Registry / testing / eslint-plugin-local-rules

eslint-plugin-local-rules

JSON →
library3.0.2jsnpmunverified

An ESLint plugin that enables project-specific rules from a local eslint-local-rules.js file, similar to the deprecated --rulesdir CLI option. Current stable version is 3.0.2, with releases about every 6-12 months. Supports npm/yarn/pnpm workspaces, TypeScript via ts-node, and provides all/all-warn configs. Key differentiators: minimal setup, automatic discovery of local rules, and workspace-aware rule resolution. Minimum Node 12.

npm install eslint-plugin-local-rules
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-LOCA
E
eslint-plugin-local-rules
testingjavascriptv3.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
module.exports = { plugins: ['local-rules'] }
require('eslint-plugin-local-rules')
The plugin is used via ESLint config, not directly imported. Include 'local-rules' in plugins array.
local-rules config
extends: ['plugin:local-rules/all']
extends: ['eslint-plugin-local-rules/all']
Use 'plugin:local-rules/all' (or 'plugin:local-rules/all-warn' for warnings), not the full package name.
rules file
module.exports = { 'rule-name': { ... } }
module.exports = { rules: { 'rule-name': { ... } } }
The exports of eslint-local-rules.js should be a plain object of rule definitions, not nested under a 'rules' key.

Shows how to define a local rule in eslint-local-rules.js and enable it via ESLint config.

// Create eslint-local-rules.js in project root module.exports = { 'no-console-log': { meta: { docs: { description: 'disallow console.log', category: 'Best Practices' }, schema: [] }, create: function (context) { return { CallExpression: function (node) { if (node.callee.type === 'MemberExpression' && node.callee.object.name === 'console' && node.callee.property.name === 'log') { context.report({ node, message: 'Unexpected console.log' }); } } }; } } }; // In .eslintrc.json { "plugins": ["local-rules"], "rules": { "local-rules/no-console-log": "error" } }
Debug
Known issues
breakingv2.0.0: Workspace support changed rule resolution: check CWD for eslint-local-rules.js before plugin install location.
fix
If using workspaces, ensure you run ESLint from the workspace subdirectory, not the project root, especially when a workspace-level rules file exists.
affects: >=2.0.0 <3.0.0
gotchaIf an eslint-local-rules.js file exists in both a workspace subdirectory and the project root, the workspace one takes precedence only when running ESLint from that workspace directory.
fix
Run ESLint from the workspace directory (e.g., cd src/app && npx eslint index.js) to pick up workspace-specific rules.
affects: >=2.0.0
gotchaWhen using ts-node for TypeScript rules, you must set module to 'commonjs' in ts-node options, otherwise imports may fail.
fix
Add `compilerOptions: { module: 'commonjs' }` to ts-node.register() call in eslint-local-rules/index.js.
affects: >=1.0.0
breakingMinimum Node.js version increased to 12 in v3.0.1.
fix
Use Node.js 12 or higher.
affects: >=3.0.1
Errors
Common errors & fixes
Error: Failed to load plugin 'local-rules' declared in '.eslintrc': Cannot find module 'eslint-plugin-local-rules'
eslint-plugin-local-rules not installed or not in node_modules.
fix
Run `npm install eslint-plugin-local-rules --save-dev` in your project.
Error: Cannot find module 'eslint-local-rules'
eslint-local-rules.js or eslint-local-rules/index.js not found in the expected directory.
fix
Create an eslint-local-rules.js file in your project root (or in the workspace directory when using workspaces).
TypeError: Invalid rule definition: rule 'my-rule' must be an object with 'create' function
The rule exported in eslint-local-rules.js is not a valid rule object (missing create or meta).
fix
Ensure each rule has both a `meta` object and a `create` function: `{ meta: { ... }, create(context) { return { ... } } }`.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies
eslintrequiredPeer dependency; required to use the plugin.
Agent activity
6 hits · last 30 days
node
6
Resources
eslint-plugin-local-rules — npm install eslint-plugin-local-rules · libregistry