Skip to content

Commit fc7c93b

Browse files
committed
update to eslint.config.mjs
1 parent 5f31ebb commit fc7c93b

File tree

11 files changed

+6165
-15758
lines changed

11 files changed

+6165
-15758
lines changed

.eslintrc

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

build/webpack/webpack.extension.browser.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const packageRoot = path.resolve(__dirname, '..', '..');
1313
const outDir = path.resolve(packageRoot, 'dist');
1414

1515
/** @type {(env: any, argv: { mode: 'production' | 'development' | 'none' }) => import('webpack').Configuration} */
16-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
16+
// eslint-disable-next-line no-unused-vars
1717
const nodeConfig = (_, { mode }) => ({
1818
context: packageRoot,
1919
entry: {

eslint.config.mjs

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
/**
2+
* ESLint Configuration for VS Code Python Extension
3+
* This file configures linting rules for the TypeScript/JavaScript codebase.
4+
* It uses the new flat config format introduced in ESLint 8.21.0
5+
*/
6+
7+
// Import essential ESLint plugins and configurations
8+
import tseslint from '@typescript-eslint/eslint-plugin';
9+
import tsParser from '@typescript-eslint/parser';
10+
import noOnlyTests from 'eslint-plugin-no-only-tests';
11+
import prettier from 'eslint-config-prettier';
12+
import importPlugin from 'eslint-plugin-import';
13+
import js from '@eslint/js';
14+
15+
export default [
16+
{
17+
ignores: ['**/node_modules/**', '**/out/**'],
18+
},
19+
// Base configuration for all files
20+
{
21+
ignores: ['**/node_modules/**', '**/out/**'],
22+
linterOptions: {
23+
reportUnusedDisableDirectives: 'off',
24+
},
25+
rules: {
26+
...js.configs.recommended.rules,
27+
'no-undef': 'off',
28+
},
29+
},
30+
// TypeScript-specific configuration
31+
{
32+
files: ['**/*.ts', '**/*.tsx'],
33+
languageOptions: {
34+
parser: tsParser,
35+
parserOptions: {
36+
ecmaVersion: 'latest',
37+
sourceType: 'module',
38+
},
39+
globals: {
40+
...(js.configs.recommended.languageOptions?.globals || {}),
41+
mocha: true,
42+
require: 'readonly',
43+
process: 'readonly',
44+
exports: 'readonly',
45+
module: 'readonly',
46+
__dirname: 'readonly',
47+
__filename: 'readonly',
48+
setTimeout: 'readonly',
49+
setInterval: 'readonly',
50+
clearTimeout: 'readonly',
51+
clearInterval: 'readonly',
52+
},
53+
},
54+
plugins: {
55+
'@typescript-eslint': tseslint,
56+
'no-only-tests': noOnlyTests,
57+
import: importPlugin,
58+
prettier: prettier,
59+
},
60+
settings: {
61+
'import/resolver': {
62+
node: {
63+
extensions: ['.js', '.ts'],
64+
},
65+
},
66+
},
67+
rules: {
68+
// Base configurations
69+
...tseslint.configs.recommended.rules,
70+
...prettier.rules,
71+
72+
// TypeScript-specific rules
73+
'@typescript-eslint/ban-ts-comment': [
74+
'error',
75+
{
76+
'ts-ignore': 'allow-with-description',
77+
},
78+
],
79+
'@typescript-eslint/ban-types': 'off',
80+
'@typescript-eslint/explicit-module-boundary-types': 'off',
81+
'@typescript-eslint/no-empty-interface': 'off',
82+
'@typescript-eslint/no-explicit-any': 'off',
83+
'@typescript-eslint/no-namespace': 'off',
84+
'@typescript-eslint/no-non-null-assertion': 'off',
85+
'@typescript-eslint/no-loss-of-precision': 'off',
86+
'@typescript-eslint/no-unused-vars': [
87+
'warn',
88+
{
89+
varsIgnorePattern: '^_',
90+
argsIgnorePattern: '^_',
91+
},
92+
],
93+
'@typescript-eslint/no-var-requires': 'off',
94+
'@typescript-eslint/no-use-before-define': [
95+
'error',
96+
{
97+
functions: false,
98+
},
99+
],
100+
101+
// Import rules
102+
'import/extensions': 'off',
103+
'import/namespace': 'off',
104+
'import/no-extraneous-dependencies': 'off',
105+
'import/no-unresolved': 'off',
106+
'import/prefer-default-export': 'off',
107+
108+
// Testing rules
109+
'no-only-tests/no-only-tests': [
110+
'error',
111+
{
112+
block: ['test', 'suite'],
113+
focus: ['only'],
114+
},
115+
],
116+
117+
// Code style rules
118+
'linebreak-style': 'off',
119+
'no-bitwise': 'off',
120+
'no-console': 'off',
121+
'no-underscore-dangle': 'off',
122+
'operator-assignment': 'off',
123+
'func-names': 'off',
124+
125+
// Error handling and control flow
126+
'no-empty': ['error', { allowEmptyCatch: true }],
127+
'no-async-promise-executor': 'off',
128+
'no-await-in-loop': 'off',
129+
'no-unreachable': 'off',
130+
'no-void': 'off',
131+
132+
// Duplicates and overrides (TypeScript handles these)
133+
'no-dupe-class-members': 'off',
134+
'no-redeclare': 'off',
135+
'no-undef': 'off',
136+
137+
// Miscellaneous rules
138+
'no-control-regex': 'off',
139+
'no-extend-native': 'off',
140+
'no-inner-declarations': 'off',
141+
'no-multi-str': 'off',
142+
'no-param-reassign': 'off',
143+
'no-prototype-builtins': 'off',
144+
'no-empty-function': 'off',
145+
'no-template-curly-in-string': 'off',
146+
'no-useless-escape': 'off',
147+
'no-extra-parentheses': 'off',
148+
strict: 'off',
149+
150+
// Restricted syntax
151+
'no-restricted-syntax': [
152+
'error',
153+
{
154+
selector: 'ForInStatement',
155+
message:
156+
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
157+
},
158+
{
159+
selector: 'LabeledStatement',
160+
message:
161+
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
162+
},
163+
{
164+
selector: 'WithStatement',
165+
message:
166+
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
167+
},
168+
],
169+
},
170+
},
171+
];

0 commit comments

Comments
 (0)