1.0.0 • Published 1 year ago

eslint-plugin-exports-control v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

eslint-plugin-exports-control

Eslint plugin for linting exports

Installation

npm i --save-dev eslint-plugin-exports-control

Usage

Create an .eslint.json file with the following:

"plugins": [
    "exports-control"
]

Then, you can add the custom rules to the .eslint.json file:

"rules": {
  "exports-control/exports-control": "error",
}

To lint your project with ESLint, add the following script to your package.json:

{
  "scripts": {
    "lint": "eslint ."
  }
}

and run the linter with:

npm run lint

Rules

exports-control/exports-control

Config example:

"exports-control/exports-control": ['error', [{
    paths: {
      includes: ['endpoints/*'],
      excludes: ['endpoints/models/*'],
    },
    patterns: ['EndpointT$'],
    description: 'There is only endpoints models, with names end of ...EndpointT',
  }]],

Examples of incorrect code for this rule:

// in file "endpoints/user.ts"
export const CurrentUserT = ...
// or
export { CurrentUserT }

Examples of correct code for this rule:

// in file "endpoints/user.ts"
export const CurrentUserEndpointT = ...
// or
export { CurrentUserEndpointT }

// in file  "endpoints/models/roles.ts"
export enum RolesEnum { ... }
// or
export { RolesEnum }