首页 > 解决方案 > Luacheck 包含排除目录中的文件

问题描述

我有一个这样的项目(其实还有更多的文件和目录):

.
├── src
│   ├── main.lua
│   └── smth.lua
└── tests
    ├── others
    │   ├── others_1.lua
    │   ├── others_2.lua
    │   └── others_3.lua
    ├── speed_tests
    │   ├── test1.lua
    │   └── test2.lua
    └── sql
        ├── join.lua
        └── select.lua

我有这样的.luacheckrc

include_files = {
    "**/*.lua"
}

exclude_files = {
    "tests/**/*.lua",
}

我希望luacheck实用程序检查目录中的tests/sql文件,但不要触摸tests/. 当然,我可以明确地写:

exclude_files = {
    "tests/others/*.lua",
    "tests/speed_tests/*.lua"
}

,但在实际项目中,有 15 个以上的目录,这样做看起来不太好。

如何优雅地达成目标?

标签: lualuacheck

解决方案


那时不要使用排除,只包含您希望遍历的目录。

include_files = {
    "src/*.lua",
    "tests/sql/*.lua"
}

推荐阅读