-
-
Notifications
You must be signed in to change notification settings - Fork 293
Expand file tree
/
Copy patheslint.config.mjs
More file actions
118 lines (110 loc) · 4.08 KB
/
Copy patheslint.config.mjs
File metadata and controls
118 lines (110 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-plugin-prettier/recommended';
import importPlugin from 'eslint-plugin-import-x';
import globals from 'globals';
import { fileURLToPath } from 'node:url';
export default tseslint.config(
// Global ignores (replaces .eslintignore)
{
ignores: [
'**/__fixtures__/**',
'packages/*/dist/**',
'packages/rulesets/src/oas/schemas/validators.ts',
'packages/rulesets/src/arazzo/schemas/validators.ts',
'packages/*/CHANGELOG.md',
'packages/formatters/src/html/templates.ts',
],
},
// Base for all linted files
{
files: ['packages/**/*.{js,mjs,ts}', 'test-harness/**/*.{js,mjs,ts}'],
extends: [tseslint.configs.recommended, prettierConfig],
languageOptions: {
globals: { ...globals.es2015, ...globals.browser, ...globals.node },
},
rules: {
'no-console': 'error',
'no-control-regex': 'error',
'no-shadow-restricted-names': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
args: 'after-used',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/explicit-function-return-type': 'warn',
},
},
// TypeScript source files with type-checking
{
files: ['packages/*/src/**/*.ts'],
extends: [tseslint.configs.eslintRecommended, tseslint.configs.recommendedTypeChecked],
plugins: { import: importPlugin },
languageOptions: {
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: fileURLToPath(new URL('.', import.meta.url)),
},
},
rules: {
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-regexp-exec': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'@typescript-eslint/strict-boolean-expressions': 'warn',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-empty-function': 'error',
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: ['**/*.{test,spec}.ts', '**/__tests__/__helpers__/*.ts'] },
],
},
},
// CLI package: downgrade no-console to warn
{
files: ['packages/cli/src/**/*.ts'],
rules: { 'no-console': 'warn' },
},
// Test files: relax strict rules
{
files: ['packages/*/src/**/__tests__/**/*.ts', 'test-harness/**/*.{ts,js}'],
rules: {
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
},
},
// Jest test files: jest + node globals
{
files: ['**/__tests__/**/*.jest.test.{ts,js}', '__mocks__/**/*.{ts,js}'],
languageOptions: { globals: { ...globals.jest, ...globals.node } },
},
// Karma test files: browser + jasmine globals
{
files: ['**/__tests__/**/*.karma.test.{ts,js}'],
languageOptions: { globals: { ...globals.browser, ...globals.jasmine } },
},
// Scripts and test-harness: node globals
{
files: ['scripts/**/*.{mjs,ts}', 'test-harness/**/*.{ts,js}'],
languageOptions: { globals: { ...globals.node } },
},
);