Skip to content

JCorpe26/folder-lint

Repository files navigation

Folder Structure Lint

A custom eslint to ensure files follow a folder structure.

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-folder-lint:

npm install eslint-plugin-folder-lint --save-dev

(Local development when creating a rule):

# folder-lint
npm run build

# target repo
npm install --D file:../folder-lint/.build

Usage

Add folder-lint to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": ["folder-lint"]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "folder-lint/lint": ['error, {
            baseDir: 'src',
            allowedPaths: ['components/*']
        }]
    }
}

For example:

Rule Meaning
components ✅  The directory components (and files in it) is accepted.
❌  Any nested directory is not accepted.
components/* ✅  The directory components is accepted.
✅  Any first level nested directory is accepted.
❌  Any second level nested directory is not accepted.
components/*/utils ✅  The directory components is accepted.
✅  Any first level nested directory is accepted.
✅  The second level nested directory utils is accepted.
❌  Any other second level nested directory is not accepted.
components/** ✅  The directory components is accepted.
✅  Any nested directory on any level is accepted.
components/*/components/** ✅  The directory components is accepted.
✅  Any first level nested directory is accepted.
✅  The second level nested directory components is accepted.
❌  Any other second level nested directory is not accepted.
✅  Any nested directory on any level inside of components directory is accepted.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published