Skip to content

Commit c352766

Browse files
overbalancetrentm
andauthored
chore(eslint): upgrade to eslint 9 (#3001)
Co-authored-by: Trent Mick <[email protected]>
1 parent 2e639c2 commit c352766

File tree

322 files changed

+4037
-5183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

322 files changed

+4037
-5183
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,5 @@ docs
8383
# version.ts file is automatically generated at compile time
8484
version.ts
8585
/.vs
86+
.cursor/rules/nx-rules.mdc
87+
.github/instructions/nx.instructions.md

.nycrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"src/platform/browser/*.ts",
1616
"test/*.ts",
1717
"webpack/*.js",
18-
".eslintrc.js"
18+
"eslint.config.mjs"
1919
],
2020
"all": true
2121
}

.prettierignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.md
2+
*.json
3+
*.jsonc
4+
*.json5
5+
*.yml
6+
*.yaml
7+
!package.json
8+
9+
/.nx

eslint.config.js

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

eslint.config.mjs

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import eslint from '@eslint/js';
18+
import tseslint from 'typescript-eslint';
19+
import globals from 'globals';
20+
import nodePlugin from 'eslint-plugin-n';
21+
import yalhPlugin from 'eslint-plugin-yet-another-license-header';
22+
23+
const defaultLicense = `
24+
/*
25+
* Copyright The OpenTelemetry Authors
26+
*
27+
* Licensed under the Apache License, Version 2.0 (the "License");
28+
* you may not use this file except in compliance with the License.
29+
* You may obtain a copy of the License at
30+
*
31+
* https://www.apache.org/licenses/LICENSE-2.0
32+
*
33+
* Unless required by applicable law or agreed to in writing, software
34+
* distributed under the License is distributed on an "AS IS" BASIS,
35+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
36+
* See the License for the specific language governing permissions and
37+
* limitations under the License.
38+
*/
39+
`;
40+
41+
// This matches `defaultLicense`, but allows additional Copyright holders
42+
// either on the same line:
43+
// Copyright The OpenTelemetry Authors, <someone>, <another someone>
44+
// and/or on subsequent lines:
45+
// Copyright The OpenTelemetry Authors
46+
// Copyright <someone>
47+
// Copyright <another someone>
48+
const licensePattern =
49+
/^\/\*\n \* Copyright The OpenTelemetry Authors(?:, [^\n]+)*\n(?: \* Copyright [^\n]+\n)* \*\n \* Licensed under the Apache License, Version 2.0 \(the "License"\);\n \* you may not use this file except in compliance with the License.\n \* You may obtain a copy of the License at\n \*\n \* {6}https:\/\/www.apache.org\/licenses\/LICENSE-2.0\n \*\n \* Unless required by applicable law or agreed to in writing, software\n \* distributed under the License is distributed on an "AS IS" BASIS,\n \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n \* See the License for the specific language governing permissions and\n \* limitations under the License.\n \*\/$/;
50+
51+
const baseConfig = tseslint.config(
52+
{
53+
ignores: [
54+
'**/.nx/**',
55+
'**/build/**',
56+
'**/coverage/**',
57+
'**/dist/**',
58+
'**/node_modules/**',
59+
],
60+
},
61+
{
62+
files: ['**/*.{js,ts,mjs}'],
63+
plugins: {
64+
'yet-another-license-header': yalhPlugin,
65+
node: nodePlugin,
66+
},
67+
extends: [
68+
eslint.configs.recommended,
69+
// nodePlugin.configs['flat/recommended'],
70+
],
71+
languageOptions: {
72+
ecmaVersion: 2022,
73+
globals: {
74+
...globals.node,
75+
},
76+
},
77+
settings: {
78+
node: {
79+
tryExtensions: ['.js', '.json', '.node', '.ts', '.tsx'],
80+
},
81+
},
82+
rules: {
83+
// old rules
84+
quotes: ['error', 'single', { avoidEscape: true }],
85+
eqeqeq: ['error', 'smart'],
86+
'prefer-rest-params': 'off',
87+
'yet-another-license-header/header': [
88+
'error',
89+
{
90+
header: defaultLicense,
91+
allowedHeaderPatterns: [licensePattern],
92+
},
93+
],
94+
95+
// new rules
96+
'no-unused-vars': 'warn',
97+
'node/no-deprecated-api': 'warn',
98+
},
99+
},
100+
101+
// TypeScript strict rules
102+
{
103+
files: ['**/*.ts'],
104+
plugins: {
105+
'@typescript-eslint': tseslint.plugin,
106+
},
107+
// turn on when we can check types
108+
// extends: [...tseslint.configs.recommendedTypeChecked],
109+
extends: [...tseslint.configs.recommended],
110+
languageOptions: {
111+
parser: tseslint.parser,
112+
parserOptions: {
113+
project: true,
114+
},
115+
},
116+
rules: {
117+
// 'node/no-missing-import': 'off',
118+
119+
// things that should be repaired
120+
'@typescript-eslint/no-explicit-any': 'warn',
121+
'@typescript-eslint/no-require-imports': 'warn',
122+
'@typescript-eslint/no-unsafe-function-type': 'warn',
123+
'@typescript-eslint/no-empty-object-type': 'warn',
124+
'@typescript-eslint/no-unused-vars': [
125+
'warn',
126+
{ argsIgnorePattern: '^_' },
127+
],
128+
129+
// old rules
130+
// this is a replacement for the deprecated ban-types rules
131+
'@typescript-eslint/no-restricted-types': [
132+
'warn',
133+
{
134+
types: {
135+
Function: 'fix',
136+
},
137+
},
138+
],
139+
// TODO: fix inheritance
140+
'@typescript-eslint/no-floating-promises': 'error',
141+
'@typescript-eslint/no-this-alias': 'off',
142+
'@typescript-eslint/naming-convention': [
143+
'error',
144+
{
145+
selector: 'memberLike',
146+
modifiers: ['private', 'protected'],
147+
format: ['camelCase'],
148+
leadingUnderscore: 'require',
149+
},
150+
],
151+
'@typescript-eslint/no-var-requires': 'off',
152+
'@typescript-eslint/no-inferrable-types': [
153+
'error',
154+
{ ignoreProperties: true },
155+
],
156+
'@typescript-eslint/no-empty-function': ['off'],
157+
'@typescript-eslint/no-shadow': ['warn'],
158+
'prefer-rest-params': 'off',
159+
},
160+
},
161+
162+
// Test files have relaxed rules
163+
{
164+
files: ['**/test/**/*.ts', '**/*.test.ts'],
165+
rules: {
166+
'@typescript-eslint/no-explicit-any': 'off',
167+
'@typescript-eslint/no-unsafe-assignment': 'off',
168+
'@typescript-eslint/no-unsafe-member-access': 'off',
169+
'@typescript-eslint/no-unsafe-call': 'off',
170+
'@typescript-eslint/no-unsafe-return': 'off',
171+
'@typescript-eslint/restrict-template-expressions': 'off',
172+
'@typescript-eslint/unbound-method': 'off',
173+
'@typescript-eslint/no-non-null-assertion': 'off',
174+
'@typescript-eslint/no-unnecessary-condition': 'off',
175+
'@typescript-eslint/no-unsafe-argument': 'off',
176+
'@typescript-eslint/ban-ts-comment': 'off',
177+
'@typescript-eslint/no-shadow': 'off',
178+
'@typescript-eslint/require-await': 'off',
179+
'@typescript-eslint/no-floating-promises': 'off',
180+
'@typescript-eslint/no-misused-promises': 'off',
181+
'@typescript-eslint/no-base-to-string': 'off',
182+
'@typescript-eslint/prefer-promise-reject-errors': 'off',
183+
'@typescript-eslint/no-unused-vars': [
184+
'warn',
185+
{ argsIgnorePattern: '^_' },
186+
],
187+
'no-empty': 'off',
188+
},
189+
},
190+
191+
// ESM files
192+
{
193+
files: ['**/*.mjs'],
194+
languageOptions: {
195+
sourceType: 'module',
196+
},
197+
},
198+
199+
// Browser environment
200+
{
201+
files: [
202+
'**/examples/web/**/*',
203+
'**/packages/**/browser/**/*',
204+
'**/packages/instrumentation-user-interaction/**/*',
205+
'**/packages/instrumentation-document-load/**/*',
206+
'**/packages/instrumentation-long-task/**/*',
207+
'**/packages/plugin-react-load/**/*',
208+
],
209+
languageOptions: {
210+
globals: {
211+
...globals.browser,
212+
Zone: 'readonly',
213+
Task: 'readonly',
214+
},
215+
},
216+
}
217+
);
218+
219+
export default baseConfig;

examples/bunyan/.eslintrc.js

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

examples/bunyan/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"version": "0.1.0",
55
"description": "Example of Bunyan integration with OpenTelemetry",
66
"scripts": {
7-
"lint": "eslint . --ext=ts,js,mjs",
8-
"lint:fix": "eslint . --ext=ts,js,mjs --fix",
97
"start": "node -r ./telemetry.js app.js"
108
},
119
"repository": {

0 commit comments

Comments
 (0)