Closed flaviostutz closed 1 year ago
As suggested in #12, I can get this one to start contributing!
Could you assign it to me?
Q: should this rule care about nested folders as well?
e.g.
{
"rules": {
"module-folder-structure": {
"folders": ["src/utils", "src/libs"]
}
}
}
Perhaps a better naming strategy if we want to add more features to this rule in the future:
folders -> allowedFolders
Or even patterns
, following serverless' framework package.patterns
idea. (if we're gonna support nested folder checks)
As suggested in #12, I can get this one to start contributing!
Could you assign it to me?
Q: should this rule care about nested folders as well?
e.g.
{ "rules": { "module-folder-structure": { "folders": ["src/utils", "src/libs"] } } }
yes!
Perhaps a better naming strategy if we want to add more features to this rule in the future:
folders -> allowedFolders
Or even
patterns
, following serverless' frameworkpackage.patterns
idea. (if we're gonna support nested folder checks)
I like the idea of using patterns as the spec, but I think the name "folder" makes it easier to understand that this rule is only about "folders", not files. If we have something like this, we can create another rule. Let's try to make the rules as small as possible, so we can combine them in different scenarios.
For the patterns, maybe we can follow the "gitignore" glob pattern style, something like we did on https://github.com/flaviostutz/monolint/blob/main/src/lint.ts#L106 while discovering modules and ignoring .monolintignore entries. The lib used is "fast-glob".
By my understanding, then we would have something like:
{
"rules": {
"module-folder-structure": {
"strict": true,
"folders": ["src/test", "src/**/utils", "src/libs/**/release"]
}
}
}
Which means, only folders that matches one of those patterns are allowed to be present (because of strict==true). If strict==false, at least one folder that follow each one of those patterns should be found.
What do you think?
closed by #36
Check if the modules have a set of folders. It can be "strict" or not (permit more than the specified folders on the module or not).
.monolinter.json: