eslint-plugin-lint

raw JSON →
1.0.0 verified Fri May 01 auth: no javascript

Load arbitrary ESLint rules from multiple directories into a single namespace (lint/). Version 1.0.0 is the current stable release; the package is quite stable with no frequent releases. It differentiates from alternatives like eslint-plugin-rulesdir by supporting multiple rule directories simultaneously, and from eslint-plugin-local-rules by offering a simple API and not requiring a specific configuration structure. It works with Node.js >=4 and is intended for use in ESLint configurations to merge custom rules from various sources into one plugin namespace.

error Error: Cannot find module 'eslint-plugin-lint'
cause Package not installed or not in node_modules.
fix
Run 'npm install eslint-plugin-lint --save-dev' from the project root.
error ESLint couldn't find the plugin "eslint-plugin-lint".
cause Missing 'lint' in plugins array of ESLint config.
fix
Add 'lint' to the plugins array in your ESLint configuration.
error Definition for rule 'lint/no-foo' was not found.
cause Rule file not in the loaded directories or filename mismatch.
fix
Ensure 'no-foo.js' exists in one of the directories passed to load() and the rule name uses the filename without extension.
error Failed to load rule 'lint/no-bar': Rule is not a function.
cause Rule file does not export a valid ESLint rule (object with create).
fix
Export an object with 'meta' and 'create' from the rule file.
gotcha Paths passed to load() must be absolute to avoid resolution issues with cwd.
fix Use path.join(__dirname, 'relative/path') to resolve to an absolute path.
gotcha Rule files must have a .js extension and export a valid ESLint rule object.
fix Ensure each rule file exports an object with meta and create properties.
gotcha Plugin name is fixed as 'lint'; you cannot rename the namespace.
fix Always reference rules as 'lint/rule-name' and add 'lint' to plugins array.
gotcha load() must be called before ESLint config is evaluated; it modifies global state.
fix Call load() at the top level of your .eslintrc.js or config file.
npm install eslint-plugin-lint
yarn add eslint-plugin-lint
pnpm add eslint-plugin-lint

Shows how to configure ESLint to load custom rules from two directories and reference them under the lint/ namespace.

// In your .eslintrc.js
const path = require('path');
require('eslint-plugin-lint').load(
  path.join(__dirname, 'my-rules'),
  path.join(__dirname, 'their-rules')
);
module.exports = {
  plugins: ['lint'],
  rules: {
    'lint/no-foo': 'warn',
    'lint/no-bar': 'error'
  }
};