-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
eslint.config.mjs
69 lines (68 loc) · 3.99 KB
/
eslint.config.mjs
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
import js from '@eslint/js'
import globals from 'globals'
import importPlugin from 'eslint-plugin-import'
import json from '@eslint/json'
import markdown from '@eslint/markdown'
import regexp from 'eslint-plugin-regexp'
import stylisticJS from '@stylistic/eslint-plugin-js'
import yml from 'eslint-plugin-yml'
export default [
{
files: ['**/*.js', '**/*.mjs'],
ignores: ['.history/*'],
languageOptions: {
ecmaVersion: 'latest', sourceType: 'script',
globals: {
...globals.browser, ...globals.greasemonkey, ...globals.node, chatgpt: 'readonly', chrome: 'readonly',
config: 'writable', CryptoJS: 'readonly', dom: 'readonly', GM_cookie: 'readonly', hljs: 'readonly',
icons: 'writable', ipv4: 'readonly', marked: 'readonly', modals: 'writable',
renderMathInElement: 'readonly', settings: 'writable', toggles: 'writable'
}
},
plugins: { 'import': importPlugin, 'js-styles': stylisticJS, regexp },
rules: {
...js.configs.recommended.rules,
...importPlugin.flatConfigs.recommended.rules,
...regexp.configs['flat/recommended'].rules,
'indent': 'off', 'no-unexpected-multiline': 'off', 'key-spacing': 'off', // allow whitespace anywhere
'js-styles/no-trailing-spaces': 'off', // ...except at ends of lines
'js-styles/max-len': ['error', {
'code': 180, // limit lines to 120 chars except if containing...
'ignoreComments': true, 'ignoreStrings': true, // ...trailing/own-line comments, quoted strings...
'ignoreTemplateLiterals': true, 'ignoreRegExpLiterals': true
}], // ...or template/regex literals
'regexp/no-unused-capturing-group': 'off',
'regexp/no-empty-group': 'off',
'regexp/no-super-linear-backtracking': 'off',
'regexp/no-empty-capturing-group': 'off',
'regexp/no-useless-flag': 'off',
'js-styles/no-extra-semi': 'error', // disallow unnecessary semicolons
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }], // enforce single quotes except backticks to avoid escaping quotes
'comma-dangle': ['error', 'never'], // enforce no trailing commas in arrays or objects
'no-async-promise-executor': 'off', // allow promise executor functions to be async (to accomodate await lines)
'no-constant-condition': 'off', // allow constant conditions
'no-empty': 'off', // allow empty blocks
'no-inner-declarations': 'off', // allow function declarations anywhere
'no-useless-escape': 'off', // allow all escape chars cause ESLint sucks at detecting truly useless ones
// 'no-unused-vars': ['error', { 'caughtErrors': 'none' }], // allow unused named args in catch blocks
'no-unused-vars': 'off', // 禁用未使用变量的检查
'no-undef': 'off', //禁用未定义变量的检查
'no-irregular-whitespace': 'error',// 启用不规则空白字符规则
'no-misleading-character-class': 'off',
'no-redeclare': 'off'
}
},
{ files: ['**/*.mjs'], languageOptions: { sourceType: 'module' } },
{ files: ['**/*.json'], ignores: ['**/package-lock.json', '.history/*'], language: 'json/json', ...json.configs.recommended },
{
files: ['**/*.md'], ignores: ['.history/*'], language: 'markdown/commonmark', plugins: { markdown },
rules: {
...markdown.configs.recommended[0].rules,
'markdown/heading-increment': 'off', // allow headings to skip levels
'markdown/fenced-code-language': 'off', // allow code blocks w/ no language specified
'markdown/no-missing-label-refs': 'off', // allow missing label references
'markdown/no-empty-links': 'off' // allow empty links
}
},
{ files: ['**/*.yaml, **/*.yml'], ignores: ['.history/*'], ...yml.configs['flat/standard'][1] }
]