Skip to content

Commit b991d6b

Browse files
committed
new config file, fix types, add webpack
more old rules, disable new node rules
1 parent 7bf8549 commit b991d6b

File tree

93 files changed

+447
-2302
lines changed

Some content is hidden

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

93 files changed

+447
-2302
lines changed

eslint.config.js

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

eslint.config.mjs

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

examples/bunyan/.eslintrc.js

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

examples/connect/.eslintrc.js

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

examples/dns/.eslintrc.js

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

0 commit comments

Comments
 (0)