-
Notifications
You must be signed in to change notification settings - Fork 346
Expand file tree
/
Copy patheslint.config.mjs
More file actions
209 lines (196 loc) · 7.03 KB
/
Copy patheslint.config.mjs
File metadata and controls
209 lines (196 loc) · 7.03 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/**
* Root flat config — the flat-config successor to `.eslintrc.js` (+ `.eslintrc.default.js`
* via the shared `eslintConfigBase`). Ignores are ported from the old `.eslintignore`.
*
* Behaviour-preserving migration: the effective ruleset matches the previous
* eslintrc setup. A handful of `'off'` rule references were dropped because their plugins
* are no longer registered (`nuxt/*`, `unicorn/*`) or the rule was removed in
* typescript-eslint v8 (`@typescript-eslint/no-var-requires`); being `'off'`, dropping them
* changes nothing.
*/
import globals from 'globals';
import { eslintConfigBase } from './eslint.config.base.mjs';
// Vue `<script setup>` compiler macros (was `env: { 'vue/setup-compiler-macros': true }`).
const compilerMacros = {
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
defineModel: 'readonly',
defineOptions: 'readonly',
defineSlots: 'readonly',
};
export default [
// Ported from `.eslintignore`.
{
ignores: [
'**/coverage/',
'**/.nyc_output/',
'**/node_modules/',
'**/.npm/',
'**/.eslintcache',
'**/.env',
'**/.cache/',
'**/.next/',
'**/dist/',
'**/dist-pkg/',
'**/.DS_Store',
'shell/utils/dynamic-importer.js',
'**/ksconfig.json',
'**/storybook-static/',
'utils/dynamic-importer.js',
'shell/assets/fonts/',
'assets/fonts/',
'shell/pkg/import.js',
'shell/types/shell/index.d.ts',
'**/build/',
'**/public/',
'pkg/**/node_modules/',
'**/elemental-ui/',
'**/kubewarden-ui/',
'styleguide/src/stories/Example/',
'storybook/src/stories/Example/',
'cypress/dist/',
'cypress/bin/',
'cypress/template/',
// Extension scaffold templates: these are copied into a generated extension and are
// linted there (their `eslint.config.mjs` imports `@rancher/shell`, unresolvable here),
// so they must not be linted by this repo.
'creators/**/files/**',
],
},
...eslintConfigBase,
// Root-level globals (was `.eslintrc.js` env: jest + vue/setup-compiler-macros).
{
languageOptions: {
globals: {
...globals.jest,
...compilerMacros,
},
},
},
// Root rule overrides (was `.eslintrc.js` rules).
{
rules: {
'jest/no-commented-out-tests': 'off',
'jest/no-disabled-tests': 'off',
'dot-notation': 'off',
'generator-star-spacing': 'off',
'guard-for-in': 'off',
'linebreak-style': 'off',
'new-cap': 'off',
'no-empty': 'off',
'no-extra-boolean-cast': 'off',
'no-new': 'off',
'no-plusplus': 'off',
'no-useless-escape': 'off',
strict: 'off',
'vue/no-unused-components': 'warn',
curly: 'warn',
eqeqeq: 'warn',
'implicit-arrow-linebreak': 'warn',
'no-caller': 'warn',
'no-cond-assign': ['warn', 'except-parens'],
'no-console': 'warn',
'no-debugger': 'warn',
'no-eq-null': 'warn',
'no-eval': 'warn',
'no-undef': 'warn',
'no-unused-vars': 'warn',
'no-redeclare': 'off',
'@typescript-eslint/no-redeclare': ['error'],
'prefer-arrow-callback': 'warn',
'prefer-template': 'warn',
'vue/order-in-components': 'off',
'vue/no-lone-template': 'off',
'vue/v-slot-style': 'off',
'vue/component-tags-order': 'off',
'vue/no-mutating-props': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'array-callback-return': 'off',
'import/order': 'off',
'import/no-named-as-default': 'off',
'vue/multi-word-component-names': 'off',
'vue/no-reserved-component-names': 'off',
'vue/no-useless-template-attributes': 'off',
'vue/attribute-hyphenation': 'off',
'vue/valid-next-tick': 'off',
'vue/no-computed-properties-in-data': 'off',
'vue/no-side-effects-in-computed-properties': 'off',
'vue/one-component-per-file': 'off',
'vue/no-deprecated-slot-attribute': 'off',
'vue/v-on-event-hyphenation': 'off',
},
},
// override: *.d.ts (was overrides[0])
{
files: ['**/*.d.ts'],
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
},
},
// override: *.js (was overrides[1])
{
files: ['**/*.js'],
rules: {
'prefer-regex-literals': 'off',
'vue/component-definition-name-casing': 'off',
'no-unreachable-loop': 'off',
'computed-property-spacing': 'off',
},
},
// override: docusaurus (was overrides[2])
{
files: ['docusaurus/**/*.{js,ts}'],
rules: { 'no-use-before-define': 'off' },
},
// override: **/*.vue (was overrides[3])
{
files: ['**/*.vue'],
rules: {
'vue/no-v-html': 'error',
'vue/html-indent': ['error', 2],
'vue/html-closing-bracket-newline': ['error', { singleline: 'never', multiline: 'always' }],
'vue/html-closing-bracket-spacing': 2,
'vue/html-end-tags': 2,
'vue/html-quotes': 2,
'vue/html-self-closing': ['error', {
html: { void: 'never', normal: 'always', component: 'always' },
svg: 'always',
math: 'always',
}],
'vue/max-attributes-per-line': ['error', {
singleline: { max: 1 },
multiline: { max: 1 },
}],
},
},
// override: shell/utils + shell/scripts (was overrides[4])
{
files: ['**/shell/utils/**/*.{js,ts}', '**/shell/scripts/**/*.{js,ts}'],
rules: { '@typescript-eslint/no-empty-function': 'off' },
},
// override: **/*.{js,ts,vue} (was overrides[5])
{
files: ['**/*.{js,ts,vue}'],
rules: {
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
// override: harvester / harvester-manager (was overrides[6])
{
files: ['**/{harvester,harvester-manager}/**/*.{js,ts,vue}'],
rules: {
'@typescript-eslint/explicit-module-boundary-types': 'off',
'vue/html-self-closing': 'off',
'vue/no-v-html': 'error',
},
},
// override: po (was overrides[7])
{
files: ['**/po/**/*.{js,ts,vue}'],
rules: { '@typescript-eslint/explicit-module-boundary-types': 'off' },
},
];