Skip to content

Igorkowalski94/eslint-plugin-project-structure-playground

Repository files navigation

ย 

Cloud Shows an illustrated sun in light mode and a moon with stars in dark mode. Cloud

Video gameOwl
eslintโ€‘pluginโ€‘project-structureโ€‘playground

Playground for eslint-plugin-project-structure.

๐Ÿ“š Documentation

๐Ÿ Getting started

Step 1 (optional)

The project uses ESLint's new config system as default. If you want to test on the old eslint config, follow these steps:

  • Remove package.json
  • Remove eslint.config.mjs
  • Remove independentModules.mjs
  • Remove fileComposition.mjs
  • Remove folderStructure.mjs
  • Rename packageLegacyConfig.json to package.json

Step 2

npm install
npm run lint:watch

or

npm run lint

๐Ÿ“‹ General Information

Warning

Folder needs to contain at least one file/subfolder with file to be validated. ESLint and Git ignore empty folders, so they wonโ€™t be pushed to the repository and will only remain visible locally.

  • All files in the features folder have all possible correct imports. You can try importing other files to see the errors.
  • Examples of individual functionalities can be found in the examples folder.
  • If you have any questions or need help creating a configuration that meets your requirements, click here.

๐Ÿ“‹ General project rules

  • Variables in .const.ts files must follow {SNAKE_CASE}.
  • .consts.ts files may only contain variables.
  • Interfaces and types in .types.ts files must follow {PascalCase}.
  • Enums in .types.ts files must follow {SNAKE_CASE}.
  • .types.ts files may only contain interfaces, types and enums.
  • All .ts files must contain only one main function. The main function should be named {fileName}. The main function can have an interface or type which must be named {FileName}Props or {FileName}Return.
  • All .tsx files must contain only one main function. The main function should be named {FileName}. The main function can have an interface or type which must be named {FileName}Props or {FileName}Return.
  • All nested functions and variables in .ts and .tsx files must follow {camelCase}.
  • .types.ts files can only import from node_modules and nothing else.
  • .consts.ts files can only import from .types.ts files located in the same directory.
  • .api.ts files can only import from .consts.ts and .types.ts files located in the same directory.

๐Ÿ“ Folder structure and independent module rules

.
โ”œโ”€โ”€ ...
โ”œโ”€โ”€ ๐Ÿ“„ fileComposition.mjs
โ”œโ”€โ”€ ๐Ÿ“„ folderStructure.mjs
โ”œโ”€โ”€ ๐Ÿ“„ independentModules.mjs
โ”œโ”€โ”€ ๐Ÿ“„ eslint.config.mjs
โ””โ”€โ”€ ๐Ÿ“‚ src
    โ”œโ”€โ”€ ๐Ÿ“‚ examples // Private
    โ”œโ”€โ”€ ๐Ÿ“‚ hooks
    โ”‚   โ”œโ”€โ”€ ...
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ useSimpleGlobalHook.test.ts       // Private.
    โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ useSimpleGlobalHook.ts            // Public.
    โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ useComplexGlobalHook              // useComplexGlobalHook family.
    โ”‚       โ”œโ”€โ”€ ๐Ÿ“ hooks (recursion)             // Private / Public for useComplexGlobalHook family.
    โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ useComplexGlobalHook.api.ts    // Private / Public for useComplexGlobalHook family.
    โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ useComplexGlobalHook.types.ts  // Private / Public for useComplexGlobalHook family.
    โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ useComplexGlobalHook.consts.ts // Private / Public for useComplexGlobalHook family.
    โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ useComplexGlobalHook.test.ts   // Private.
    โ”‚       โ””โ”€โ”€ ๐Ÿ“„ useComplexGlobalHook.ts        // Public.
    โ””โ”€โ”€ ๐Ÿ“‚ features
        โ”œโ”€โ”€ ...
        โ”œโ”€โ”€ ๐Ÿ“„ Feature3.test.tsx            // Private.
        โ”œโ”€โ”€ ๐Ÿ“„ Feature3.tsx                 // Public.
        โ”œโ”€โ”€ ๐Ÿ“‚ Feature2                     // Feature2 family. Same structure as Feature1.
        โ””โ”€โ”€ ๐Ÿ“‚ Feature1                     // Feature1 family.
            โ”œโ”€โ”€ ๐Ÿ“„ feature1.api.ts          // Private / Public for Feature1 family.
            โ”œโ”€โ”€ ๐Ÿ“„ feature1.types.ts        // Private / Public for Feature1 family.
            โ”œโ”€โ”€ ๐Ÿ“„ feature1.consts.ts       // Private / Public for Feature1 family.
            โ”œโ”€โ”€ ๐Ÿ“„ Feature1.test.tsx        // Private.
            โ”œโ”€โ”€ ๐Ÿ“„ Feature1.tsx             // Public.
            โ”œโ”€โ”€ ๐Ÿ“‚ components
            โ”‚   โ”œโ”€โ”€ ...
            โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ SimpleComponent.test.tsx       // Private.
            โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ SimpleComponent.tsx            // Private / Public for Feature1 family / Public for ComplexComponent family.
            โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ ComplexComponent               // ComplexComponent family.
            โ”‚       โ”œโ”€โ”€ ๐Ÿ“ components (recursion)     // Private / Public for ComplexComponent family.
            โ”‚       โ”œโ”€โ”€ ๐Ÿ“ hooks (recursion)          // Private / Public for ComplexComponent family.
            โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ complexComponent.api.ts     // Private / Public for ComplexComponent family.
            โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ complexComponent.types.ts   // Private / Public for ComplexComponent family.
            โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ complexComponent.consts.ts  // Private / Public for ComplexComponent family.
            โ”‚       โ”œโ”€โ”€ ๐Ÿ“„ ComplexComponent.test.tsx   // Private.
            โ”‚       โ””โ”€โ”€ ๐Ÿ“„ ComplexComponent.tsx        // Private / Public for ComplexComponent family / Public for Feature1 family / Public for SimpleComponent.tsx.
            โ””โ”€โ”€ ๐Ÿ“‚ hooks
                โ”œโ”€โ”€ ...
                โ”œโ”€โ”€ ๐Ÿ“„ useSimpleHook.test.ts           // Private.
                โ”œโ”€โ”€ ๐Ÿ“„ useSimpleHook.ts                // Private / Public for Feature1 family / Public for useComplexHook family.
                โ””โ”€โ”€ ๐Ÿ“‚ useComplexHook                 // useComplexHook family.
                    โ”œโ”€โ”€ ๐Ÿ“ hooks (recursion)          // Private / Public for useComplexHook family.
                    โ”œโ”€โ”€ ๐Ÿ“„ useComplexHook.api.ts      // Private / Public for useComplexHook family.
                    โ”œโ”€โ”€ ๐Ÿ“„ useComplexHook.types.ts    // Private / Public for useComplexHook family.
                    โ”œโ”€โ”€ ๐Ÿ“„ useComplexHook.consts.ts   // Private / Public for useComplexHook family.
                    โ”œโ”€โ”€ ๐Ÿ“„ useComplexHook.test.ts     // Private.
                    โ””โ”€โ”€ ๐Ÿ“„ useComplexHook.ts          // Private / Public for useComplexHook family / Public for Feature1 family / Public for useSimpleHook.tsx.

Party Popper Sponsors

A big thank you to all the sponsors for your support! You give me the strength and motivation to keep going!

Thanks to you, I can help others create their ideal projects!

Love-You Gesture