eslint-plugin-local

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

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
eslint-plugin-local
3104.2.12 months ago7 years agoMinified + gzip package size for eslint-plugin-local in KB

Readme

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.