forked from xtermjs/xterm.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.mjs
More file actions
152 lines (149 loc) · 7.07 KB
/
eslint.config.mjs
File metadata and controls
152 lines (149 loc) · 7.07 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// @ts-check
import eslint from '@eslint/js';
import stylistic from '@stylistic/eslint-plugin';
import jsdoc from 'eslint-plugin-jsdoc';
import tseslint from 'typescript-eslint';
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
ignores: [
'addons/*/src/third-party/*.ts',
'**/out/*',
'**/out-test/*',
'**/out-esbuild/*',
'**/out-esbuild-test/*',
'**/inwasm-sdks/*',
'**/typings/*.d.ts',
'**/node_modules',
'**/*.js',
'**/*.mjs'
]
},
{
files: ['**/*.ts'],
plugins: {
'@stylistic': stylistic,
jsdoc
},
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname
}
},
rules: {
'@stylistic/comma-spacing': ['warn', { before: false, after: true }],
'@stylistic/indent': ['warn', 2],
'@stylistic/semi': ['warn', 'always'],
'@stylistic/quotes': ['warn', 'single', { allowTemplateLiterals: true }],
'@stylistic/member-delimiter-style': ['warn', {
multiline: { delimiter: 'semi', requireLast: true },
singleline: { delimiter: 'comma', requireLast: false }
}],
'@stylistic/type-annotation-spacing': 'warn',
'@typescript-eslint/array-type': ['warn', { default: 'array', readonly: 'generic' }],
'@typescript-eslint/consistent-type-assertions': 'warn',
'@typescript-eslint/consistent-type-definitions': 'warn',
'@typescript-eslint/explicit-function-return-type': ['warn', { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': ['warn', { accessibility: 'explicit', overrides: { constructors: 'off' } }],
'@typescript-eslint/naming-convention': [
'warn',
{ selector: 'default', format: ['camelCase'], filter: { regex: '^[a-z]', match: true } },
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE'] },
{ selector: 'variable', filter: '^I.+Service$', format: ['PascalCase'], prefix: ['I'] },
{ selector: 'memberLike', modifiers: ['private'], format: ['camelCase'], leadingUnderscore: 'require' },
{ selector: 'memberLike', modifiers: ['protected'], format: ['camelCase'], leadingUnderscore: 'require' },
{ selector: 'enumMember', format: ['UPPER_CASE'] },
{ selector: 'property', modifiers: ['public'], format: ['camelCase', 'UPPER_CASE'], filter: { regex: '^[a-z]', match: true } },
{ selector: 'method', modifiers: ['public'], format: ['camelCase', 'UPPER_CASE'], custom: { regex: '^on[A-Z].+', match: false } },
{ selector: 'method', modifiers: ['private'], format: ['camelCase'], leadingUnderscore: 'require', custom: { regex: '^on[A-Z].+', match: false } },
{ selector: 'method', modifiers: ['protected'], format: ['camelCase'], leadingUnderscore: 'require', custom: { regex: '^on[A-Z].+', match: false } },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'interface', format: ['PascalCase'], prefix: ['I'] }
],
'@typescript-eslint/no-confusing-void-expression': ['warn', { ignoreArrowShorthand: true }],
'@typescript-eslint/no-useless-constructor': 'warn',
'@typescript-eslint/prefer-nullish-coalescing': ['warn', { ignorePrimitives: true }],
'@typescript-eslint/prefer-namespace-keyword': 'warn',
'@typescript-eslint/no-unused-vars': ['warn', { vars: 'all', args: 'none' }],
'@typescript-eslint/no-require-imports': 'off',
// Added in eslint upgrade, new defaults
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-namespace': 'off',
// Allow duplicates for bit field constants
'@typescript-eslint/no-duplicate-enum-values': 'off',
'curly': ['warn', 'multi-line'],
'eqeqeq': ['warn', 'always'],
'jsdoc/check-alignment': 'warn',
'jsdoc/check-param-names': 'warn',
'jsdoc/no-multi-asterisks': 'warn',
'keyword-spacing': 'warn',
'max-len': ['warn', {
code: 1000,
comments: 100,
ignoreTrailingComments: true,
ignoreUrls: true,
ignorePattern: '^ *((?<vt_comment>(//|\\*) @vt)|(?<table_comment>\\* \\| )|(?<commented_code>// ))'
}],
'new-parens': 'warn',
'no-duplicate-imports': 'warn',
'no-else-return': ['warn', { allowElseIf: false }],
'no-eval': 'warn',
'no-extra-semi': 'error',
'no-irregular-whitespace': 'warn',
'no-restricted-imports': ['warn', { patterns: ['.*\\/out\\/.*'] }],
'no-restricted-syntax': [
'warn',
{ selector: "CallExpression[callee.name='requestAnimationFrame']", message: 'The global requestAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService.' },
{ selector: "CallExpression[callee.name='cancelAnimationFrame']", message: 'The global cancelAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService.' },
{ selector: "CallExpression > MemberExpression[object.name='window'][property.name='requestAnimationFrame']", message: 'window.requestAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService.' },
{ selector: "CallExpression > MemberExpression[object.name='window'][property.name='cancelAnimationFrame']", message: 'window.cancelAnimationFrame() should be avoided, call it on the parent window from ICoreBrowserService.' },
{ selector: "MemberExpression[object.name='window'][property.name='devicePixelRatio']", message: 'window.devicePixelRatio should be avoided, get it from ICoreBrowserService.' }
],
'no-trailing-spaces': 'warn',
'no-unsafe-finally': 'warn',
'no-unused-vars': 'off',
'no-var': 'warn',
'one-var': ['warn', 'never'],
'no-empty': 'off',
'no-empty-pattern': 'off',
'no-cond-assign': 'off',
'no-case-declarations': 'off',
'for-direction': 'off',
'no-prototype-builtins': 'off',
'no-useless-escape': 'off',
'no-self-assign': 'off',
'no-async-promise-executor': 'off',
'prefer-rest-params': 'off',
'no-control-regex': 'off',
'no-fallthrough': 'off',
'prefer-spread': 'off',
'object-curly-spacing': ['warn', 'always'],
'prefer-const': 'warn',
'spaced-comment': ['warn', 'always', { markers: ['/'], exceptions: ['-'] }]
}
},
{
files: ['**/*.api.ts', '**/*.test.ts'],
rules: {
'object-curly-spacing': 'off',
'max-len': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off'
}
},
{
// Disable prefer-nullish-coalescing for files without strictNullChecks
files: ['demo/**/*.ts', '**/*.benchmark.ts'],
rules: {
'@typescript-eslint/prefer-nullish-coalescing': 'off'
}
}
);