Skip to content

Commit 1151c98

Browse files
committed
build: update dependency eslint to v9
Manual changes: * `npx @eslint/migrate-config .eslintrc.json`. * Disable `reportUnusedDisableDirectives`. * Patch the `header` plugin as mentioned in the upstream issue.
1 parent eb058d0 commit 1151c98

File tree

6 files changed

+543
-402
lines changed

6 files changed

+543
-402
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
.npmrc=-1406867100
55
modules/testing/builder/package.json=973445093
6-
package.json=-945739255
6+
package.json=707763661
77
packages/angular/build/package.json=-1114621695
88
packages/angular/cli/package.json=-1917515334
99
packages/angular/pwa/package.json=1108903917
@@ -17,7 +17,7 @@ packages/angular_devkit/schematics/package.json=-1133510866
1717
packages/angular_devkit/schematics_cli/package.json=-2026655035
1818
packages/ngtools/webpack/package.json=605871936
1919
packages/schematics/angular/package.json=251715148
20-
pnpm-lock.yaml=451428255
20+
pnpm-lock.yaml=1012985554
2121
pnpm-workspace.yaml=-1264044456
2222
tests/package.json=700948366
23-
yarn.lock=305179493
23+
yarn.lock=-163346104

.eslintrc.json

Lines changed: 0 additions & 150 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
2+
import stylistic from '@stylistic/eslint-plugin';
3+
import typescriptEslint from '@typescript-eslint/eslint-plugin';
4+
import _import from 'eslint-plugin-import';
5+
import header from 'eslint-plugin-header';
6+
import globals from 'globals';
7+
import tsParser from '@typescript-eslint/parser';
8+
import path from 'node:path';
9+
import { fileURLToPath } from 'node:url';
10+
import js from '@eslint/js';
11+
import { FlatCompat } from '@eslint/eslintrc';
12+
13+
const __filename = fileURLToPath(import.meta.url);
14+
const __dirname = path.dirname(__filename);
15+
const compat = new FlatCompat({
16+
baseDirectory: __dirname,
17+
recommendedConfig: js.configs.recommended,
18+
allConfig: js.configs.all,
19+
});
20+
21+
// See: https://github.com/Stuk/eslint-plugin-header/issues/57
22+
header.rules.header.meta.schema = false;
23+
24+
export default [
25+
{
26+
ignores: [
27+
'**/bazel-out',
28+
'**/dist-schema',
29+
'goldens/public-api',
30+
'modules/testing/builder/projects',
31+
'packages/angular_devkit/build_angular/src/babel-bazel.d.ts',
32+
'packages/angular_devkit/build_angular/test',
33+
'packages/angular_devkit/build_webpack/test',
34+
'packages/angular_devkit/schematics_cli/blank/project-files',
35+
'packages/angular_devkit/schematics_cli/blank/schematic-files',
36+
'packages/angular_devkit/schematics_cli/schematic/files',
37+
'**/tests',
38+
'**/.yarn',
39+
'**/dist',
40+
'**/node_modules',
41+
'**/third_party',
42+
],
43+
},
44+
...fixupConfigRules(
45+
compat.extends(
46+
'eslint:recommended',
47+
'plugin:import/typescript',
48+
'plugin:@typescript-eslint/recommended',
49+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
50+
'prettier',
51+
),
52+
),
53+
{
54+
plugins: {
55+
'@stylistic': stylistic,
56+
'@typescript-eslint': fixupPluginRules(typescriptEslint),
57+
import: fixupPluginRules(_import),
58+
header,
59+
},
60+
61+
languageOptions: {
62+
globals: {
63+
...globals.node,
64+
},
65+
66+
parser: tsParser,
67+
ecmaVersion: 5,
68+
sourceType: 'module',
69+
70+
parserOptions: {
71+
project: 'tsconfig.json',
72+
},
73+
},
74+
75+
linterOptions: {
76+
// TODO: This defaults to "warn" in eslint9 and might be worth turning on.
77+
reportUnusedDisableDirectives: 'off',
78+
},
79+
80+
rules: {
81+
'@stylistic/lines-around-comment': [
82+
'error',
83+
{
84+
allowArrayStart: true,
85+
allowBlockStart: true,
86+
allowClassStart: true,
87+
allowEnumStart: true,
88+
allowInterfaceStart: true,
89+
allowModuleStart: true,
90+
allowObjectStart: true,
91+
allowTypeStart: true,
92+
beforeBlockComment: true,
93+
ignorePattern: '@license',
94+
},
95+
],
96+
97+
'@stylistic/spaced-comment': ['error', 'always'],
98+
'@typescript-eslint/consistent-type-assertions': 'error',
99+
'@typescript-eslint/no-explicit-any': 'error',
100+
'@typescript-eslint/no-non-null-assertion': 'error',
101+
'@typescript-eslint/no-unnecessary-qualifier': 'error',
102+
'@typescript-eslint/no-unused-expressions': 'error',
103+
curly: 'error',
104+
105+
'header/header': [
106+
'error',
107+
'block',
108+
[
109+
'*',
110+
' * @license',
111+
' * Copyright Google LLC All Rights Reserved.',
112+
' *',
113+
' * Use of this source code is governed by an MIT-style license that can be',
114+
' * found in the LICENSE file at https://angular.dev/license',
115+
' ',
116+
],
117+
2,
118+
],
119+
120+
'import/first': 'error',
121+
'import/newline-after-import': 'error',
122+
'import/no-absolute-path': 'error',
123+
'import/no-duplicates': 'error',
124+
125+
'import/no-unassigned-import': [
126+
'error',
127+
{
128+
allow: ['symbol-observable'],
129+
},
130+
],
131+
132+
'import/order': [
133+
'error',
134+
{
135+
alphabetize: {
136+
order: 'asc',
137+
},
138+
139+
groups: [['builtin', 'external'], 'parent', 'sibling', 'index'],
140+
},
141+
],
142+
143+
'max-len': [
144+
'error',
145+
{
146+
code: 140,
147+
ignoreUrls: true,
148+
},
149+
],
150+
151+
'max-lines-per-function': [
152+
'error',
153+
{
154+
max: 200,
155+
},
156+
],
157+
158+
'no-caller': 'error',
159+
'no-console': 'error',
160+
161+
'no-empty': [
162+
'error',
163+
{
164+
allowEmptyCatch: true,
165+
},
166+
],
167+
168+
'no-eval': 'error',
169+
'no-multiple-empty-lines': ['error'],
170+
'no-throw-literal': 'error',
171+
172+
'padding-line-between-statements': [
173+
'error',
174+
{
175+
blankLine: 'always',
176+
prev: '*',
177+
next: 'return',
178+
},
179+
],
180+
181+
'sort-imports': [
182+
'error',
183+
{
184+
ignoreDeclarationSort: true,
185+
},
186+
],
187+
188+
'spaced-comment': [
189+
'error',
190+
'always',
191+
{
192+
markers: ['/'],
193+
},
194+
],
195+
196+
'@typescript-eslint/ban-types': 'off',
197+
'@typescript-eslint/no-implied-eval': 'off',
198+
'@typescript-eslint/no-var-requires': 'off',
199+
'@typescript-eslint/no-unsafe-argument': 'off',
200+
'@typescript-eslint/no-unsafe-assignment': 'off',
201+
'@typescript-eslint/no-unsafe-call': 'off',
202+
'@typescript-eslint/no-unsafe-member-access': 'off',
203+
'@typescript-eslint/no-unsafe-return': 'off',
204+
'@typescript-eslint/no-unused-vars': 'off',
205+
'@typescript-eslint/require-await': 'off',
206+
'@typescript-eslint/restrict-plus-operands': 'off',
207+
'@typescript-eslint/restrict-template-expressions': 'off',
208+
'@typescript-eslint/unbound-method': 'off',
209+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
210+
'@typescript-eslint/no-redundant-type-constituents': 'off',
211+
'@typescript-eslint/no-base-to-string': 'off',
212+
'@typescript-eslint/no-empty-object-type': 'off',
213+
'@typescript-eslint/no-require-imports': 'off',
214+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
215+
'@typescript-eslint/only-throw-error': 'off',
216+
'@typescript-eslint/no-unsafe-function-type': 'off',
217+
},
218+
},
219+
{
220+
files: ['!packages/**', '**/*_spec.ts'],
221+
222+
rules: {
223+
'max-lines-per-function': 'off',
224+
'no-case-declarations': 'off',
225+
'no-console': 'off',
226+
},
227+
},
228+
];

0 commit comments

Comments
 (0)