eslint-plugin-local
TypeScript icon, indicating that this package has built-in type declarations

4.2.1 • Public • Published

This ESLint plugin allows you to implement a custom ESLint plugin including custom rules in your repository without installing them as a dependency.

Originally inspired by cletusw/eslint-plugin-local-rules.

Installation

npm install --save-dev eslint-plugin-local

Usage

The JavaScript file named .eslint-plugin-local.js or .eslint-plugin-local/index.js or use .cjs file extension must be created at the root of your repository, which the file has the content of an ESLint plugin. For example:

module.exports = {
  rules: {
    sample: {
      // Optional
      meta: {
        // See https://eslint.org/docs/latest/extend/custom-rules#rule-structure
      },

      // Mandatory
      create: function (context) {
        // Implementation goes here
        // See https://eslint.org/docs/latest/extend/custom-rules
      },

      // Optional
      // Unit test can be triggered by `eslint-plugin-local test` command
      // See https://eslint.org/docs/latest/integrate/nodejs-api#ruletester
      tests: {
        valid: [...],
        invalid: [...],
      }
    }
  }
}

Then apply the plugin to your .eslintrc file:

plugins:
  - local
rules:
  - local/sample: error

Additionally, this package provides eslint-plugin-local test command out of the box, which it scans for tests: { valid: [], invalid: [] } field in each rule and runs RuleTester internally.

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-local

Weekly Downloads

99,242

Version

4.2.1

License

MIT

Unpacked Size

10.2 kB

Total Files

7

Last publish

Collaborators

  • rebasecop