@codacy/tools-eslint-8

中文文档
0.28.0发布于 2026/11/09MITTypeScriptCommonJS近 30 天下载 1.2万

ESLint 8 adapter — Library-mode JavaScript/TypeScript linter (legacy config)

原始使用文档
文档目录7 节
  1. Table of Contents
  2. Overview
  3. Coexistence with ESLint 9
  4. Updating patterns
  5. Updating the ESLint version
  6. Development
  7. Notes for maintainers

@codacy/tools-eslint-8

Table of Contents


Overview

JavaScript/TypeScript linter using ESLint 8 with the legacy config format (.eslintrc). Uses the Library execution strategy — calls the ESLint API directly rather than spawning a subprocess.

PropertyValue
Tool IDESLint8
Codacy UUIDf8b29663-2cb2-498d-b923-a10c6a8c05cd
StrategyLibrary
LanguagesJavaScript, TypeScript
Dependencyeslint npm package (v8.x) + 90+ plugin packages
Patterns2816 (285 core + 2531 plugin)
File patterns**/*.js, **/*.jsx, **/*.ts, **/*.tsx

Coexistence with ESLint 9

This adapter coexists safely with @codacy/tools-eslint-9 in the same monorepo and the same Node.js process. Key design decisions:

  • pnpm isolation: Each adapter has its own node_modules/eslint symlink pointing to a different version in the pnpm store. import("eslint") from each adapter's built output resolves to the correct version.
  • Inline types: ESLint API types are defined inline (not imported from the eslint package) to avoid TypeScript declaration conflicts.
  • Separate plugin registries: Plugins that need different versions for ESLint 8 vs 9 (e.g. @typescript-eslint, react-hooks) are installed at the correct version in each adapter's own dependencies.
  • Lint script: Uses the root's ESLint 9 for linting source code (node ../../../node_modules/eslint/bin/eslint.js) to avoid the local ESLint 8 binary conflicting with the root's flat config.

Updating patterns

# Re-fetch pattern metadata from the Codacy API
pnpm prefetch

# Commit the result
git add src/patterns.json

Pattern IDs use the codacy-eslint encoding: _ → __, / → _. Examples:

  • ESLint8_no-unused-vars (core rule)
  • ESLint8_@typescript-eslint_no-unused-vars (scoped plugin)
  • ESLint8_react_jsx-no-target-blank (non-scoped plugin)

Updating the ESLint version

ESLint 8 is end-of-life (October 2024). Version updates are not expected. This adapter targets the final 8.57.x release. For newer ESLint, use the eslint-9 adapter.

Development

pnpm build    # Build with tsup
pnpm test     # Run tests

Notes for maintainers

  • Preset mappings (src/pattern-mappings.json): prefixes only. @stylistic's JSX rules live under ESLint8_@stylistic_ beside that plugin's framework-agnostic rules, so the react key names the ESLint8_@stylistic_jsx- sub-prefix explicitly. Codacy tags those rules reactjs, but gating on the tag is wrong here: the same tag sits on ESLint8_functional_no-classes ("no ES6 classes anywhere"), css-modules_no-undef-class and test-selectors_onChange, none of which are React rules — and because filterAutoPatterns ORs matched keys, a tag also drags in rules prefix-owned by other keys entirely. Measured on an ordinary React login form, tag gating produced 15 findings from rules the project had no reason to enable. Same reasoning for the Vue SFC custom-block rules, named as ESLint8_jsonc_vue-custom-block / ESLint8_yml_vue-custom-block.
  • ESLint 8 uses the legacy config format (.eslintrc.*). The adapter generates legacy config objects with plugins as string names, parser as an absolute path, and overrides for TypeScript-specific configuration.
  • No executable config files: .eslintrc.js, .eslintrc.cjs, and the extensionless .eslintrc are excluded from local config detection because those formats can directly execute repo-controlled code. Only static formats (.eslintrc.yaml, .eslintrc.yml, .eslintrc.json) are detected. Note: this does not fully eliminate code execution when local configs are enabled — ESLint legacy config fields like extends and parser can still resolve to repo-controlled modules.
  • Plugin resolution: resolvePluginsRelativeTo points ESLint at this adapter's package root so it finds plugins in our node_modules rather than the user's repo.
  • Always-on TS parser override: A .ts/.tsx override with @typescript-eslint/parser is always created when any rules are enabled — not just when @typescript-eslint rules are present. This ensures all plugins (e.g. jsdoc) can analyze TypeScript files correctly, and that core rules like no-redeclare and no-undef are unconditionally disabled for TS files (TypeScript's compiler handles them natively).
  • No project: true: The TS parser override does not use project: true because it fails when no tsconfig.json covers the target files. Most @typescript-eslint rules work without type information; type-aware rules degrade gracefully.
  • Pattern IDs use the same encoding as the codacy-eslint wrapper: _ → __ then / → _ (encode), reverse for decode.
  • The blacklist.ts contains rules known to crash ESLint or produce severe false positives, shared with the ESLint 9 adapter's blacklist.
  • checkAvailability verifies that the loaded ESLint version starts with 8. to prevent accidental use of ESLint 9.
  • The tool is an npm payload, not a dependency: it is resolved at run time (a Codacy-managed install under ~/.codacy/tools/<id>/, a CODACY_TOOL_ROOT_<ID> root, or this package's own node_modules in the monorepo) and install runs npm ci against the committed payload/package-lock.json. See src/payload.ts.

版本与发布记录

@codacy/tools-eslint-8 共发布 29 个版本,首次发布于 2026/04/17;过去 12 个月发布了 29 个版本。

版本发布日期距今
0.28.0latest2026/11/09今天
0.27.12026/11/054 天前
0.27.02026/11/036 天前
0.26.02026/10/3010 天前
0.25.02026/10/1921 天前
0.24.02026/09/251 个月前

关于 @codacy/tools-eslint-8 的常见问题

@codacy/tools-eslint-8 是什么?

ESLint 8 adapter — Library-mode JavaScript/TypeScript linter (legacy config)

如何安装 @codacy/tools-eslint-8?

在项目目录运行 npm install @codacy/tools-eslint-8,或使用 pnpm add / yarn add / bun add。

@codacy/tools-eslint-8 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@codacy/tools-eslint-8 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@codacy/tools-eslint-8 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@codacy/tools-eslint-8 可以商用吗?

@codacy/tools-eslint-8 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@codacy/tools-eslint-8 的下载量有多少?

根据 npm 官方下载统计,@codacy/tools-eslint-8 在 2026/10/10 – 2026/11/08 这 30 天内被下载 11,795 次,日均约 393 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@codacy/tools-eslint-8 还在维护吗?

最新版本 0.28.0 发布于 2026/11/09(今天);至今共发布 29 个版本,其中过去 12 个月发布了 29 个;首次发布于 2026/04/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。