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多个目录,这样做看起来不好看。

我怎样才能优雅地达到目标?

点赞
用户3342050
用户3342050

不要使用exclude,只包含你希望遍历的目录。

include_files = {
    "src/*.lua",
    "tests/sql/*.lua"
}
2020-10-21 08:51:47