flaviostutz / monolint

Linter for monorepos. Checks folder structure, module contents, file contents and naming conventions
MIT License
7 stars 4 forks source link

Create rule "module-required-files" #4

Closed flaviostutz closed 1 year ago

flaviostutz commented 1 year ago

Check if modules have the specified files. Can be strict or not.

.monolinter.json:

{
  "rules": {
    "module-required-files": {
      "strict": false,
      "files": ["README.md", "Makefile"]
     }
  }
}
tiagostutz commented 1 year ago

As we already have "module-folder-structure" how about changing this module name to "module-required-files" to avoid mixing up both?

Also, what does "strict" means in this case? Means that it requires exactly the listed files and if there are other files than those it would be a violation?

flaviostutz commented 1 year ago

Good one! Strict means that only those files are allowed to be in the module.

tiagostutz commented 1 year ago

Cool! Please, can you assign this issue to me? I can tackle that.

flaviostutz commented 1 year ago

@tiagostutz I was wondering if, on top of the simpler way of describing required files, we could have a more advanced configuration like:

{
  "rules": {
    "module-required-files": {
      "strict": false,
      "files": [ "README.md", "Makefile" ]
      "if-files": {
        "package.json": ["tsconfig.json", "jest.config.js", ".eslintrc.js"],
        "go.mod": ["go.sum"]
      }
    }
}

In this example,

tiagostutz commented 1 year ago

Sounds good! We could create another issue for that and keep this one with the simple configuration, as it will already bring value. And I have this small suggestion of change on top of what you proposed for the format. We could have the simple format (tackled in this ticket):

{
  "rules": {
    "module-required-files": {
      "strict": false,
      "files": ["README.md", "Makefile"]
     }
  }

And the advanced config:

{
   "rules":{
      "module-required-files":{
         "files":[
            {
               "all":[
                  "README.md",
                  "Makefile"
               ],
               "strict": false
            },
            {
               "package.json":[
                  "tsconfig.json",
                  "jest.config.js",
                  ".eslintrc.js"
               ],
               "strict": false
            },
            {
               "go.mod":[
                  "go.sum"
               ],
               "strict": true
            }
         ]
      }
   }
}

wdyt?

flaviostutz commented 1 year ago

Perfect! This proposal was moved to #20