{"id":14562,"library":"eslint-rule-extender","title":"ESLint Rule Extender Utility","description":"eslint-rule-extender is a utility library designed to facilitate the extension and modification of existing ESLint rules without needing to rewrite them entirely. It provides a programmatic API to override aspects of an `ESLintRule` object, allowing developers to customize `meta` properties, add new AST visitors, or modify the reporting behavior of a rule. This can be particularly useful for creating highly specific linting rules based on established ones, or for adapting third-party rules to fit unique project requirements. As of version 0.0.1, it focuses on core functionality, offering a lean approach to rule customization. Its release cadence is not explicitly defined, but as a utility, updates would likely follow ESLint API changes or community-driven feature requests. A key differentiator is its focus on *extending* rather than *composing* rules, providing granular control over specific aspects.","status":"active","version":"0.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/kaicataldo/eslint-rule-extender","tags":["javascript","eslint","custom","rule","rules","plugin","plugins"],"install":[{"cmd":"npm install eslint-rule-extender","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-rule-extender","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-rule-extender","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for any ESLint utility, as it operates on ESLint rule objects and context.","package":"eslint","optional":false}],"imports":[{"note":"Primary CommonJS import pattern. Given the 0.0.1 version, CommonJS is the expected module system.","symbol":"ruleExtender","correct":"const ruleExtender = require('eslint-rule-extender');"},{"note":"ESM import for `ruleExtender`. The package at 0.0.1 likely doesn't have explicit ESM exports, so this might require bundler configuration or be unsupported. It's a default export.","wrong":"import { ruleExtender } from 'eslint-rule-extender';","symbol":"ruleExtender","correct":"import ruleExtender from 'eslint-rule-extender';"}],"quickstart":{"code":"const ruleExtender = require('eslint-rule-extender');\nconst { originalRule } = require('eslint-plugin-example'); // Replace with a real ESLint rule import\n\n// Example: Define a placeholder originalRule for demonstration\nconst mockOriginalRule = {\n  meta: {\n    type: 'problem',\n    docs: {\n      description: 'Disallow direct use of ThisExpression (mock)',\n      category: 'Possible Problems',\n      recommended: true\n    },\n    schema: [],\n    messages: {\n      defaultMessage: 'Avoid ThisExpression.'\n    }\n  },\n  create(context) {\n    return {\n      ThisExpression(node) {\n        context.report({\n          node,\n          messageId: 'defaultMessage'\n        });\n      }\n    };\n  }\n};\n\n// In a real scenario, you'd import an actual rule, e.g., from 'eslint/lib/rules/no-console'\n// const originalRule = require('eslint/lib/rules/no-console');\n\nconst extendedRule = ruleExtender(mockOriginalRule, {\n  metaOverrides: {\n    type: 'suggestion',\n    fixable: false,\n    messages: {\n        anAdditionalSuggestion: 'Arrow functions are fine here!',\n        ...mockOriginalRule.meta.messages\n    }\n  },\n  createAdditionalVisitors(context) {\n    return {\n      ArrowFunctionExpression(node) {\n        context.report({ node, messageId: 'anAdditionalSuggestion' });\n      }\n    };\n  },\n  reportOverrides(meta) {\n    // Only report if the node type is NOT 'ThisExpression'\n    return meta.node.type !== 'ThisExpression';\n  }\n});\n\n// To use this extended rule, you would typically export it from an ESLint plugin:\n// module.exports = {\n//   rules: {\n//     'my-extended-rule': extendedRule\n//   }\n// };\n\nconsole.log('Extended Rule Meta:', extendedRule.meta);\n// Simulate a rule execution for demonstration (not how ESLint actually runs it)\n// In a real ESLint setup, this rule would be applied to source code.\n// For now, we just show it's configured.\n","lang":"javascript","description":"This example demonstrates how to use `eslint-rule-extender` to customize an existing rule by overriding its `meta` properties, adding new visitor callbacks, and conditionally suppressing reports."},"warnings":[{"fix":"Review the package's GitHub repository for the latest status and any new releases before integrating into production systems. Pin the exact version in `package.json`.","message":"The package is at version 0.0.1, indicating early development. API stability is not guaranteed, and future versions may introduce breaking changes without a major version bump.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"If using in an ESM-only Node.js project, test `import ruleExtender from 'eslint-rule-extender';` thoroughly. You might need to add `\"type\": \"module\"` to your `package.json` or consult the package's repository for ESM support plans.","message":"The README examples use `require()`, suggesting primary support for CommonJS. While bundlers might handle ESM `import` statements, direct Node.js ESM environments might require explicit configuration or may not be supported at this early version.","severity":"gotcha","affected_versions":"0.0.1"},{"fix":"Use the spread operator (`...originalRule.meta.messages`) when defining `metaOverrides.messages` to ensure all original message IDs are available alongside new ones, or explicitly define all required messages.","message":"When overriding `meta` properties, ensure that the original rule's messages are preserved or correctly merged if you intend to still use them. The `metaOverrides` will fully replace properties, so careful merging is necessary for objects like `messages`.","severity":"gotcha","affected_versions":"0.0.1"}],"env_vars":null,"search_vec":"'0.0.1':90 'adapt':77 'add':48 'allow':42 'api':34,119 'approach':99 'aspect':37,144 'ast':50 'base':71 'behavior':56 'cadenc':105 'chang':120 'communiti':123 'community-driven':122 'compos':137 'control':141 'core':94 'creat':66 'custom':45,102,147 'defin':109 'design':13 'develop':43 'differenti':129 'driven':124 'entir':29 'eslint':1,6,22,118,146 'eslint-rule-extend':5 'eslintrul':40 'establish':73 'exist':21 'explicit':108 'extend':3,8,134 'extens':17 'facilit':15 'featur':125 'fit':83 'focus':92,132 'follow':117 'function':95 'granular':140 'high':67 'javascript':145 'key':128 'lean':98 'librari':12 'like':116 'lint':69 'meta':46 'modif':19 'modifi':53 'need':25 'new':49 'object':41 'offer':96 'one':74 'overrid':36 'parti':80 'particular':63 'plugin':150,151 'programmat':33 'project':85 'properti':47 'provid':31,139 'rather':135 'releas':104 'report':55 'request':126 'requir':86 'rewrit':27 'rule':2,7,23,59,70,81,101,138,148,149 'specif':68,143 'third':79 'third-parti':78 'uniqu':84 'updat':114 'use':64 'util':4,11,113 'version':89 'visitor':51 'without':24 'would':115","created_at":"2026-04-20T18:42:26.988277+00:00","updated_at":"2026-04-20T18:42:26.988277+00:00","problems":[{"fix":"Replace `require('eslint-plugin-example')` with an actual ESLint rule import, for example, `require('eslint/lib/rules/no-debugger')` for a built-in rule, or the path to a rule from an installed plugin.","cause":"The quickstart example uses `eslint-plugin-example` as a placeholder for an original rule. This plugin does not actually exist on npm.","error":"Error: Cannot find module 'eslint-plugin-example'"},{"fix":"Ensure that `originalRule` is correctly imported and is a valid ESLint rule object with at least a `meta` property, or that the path to the rule is correct.","cause":"The `originalRule` passed to `ruleExtender` is undefined or not a valid ESLint rule object, which typically has a `meta` property.","error":"TypeError: Cannot read properties of undefined (reading 'meta')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/kaicataldo/eslint-rule-extender","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/eslint-rule-extender","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}