-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
131 lines (120 loc) · 3.55 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
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
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
import parser from 'vue-eslint-parser';
import commonStyle from './src/fun-coding-style/common.mjs';
import typescriptStyle from './src/fun-coding-style/typescript.mjs';
import vueRules from './src/fun-coding-style/vue.mjs';
import vueFormattingRules from './src/fun-coding-style/vue_formatting.mjs';
export default [
commonStyle,
{
files: [ '**/*.vue', '**/*.ts' ],
plugins: {
...typescriptStyle.plugins,
},
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
parser: parser,
ecmaVersion: 7,
sourceType: 'module',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaFeatures: {
modules: true,
},
},
},
rules: {
...typescriptStyle.rules,
// The following rules should be turned on again in the future (using the settings from typescriptStyle)
// We placed them here to avoid huge changes in our legacy codebase and to allow for slow migration
// See https://phabricator.wikimedia.org/T383409
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
// NEEDS_TEAM_DECISION
'@stylistic/comma-dangle': 'off',
'@stylistic/space-infix-ops': 'off',
'@stylistic/member-delimiter-style': 'off',
// We do have some classes that use an underscore for private methods/properties
'no-underscore-dangle': 'off',
// Custom rules to prevent shipping debug code to prod
'no-console': 'error',
'no-debugger': 'error',
},
},
// more lenient rules for test files
{
files: [ 'test/**/*.ts', 'test/**/*.vue', 'test/**/*.mjs' ],
languageOptions: {
globals: {
...globals.node,
...globals.browser,
},
parser: parser,
ecmaVersion: 7,
sourceType: 'module',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaFeatures: {
modules: true,
},
},
},
rules: {
'no-console': 'off',
'no-debugger': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
},
{
files: [ '**/*.vue' ],
plugins: {
vue: pluginVue,
},
languageOptions: {
parser: parser,
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
sourceType: 'module',
},
},
rules: {
...pluginVue.configs.essential.rules,
...vueRules.rules,
...vueFormattingRules.rules,
// Vue 3 allows for multiple template roots, we should not have this rule
// TODO investigate why we have to manually disable this
'vue/no-multiple-template-root': 'off',
// This is related to a "temporary" fix we made that never got investigated and might be a fixed bug in Vue
// See commit a0e422a5c860f2bb305079e0f36de4847ada0283 ("Fix reactivity in compiled banner")
'vue/no-v-model-argument': 'off',
// Allow for long SVG components by having a ridiculous max-len for the template section of Vue files
'@stylistic/max-len': 'off',
'vue/max-len': [ 'warn', {
code: 170,
template: 100_000,
tabWidth: 4,
ignorePattern: '^[\\s]*(//|<!--) (es|style)lint-.+',
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
} ],
'vue/no-unused-components': [ 'error', {
ignoreWhenBindingPresent: false,
} ],
// We're using inline styles in SCG icon files and one-off content components
'vue/no-static-inline-styles': 'off',
// This forces script and style lang in Vue single file components
'vue/block-lang': [ 'error', {
script: { lang: 'ts' },
style: { lang: 'scss' },
} ],
},
},
];