{"id":19822,"library":"eslint-plugin-local-rules","title":"eslint-plugin-local-rules","description":"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.","status":"active","version":"3.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/cletusw/eslint-plugin-local-rules","tags":["javascript","eslint","eslintplugin"],"install":[{"cmd":"npm install eslint-plugin-local-rules","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-local-rules","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-local-rules","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required to use the plugin.","package":"eslint","optional":false}],"imports":[{"note":"The plugin is used via ESLint config, not directly imported. Include 'local-rules' in plugins array.","wrong":"require('eslint-plugin-local-rules')","symbol":"plugin","correct":"module.exports = { plugins: ['local-rules'] }"},{"note":"Use 'plugin:local-rules/all' (or 'plugin:local-rules/all-warn' for warnings), not the full package name.","wrong":"extends: ['eslint-plugin-local-rules/all']","symbol":"local-rules config","correct":"extends: ['plugin:local-rules/all']"},{"note":"The exports of eslint-local-rules.js should be a plain object of rule definitions, not nested under a 'rules' key.","wrong":"module.exports = { rules: { 'rule-name': { ... } } }","symbol":"rules file","correct":"module.exports = { 'rule-name': { ... } }"}],"quickstart":{"code":"// Create eslint-local-rules.js in project root\nmodule.exports = {\n  'no-console-log': {\n    meta: { docs: { description: 'disallow console.log', category: 'Best Practices' }, schema: [] },\n    create: function (context) {\n      return {\n        CallExpression: function (node) {\n          if (node.callee.type === 'MemberExpression' && node.callee.object.name === 'console' && node.callee.property.name === 'log') {\n            context.report({ node, message: 'Unexpected console.log' });\n          }\n        }\n      };\n    }\n  }\n};\n\n// In .eslintrc.json\n{\n  \"plugins\": [\"local-rules\"],\n  \"rules\": { \"local-rules/no-console-log\": \"error\" }\n}","lang":"javascript","description":"Shows how to define a local rule in eslint-local-rules.js and enable it via ESLint config."},"warnings":[{"fix":"If using workspaces, ensure you run ESLint from the workspace subdirectory, not the project root, especially when a workspace-level rules file exists.","message":"v2.0.0: Workspace support changed rule resolution: check CWD for eslint-local-rules.js before plugin install location.","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"Run ESLint from the workspace directory (e.g., cd src/app && npx eslint index.js) to pick up workspace-specific rules.","message":"If 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.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Add `compilerOptions: { module: 'commonjs' }` to ts-node.register() call in eslint-local-rules/index.js.","message":"When using ts-node for TypeScript rules, you must set module to 'commonjs' in ts-node options, otherwise imports may fail.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use Node.js 12 or higher.","message":"Minimum Node.js version increased to 12 in v3.0.1.","severity":"breaking","affected_versions":">=3.0.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install eslint-plugin-local-rules --save-dev` in your project.","cause":"eslint-plugin-local-rules not installed or not in node_modules.","error":"Error: Failed to load plugin 'local-rules' declared in '.eslintrc': Cannot find module 'eslint-plugin-local-rules'"},{"fix":"Create an eslint-local-rules.js file in your project root (or in the workspace directory when using workspaces).","cause":"eslint-local-rules.js or eslint-local-rules/index.js not found in the expected directory.","error":"Error: Cannot find module 'eslint-local-rules'"},{"fix":"Ensure each rule has both a `meta` object and a `create` function: `{ meta: { ... }, create(context) { return { ... } } }`.","cause":"The rule exported in eslint-local-rules.js is not a valid rule object (missing create or meta).","error":"TypeError: Invalid rule definition: rule 'my-rule' must be an object with 'create' function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}