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-parent-folder" #5

Closed flaviostutz closed 1 year ago

flaviostutz commented 1 year ago

Check if module is inside specific parent folder paths. Defaults to "modules"

.monolinter.json:

{
  "rules": {
    "module-parent-folder": true
  }
}
{
  "rules": {
    "module-parent-regex": ["services", "web", "libs", "services/group1", "services/group2"]
  }
}
tiagostutz commented 1 year ago

Hi! I'm taking this for my Open Source Friday.! 🕹️

flaviostutz commented 1 year ago

🎉🎉

tiagostutz commented 1 year ago

I think it would make sense to have the module-parent-folder being the array of regex instead of having two different attributes, right? Like:

{
  "rules": {
    "module-parent-folder": ["services", "web", "libs", "services/group1", "services/group2"]
  }
}

Right?

And also allowing the glob pattern style...?

tiagostutz commented 1 year ago

Also, I'm not sure if it in this case having a default value makes sense... because this type of structure is very wide IMO. Maybe it would be better to have it just as an array of glob patterns. wdyt?

flaviostutz commented 1 year ago

An array of glob patterns is perfect and very powerful! The default would be just a tip for people that doesn't know how to structure their Repo at first, and who already knows their structure would be pushed to override the rule so. This way on the first "errors" the person that already have its own structure will be presented to this rule, if we dont have and error maybe they won't even know we have this rule. Just an idea :)

About glob processing, we use it on discovermodules already using “fast-glob”. Take a look while implementing it.

tiagostutz commented 1 year ago

Nice, thanks for the fast-glob tip, I'll check that out! Very handy.

About the default modules folder, still not sure if there is enough common sense that a project would have modules as the parent folder of the created modules. For instance, in https://github.com/vsavkin/large-monorepo we don't have it and in some of the projects at https://github.com/korfuri/awesome-monorepo#notable-public-monorepos I couldn't find a common sense. I still think that this lack of common sense/practice leads to not having a default approach so far.

My suggestion is to start without the default as it simplifies a little bit the code, and then we discuss this in another issue. Sounds reasonable?

flaviostutz commented 1 year ago

Ok! Let's do that.