-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
137 lines (127 loc) · 4.1 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
132
133
134
135
136
137
import vuejsAccessibility from 'eslint-plugin-vuejs-accessibility';
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';
// A workaround until our project really uses the fixed "globals" package (eslint transitive dependency)
// See https://github.com/sindresorhus/globals/issues/239
const fixedBrowserGlobals = Object.assign( {}, globals.browser, { AudioWorkletGlobalScope: globals.browser[ 'AudioWorkletGlobalScope ' ] } );
delete fixedBrowserGlobals[ 'AudioWorkletGlobalScope ' ];
export default [
commonStyle,
{
files: [ '**/*.vue', '**/*.ts' ],
plugins: {
...typescriptStyle.plugins,
},
languageOptions: {
globals: {
...globals.node,
...fixedBrowserGlobals,
},
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/array-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
// Custom rules to prevent shipping debug code to prod
'no-console': 'error',
'no-debugger': 'error',
},
},
{
name: 'Additional rules for Jest TypeScript test files',
files: [ 'tests/**/*.ts' ],
languageOptions: {
globals: {
...globals.node,
...fixedBrowserGlobals,
...globals.jest,
},
parser: parser,
ecmaVersion: 7,
sourceType: 'module',
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaFeatures: {
modules: true,
},
},
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-namespace': 'off',
},
},
{
files: [ '**/*.vue' ],
plugins: {
vue: pluginVue,
'vuejs-accessibility': vuejsAccessibility,
},
languageOptions: {
parser: parser,
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
sourceType: 'module',
},
},
rules: {
...pluginVue.configs.essential.rules,
...vuejsAccessibility.configs.recommended.rules,
// The following rules should be turned on again in the future (using the settings from pluginVue.configs.essential)
// We placed them here to avoid huge changes in our legacy codebase and to allow for slow migration
// See https://phabricator.wikimedia.org/T383420
'vue/multi-word-component-names': 'off',
'vue/no-mutating-props': 'off',
'vue/no-multiple-template-root': 'off',
'vue/no-v-for-template-key': 'off',
// Allow for dot-separated slot names for our custom FeatureToggle component
// We should consider renaming the slots to use a different separator
'vue/valid-v-slot': '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,
} ],
'vuejs-accessibility/label-has-for': [ 'error', {
required: {
some: [ 'nesting', 'id' ],
},
} ],
// We use autofocus to ensure the first form field in dialog modals is focused on open
'vuejs-accessibility/no-autofocus': 'off',
},
},
];