javascriptreactjstypescripteslintlint

force folder structure and names in a repository using eslint


I'm looking to force a structure of names in a specific path for a folder and it's sub folders

not only the styling of the names (kebab, camel) but the actual names of the folders and files

lets take for an example the following paths

./src/modules/module1
./src/modules/module2
./src/modules/module3

each of the provided path should force sub folders with the names

services
components
style

creating a nested folder with a different name on those path should not be valid

so the end result should be something like that:

./src/modules/module1/services (valid)
./src/modules/module1/components (valid)
./src/modules/module2/components (valid)
./src/modules/module1/banana (not valid)
./src/modules/orange/yellow (valid)

is eslint the right tool for that? any specific plugin I should use ?

I could only find a solution for the styling of the names but didn't find anything for a fixed named structure

I'm using type-script in reactJS project and looking for a solution that is not coupled to any IDE

thanks


Solution

  • Check out FoldersLint, it should do the job.

    https://github.com/denisraslov/folderslint

    This is basically how it works: enter image description here