Skip to content

Commit 6c95d76

Browse files
committed
Removes duplication
1 parent 4bf8b5a commit 6c95d76

File tree

1 file changed

+18
-60
lines changed

1 file changed

+18
-60
lines changed

eslint.config.mjs

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ import { configs as litConfigs } from 'eslint-plugin-lit';
99
import { configs as wcConfigs } from 'eslint-plugin-wc';
1010
import noSrcImports from './scripts/eslint-rules/no-src-imports.js';
1111

12+
/** @type {Awaited<import('typescript-eslint').Config>[number]['languageOptions']} */
13+
const defaultLanguageOptions = {
14+
parser: ts.parser,
15+
parserOptions: {
16+
ecmaVersion: 2023,
17+
sourceType: 'module',
18+
ecmaFeatures: { impliedStrict: true },
19+
projectService: true,
20+
},
21+
};
22+
1223
export default ts.config(
1324
js.configs.recommended,
1425
...ts.configs.strictTypeChecked,
@@ -18,9 +29,7 @@ export default ts.config(
1829
ignores: ['*', '*/', '!src/', '!tests/', 'src/@types/'],
1930
},
2031
{
21-
linterOptions: {
22-
reportUnusedDisableDirectives: true,
23-
},
32+
linterOptions: { reportUnusedDisableDirectives: true },
2433
plugins: {
2534
'import-x': importX,
2635
'anti-trojan-source': antiTrojanSource,
@@ -325,16 +334,7 @@ export default ts.config(
325334
name: 'extension:node',
326335
files: ['src/**/*'],
327336
ignores: ['src/**/webview/**/*', 'src/webviews/apps/**/*', 'src/env/browser/**/*'],
328-
languageOptions: {
329-
globals: { ...globals.node },
330-
parser: ts.parser,
331-
parserOptions: {
332-
ecmaVersion: 2023,
333-
sourceType: 'module',
334-
ecmaFeatures: { impliedStrict: true },
335-
projectService: true,
336-
},
337-
},
337+
languageOptions: { ...defaultLanguageOptions, globals: { ...globals.node } },
338338
},
339339
{
340340
files: ['src/env/node/**/*'],
@@ -362,16 +362,7 @@ export default ts.config(
362362
name: 'extension:browser',
363363
files: ['src/**/*'],
364364
ignores: ['src/**/webview/**/*', 'src/webviews/apps/**/*', 'src/env/node/**/*'],
365-
languageOptions: {
366-
globals: { ...globals.worker },
367-
parser: ts.parser,
368-
parserOptions: {
369-
ecmaVersion: 2023,
370-
sourceType: 'module',
371-
ecmaFeatures: { impliedStrict: true },
372-
projectService: true,
373-
},
374-
},
365+
languageOptions: { ...defaultLanguageOptions, globals: { ...globals.worker } },
375366
},
376367
{
377368
name: 'webviews',
@@ -391,16 +382,7 @@ export default ts.config(
391382
'**/webview/**/*',
392383
],
393384
ignores: ['**/-webview/**/*'],
394-
languageOptions: {
395-
globals: { ...globals.browser },
396-
parser: ts.parser,
397-
parserOptions: {
398-
ecmaVersion: 2023,
399-
sourceType: 'module',
400-
ecmaFeatures: { impliedStrict: true },
401-
projectService: true,
402-
},
403-
},
385+
languageOptions: { ...defaultLanguageOptions, globals: { ...globals.browser } },
404386
rules: {
405387
'@typescript-eslint/no-restricted-imports': [
406388
'error',
@@ -444,16 +426,7 @@ export default ts.config(
444426
...wcConfigs['flat/best-practice'],
445427
files: ['src/webviews/apps/**/*'],
446428
ignores: ['**/-webview/**/*'],
447-
languageOptions: {
448-
globals: { ...globals.browser },
449-
parser: ts.parser,
450-
parserOptions: {
451-
ecmaVersion: 2023,
452-
sourceType: 'module',
453-
ecmaFeatures: { impliedStrict: true },
454-
projectService: true,
455-
},
456-
},
429+
languageOptions: { ...defaultLanguageOptions, globals: { ...globals.browser } },
457430
rules: {
458431
// 'lit/quoted-expressions': 'error',
459432
'lit/lifecycle-super': 'error',
@@ -466,13 +439,7 @@ export default ts.config(
466439
'@typescript-eslint/no-restricted-imports': [
467440
'error',
468441
{
469-
paths: [
470-
{
471-
name: 'vscode',
472-
message: "Can't use `vscode` in webviews",
473-
allowTypeImports: true,
474-
},
475-
],
442+
paths: [{ name: 'vscode', message: "Can't use `vscode` in webviews", allowTypeImports: true }],
476443
patterns: [
477444
{
478445
group: ['container'],
@@ -501,16 +468,7 @@ export default ts.config(
501468
{
502469
name: 'tests:e2e',
503470
files: ['tests/**/*'],
504-
languageOptions: {
505-
globals: { ...globals.node },
506-
parser: ts.parser,
507-
parserOptions: {
508-
ecmaVersion: 2023,
509-
sourceType: 'module',
510-
ecmaFeatures: { impliedStrict: true },
511-
projectService: true,
512-
},
513-
},
471+
languageOptions: { ...defaultLanguageOptions, globals: { ...globals.node } },
514472
rules: {
515473
'@typescript-eslint/no-restricted-imports': 'off',
516474
},

0 commit comments

Comments
 (0)