{"id":20009,"library":"eslint-utils","title":"eslint-utils","description":"Utility functions and classes for developing ESLint custom rules, stable version 3.0.0, released occasionally with major version bumps. Provides static evaluation on AST nodes, reference tracking for modules/globals, and helper functions like getStaticValue(), ReferenceTracker, and PatternMatcher. Differentiators: comprehensive AST utility for ESLint plugin authors, well-documented, and actively maintained by a seasoned contributor. Current version drops support for older Node.js and adds exports field.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mysticatea/eslint-utils","tags":["javascript","eslint"],"install":[{"cmd":"npm install eslint-utils","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-utils","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency, required for using the utilities in ESLint plugin context","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v3; CommonJS require() fails due to exports field restriction","wrong":"const getStaticValue = require('eslint-utils').getStaticValue","symbol":"getStaticValue","correct":"import { getStaticValue } from 'eslint-utils'"},{"note":"Class for tracking references to globals/modules","symbol":"ReferenceTracker","correct":"import { ReferenceTracker } from 'eslint-utils'"},{"note":"Direct import of internal file paths is disallowed since v3 due to exports field","wrong":"import PatternMatcher from 'eslint-utils/PatternMatcher'","symbol":"PatternMatcher","correct":"import { PatternMatcher } from 'eslint-utils'"}],"quickstart":{"code":"import { getStaticValue, ReferenceTracker } from 'eslint-utils';\n\nexport default {\n  create(context) {\n    const tracker = new ReferenceTracker(context.getScope());\n    return {\n      MemberExpression(node) {\n        const value = getStaticValue(node, context.getScope());\n        if (value && value.value === 'click') {\n          context.report({ node, message: 'Avoid using \"click\" as property.' });\n        }\n      }\n    };\n  }\n};","lang":"typescript","description":"Shows usage of getStaticValue and ReferenceTracker in an ESLint rule to detect member expressions with static value 'click'."},"warnings":[{"fix":"Use only the package root imports as documented.","message":"Direct access to internal files (e.g., 'eslint-utils/ast-utils') is disallowed in v3.0.0 due to the 'exports' field.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade Node.js to ^10.0.0 || ^12.0.0 || >=14.0.0.","message":"Node.js versions <10.0.0, 11.0.0-13.0.0 are no longer supported in v3.0.0.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Review rule logic relying on that function's output.","message":"getFunctionNameWithKind(node) result changed in some cases in v3.0.0.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"If using globalThis tracking, adjust expectations.","message":"ReferenceTracker#iterateGlobalReferences() behavior changed in v2.0.0 to recognize globalThis by default.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Update to v1.4.1 or later.","message":"getStringIfConstant() fails on BigInt and RegExp literals on runtimes without BigInt support (<v1.4.1).","severity":"gotcha","affected_versions":"<1.4.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Import from root: import { getStaticValue } from 'eslint-utils'","cause":"ESM-only package with exports field restricts subpath imports since v3.0.0.","error":"Cannot find module 'eslint-utils/ast-utils'"},{"fix":"Use import syntax or dynamic import(). If using CommonJS project, consider an older version.","cause":"Package is ESM-only since v3.0.0; require() fails.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/eslint-utils/index.mjs not supported."},{"fix":"Use named import: import { getStaticValue } from 'eslint-utils'","cause":"Misunderstood that getStaticValue is exported as default or internal property.","error":"Cannot read property 'getStaticValue' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}