@ebarooni/angular-eslint-config

中文文档
2.0.0发布于 2026/11/01MITTypeScriptES Module零依赖构建来源已验证

Shared ESLint configuration for Angular projects

原始使用文档
文档目录6 节
  1. Installation
  2. Compatibility
  3. Setup
  4. Usage
  5. Test project
  6. Migration to 2.0.0

@ebarooni/angular-eslint-config

Shared ESLint configuration for Angular projects.

Installation

npm i -D @ebarooni/angular-eslint-config @eslint/js angular-eslint eslint eslint-config-prettier typescript typescript-eslint

Compatibility

Supported versions: angular-eslint 22, ESLint 10, @eslint/js 10, eslint-config-prettier 10, TypeScript 6.0, and typescript-eslint 8.58.

Node.js in .nvmrc is 24.22.2. The engines field allows Node.js ^22.22.3, ^24.15.0, or >=26.0.0.

Use 1.x for Angular 18-21 / TypeScript 5.

Setup

Create eslint.config.mjs in the Angular project:

import defineEslintConfig from "@ebarooni/angular-eslint-config";

export default defineEslintConfig({
  tsconfigRootDir: import.meta.dirname,
});

defineEslintConfig() with no arguments also works. The config uses the TypeScript project service. The config ignores .angular/, dist/ and coverage/.

Pass extra config objects after the options object.

Usage

npx eslint
npx eslint --fix

Test project

The test directory is a small Angular 22 app. It uses this package.

npm run test at the root builds this package, installs that app, and runs ESLint there. It does not call the scripts below. npm run lint in test runs the same ESLint command. The lint result is the same.

Build this package before you lint the test app. The package entry is dist. dist is not in git.

An old dist from 1.0 causes Config (unnamed): Unexpected key "tsconfigRootDir". The 1.0 function puts the options object into the ESLint config. That object has tsconfigRootDir at the top level. Run npm run build. The 2.0 file puts the key under languageOptions.parserOptions. npm run test checks that placement.

npm ci
npm run build
cd test
npm ci
npm run lint
npm run format:check
npm run format

npm run format writes Prettier changes. npm run format:check only checks them. The root package has the same format and format:check scripts.

Migration to 2.0.0

2.0.0 uses ESLint 10. It does not support ESLint 9.

2.0.0 changes the call.

Old call:

import defineEslintConfig from "@ebarooni/angular-eslint-config";

export default defineEslintConfig([
  {
    languageOptions: {
      parserOptions: {
        project: ["tsconfig.eslint.json"],
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },
]);

New call:

import defineEslintConfig from "@ebarooni/angular-eslint-config";

export default defineEslintConfig({
  tsconfigRootDir: import.meta.dirname,
});

The old array call throws. Pass an options object.

Delete tsconfig.eslint.json when no other file uses it.

2.0.0 also enables these rules. They report errors in existing code:

  • @angular-eslint/prefer-on-push-component-change-detection with allowExplicitOnPush: false. An explicit ChangeDetectionStrategy.OnPush is an error. The rule can remove it.
  • @angular-eslint/no-uncalled-signals
  • @angular-eslint/prefer-signals
  • @angular-eslint/prefer-output-readonly
  • @angular-eslint/template/prefer-ngsrc
  • @angular-eslint/template/no-duplicate-attributes
  • @angular-eslint/template/button-has-type

This package is ESM only. It does not ship a CommonJS build. Use import. require() returns a module object, not the function.

版本与发布记录

@ebarooni/angular-eslint-config 共发布 2 个版本,首次发布于 2026/01/02;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.0latest2026/11/012 天前
1.0.02026/01/0210 个月前

关于 @ebarooni/angular-eslint-config 的常见问题

@ebarooni/angular-eslint-config 是什么?

为Angular项目共享ESLint配置

如何安装 @ebarooni/angular-eslint-config?

在项目目录运行 npm install @ebarooni/angular-eslint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(^10.0.0)、@eslint/js(^10.0.0)、typescript(>=6.0.0 <6.1.0)、angular-eslint(^22.0.0)、typescript-eslint(^8.58.0)、eslint-config-prettier(^10.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ebarooni/angular-eslint-config 支持 TypeScript 吗?

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

@ebarooni/angular-eslint-config 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ebarooni/angular-eslint-config 需要什么版本的 Node.js?

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

@ebarooni/angular-eslint-config 可以商用吗?

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

@ebarooni/angular-eslint-config 还在维护吗?

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