|
1 | | -module.exports = { |
2 | | - plugins: [ |
3 | | - "@typescript-eslint", |
4 | | - "header", |
5 | | - "node", |
6 | | - "prettier" |
7 | | - ], |
8 | | - extends: ["eslint:recommended", "plugin:prettier/recommended"], |
9 | | - parser: "@typescript-eslint/parser", |
10 | | - parserOptions: { |
11 | | - "project": null |
| 1 | +const js = require('@eslint/js'); |
| 2 | +const tseslint = require('typescript-eslint'); |
| 3 | +const prettierConfig = require('eslint-config-prettier'); |
| 4 | +const eslintPluginPrettier = require('eslint-plugin-prettier'); |
| 5 | +const headerPlugin = require('eslint-plugin-header'); |
| 6 | + |
| 7 | +module.exports = [ |
| 8 | + { |
| 9 | + ignores: ['**/build/**', '**/coverage/**'], |
12 | 10 | }, |
13 | | - ignorePatterns: [ |
14 | | - "**/build/**", |
15 | | - "**/coverage/**" |
16 | | - ], |
17 | | - root: true, |
18 | | - rules: { |
19 | | - "quotes": ["error", "single", { "avoidEscape": true }], |
20 | | - "eqeqeq": [ |
21 | | - "error", |
22 | | - "smart" |
23 | | - ], |
24 | | - "prefer-rest-params": "off", |
25 | | - "no-shadow": "off", |
26 | | - "node/no-deprecated-api": ["warn"], |
27 | | - "header/header": ["error", "block", [{ |
28 | | - pattern: / \* Copyright The OpenTelemetry Authors(, .+)*[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm, |
29 | | - template: |
30 | | - `\n * Copyright The OpenTelemetry Authors\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 * 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 ` |
31 | | - }]] |
32 | | - }, |
33 | | - overrides: [ |
34 | | - { |
35 | | - files: ['*.ts'], |
36 | | - // Enable typescript-eslint for ts files. |
37 | | - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], |
| 11 | + js.configs.recommended, |
| 12 | + ...tseslint.configs.recommended, |
| 13 | + prettierConfig, |
| 14 | + { |
| 15 | + plugins: { |
| 16 | + header: headerPlugin, |
| 17 | + prettier: eslintPluginPrettier, |
| 18 | + }, |
| 19 | + languageOptions: { |
| 20 | + parser: tseslint.parser, |
38 | 21 | parserOptions: { |
39 | | - "project": "./tsconfig.json" |
| 22 | + project: null, |
40 | 23 | }, |
41 | | - rules: { |
42 | | - "@typescript-eslint/no-floating-promises": "error", |
43 | | - "@typescript-eslint/no-this-alias": "off", |
44 | | - "@typescript-eslint/naming-convention": [ |
45 | | - "error", |
| 24 | + }, |
| 25 | + rules: { |
| 26 | + quotes: ['error', 'single', { avoidEscape: true }], |
| 27 | + eqeqeq: ['error', 'smart'], |
| 28 | + 'prefer-rest-params': 'off', |
| 29 | + 'no-shadow': 'off', |
| 30 | + 'header/header': [ |
| 31 | + 'error', |
| 32 | + 'block', |
| 33 | + [ |
46 | 34 | { |
47 | | - "selector": "memberLike", |
48 | | - "modifiers": ["private", "protected"], |
49 | | - "format": ["camelCase"], |
50 | | - "leadingUnderscore": "require" |
51 | | - } |
| 35 | + pattern: |
| 36 | + / \* Copyright The OpenTelemetry Authors(, .+)*[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm, |
| 37 | + template: `\n * Copyright The OpenTelemetry Authors\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 * 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 `, |
| 38 | + }, |
52 | 39 | ], |
53 | | - "@typescript-eslint/no-var-requires": "off", |
54 | | - "@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }], |
55 | | - "@typescript-eslint/no-empty-function": ["off"], |
56 | | - "@typescript-eslint/ban-types": ["warn", { |
57 | | - "types": { |
58 | | - "Function": null, |
59 | | - } |
60 | | - }], |
61 | | - "@typescript-eslint/no-shadow": ["warn"], |
62 | | - "prefer-rest-params": "off", |
63 | | - } |
| 40 | + ], |
64 | 41 | }, |
65 | | - { |
66 | | - files: ["test/**/*.ts"], |
67 | | - // Enable typescript-eslint for ts files. |
68 | | - extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"], |
| 42 | + }, |
| 43 | + { |
| 44 | + files: ['**/*.ts'], |
| 45 | + ...tseslint.configs.recommended, |
| 46 | + languageOptions: { |
| 47 | + parser: tseslint.parser, |
69 | 48 | parserOptions: { |
70 | | - "project": "./tsconfig.json" |
| 49 | + project: './tsconfig.json', |
71 | 50 | }, |
72 | | - rules: { |
73 | | - "no-empty": "off", |
74 | | - "@typescript-eslint/ban-ts-ignore": "off", |
75 | | - "@typescript-eslint/ban-types": ["warn", { |
76 | | - "types": { |
77 | | - "Function": null, |
78 | | - } |
79 | | - }], |
80 | | - "@typescript-eslint/no-empty-function": "off", |
81 | | - "@typescript-eslint/no-explicit-any": "off", |
82 | | - "@typescript-eslint/no-unused-vars": "off", |
83 | | - "@typescript-eslint/no-var-requires": "off", |
84 | | - "@typescript-eslint/no-shadow": ["off"], |
85 | | - "@typescript-eslint/no-floating-promises": ["off"], |
86 | | - "@typescript-eslint/no-non-null-assertion": ["off"], |
87 | | - "@typescript-eslint/explicit-module-boundary-types": ["off"], |
88 | | - "prefer-rest-params": "off", |
89 | | - } |
90 | 51 | }, |
91 | | - { |
92 | | - files: ["*.mjs"], |
| 52 | + rules: { |
| 53 | + '@typescript-eslint/no-floating-promises': 'error', |
| 54 | + '@typescript-eslint/no-this-alias': 'off', |
| 55 | + '@typescript-eslint/naming-convention': [ |
| 56 | + 'error', |
| 57 | + { |
| 58 | + selector: 'memberLike', |
| 59 | + modifiers: ['private', 'protected'], |
| 60 | + format: ['camelCase'], |
| 61 | + leadingUnderscore: 'require', |
| 62 | + }, |
| 63 | + ], |
| 64 | + '@typescript-eslint/no-var-requires': 'off', |
| 65 | + '@typescript-eslint/no-inferrable-types': [ |
| 66 | + 'error', |
| 67 | + { ignoreProperties: true }, |
| 68 | + ], |
| 69 | + '@typescript-eslint/no-empty-function': ['off'], |
| 70 | + '@typescript-eslint/ban-types': [ |
| 71 | + 'warn', |
| 72 | + { |
| 73 | + types: { |
| 74 | + Function: null, |
| 75 | + }, |
| 76 | + }, |
| 77 | + ], |
| 78 | + '@typescript-eslint/no-shadow': ['warn'], |
| 79 | + '@typescript-eslint/ban-ts-comment': [ |
| 80 | + 'error', |
| 81 | + { |
| 82 | + 'ts-ignore': true, |
| 83 | + 'ts-nocheck': true, |
| 84 | + 'ts-check': false, |
| 85 | + }, |
| 86 | + ], |
| 87 | + 'prefer-rest-params': 'off', |
| 88 | + }, |
| 89 | + }, |
| 90 | + { |
| 91 | + files: ['**/test/**/*.ts'], |
| 92 | + ...tseslint.configs.recommended, |
| 93 | + languageOptions: { |
| 94 | + parser: tseslint.parser, |
93 | 95 | parserOptions: { |
94 | | - sourceType: 'module', |
95 | | - } |
96 | | - } |
97 | | - ] |
98 | | -}; |
| 96 | + project: './tsconfig.json', |
| 97 | + }, |
| 98 | + }, |
| 99 | + rules: { |
| 100 | + 'no-empty': 'off', |
| 101 | + '@typescript-eslint/ban-ts-ignore': 'off', |
| 102 | + '@typescript-eslint/ban-types': [ |
| 103 | + 'warn', |
| 104 | + { |
| 105 | + types: { |
| 106 | + Function: null, |
| 107 | + }, |
| 108 | + }, |
| 109 | + ], |
| 110 | + '@typescript-eslint/no-empty-function': 'off', |
| 111 | + '@typescript-eslint/no-explicit-any': 'off', |
| 112 | + '@typescript-eslint/no-unused-vars': 'off', |
| 113 | + '@typescript-eslint/no-var-requires': 'off', |
| 114 | + '@typescript-eslint/no-shadow': ['off'], |
| 115 | + '@typescript-eslint/no-floating-promises': ['off'], |
| 116 | + '@typescript-eslint/no-non-null-assertion': ['off'], |
| 117 | + '@typescript-eslint/explicit-module-boundary-types': ['off'], |
| 118 | + 'prefer-rest-params': 'off', |
| 119 | + }, |
| 120 | + }, |
| 121 | + { |
| 122 | + files: ['**/*.mjs'], |
| 123 | + languageOptions: { |
| 124 | + sourceType: 'module', |
| 125 | + }, |
| 126 | + }, |
| 127 | +]; |
0 commit comments