forked from rancher-sandbox/rancher-desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.mts
More file actions
192 lines (190 loc) · 7.48 KB
/
eslint.config.mts
File metadata and controls
192 lines (190 loc) · 7.48 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
import path from 'path';
import { includeIgnoreFile } from '@eslint/compat';
import eslint from '@eslint/js';
import { standardTypeChecked } from '@vue/eslint-config-standard-with-typescript';
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
import pluginVue from 'eslint-plugin-vue';
import globals from 'globals';
export default defineConfigWithVueTs(
eslint.configs.recommended,
pluginVue.configs['flat/recommended'],
standardTypeChecked.map(entry => {
// Avoid issues with redefining plugins:
// `Config "typescript-eslint/base": Key "plugins": Cannot redefine plugin "@typescript-eslint".`
if (entry.plugins) {
delete entry.plugins['@typescript-eslint'];
}
return entry;
}),
vueTsConfigs.recommendedTypeChecked,
vueTsConfigs.stylisticTypeChecked,
includeIgnoreFile(path.resolve('.gitignore')),
{
name: 'rancher-desktop',
languageOptions: {
sourceType: 'commonjs',
},
rules: {
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/indent': ['warn', 2, { SwitchCase: 0 }],
'@stylistic/key-spacing': ['warn', {
align: {
beforeColon: false,
afterColon: true,
on: 'value',
mode: 'minimum',
},
multiLine: {
beforeColon: false,
afterColon: true,
},
}],
'@stylistic/no-multi-spaces': ['error', { ignoreEOLComments: true, exceptions: { Property: true, ImportAttribute: true, TSTypeAnnotation: true } }],
'@stylistic/quotes': ['warn', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'@stylistic/semi': ['error', 'always', {
omitLastInOneLineBlock: true,
omitLastInOneLineClassBody: true,
}],
'@stylistic/space-before-function-paren': ['error', 'never'],
'@stylistic/space-in-parens': 'off',
'@stylistic/template-curly-spacing': ['error', 'always'],
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-deprecated': 'error',
'@typescript-eslint/no-explicit-any': 'off', // We do need `any` sometimes
'@typescript-eslint/no-unused-vars': ['warn', {
args: 'none', caughtErrors: 'none', ignoreRestSiblings: true, varsIgnorePattern: '^_.',
}],
'@typescript-eslint/only-throw-error': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/unbound-method': 'off',
'import-x/order': ['error', {
alphabetize: { order: 'asc' },
groups: ['builtin', 'external', ['parent', 'sibling', 'index'], 'internal', 'object', 'type'],
'newlines-between': 'always',
pathGroupsExcludedImportTypes: ['builtin', 'object'],
pathGroups: [
{
pattern: '@pkg/**',
group: 'internal',
},
],
}],
'new-cap': 'off',
// This one assumes all callbacks have errors in the first argument, which isn't likely.
'n/no-callback-literal': 'off',
'no-global-assign': ['error', { exceptions: ['console'] }],
'vue/comma-dangle': ['error', 'always-multiline'],
},
},
{
name: 'rancher-desktop-vue',
files: ['**/*.vue'],
languageOptions: {
sourceType: 'module',
},
},
{
// The `no-useless-assignment` rule is catching `export const getters = ...` for some reason.
name: 'rancher-desktop-useless-assignment-in-store',
files: ['pkg/rancher-desktop/store/*.ts'],
rules: { 'no-useless-assignment': 'off' },
},
{
// Disable TypeScript-specific rules in JavaScript files.
name: 'rancher-desktop-js',
files: ['**/*.js', '**/*.cjs'],
rules: {
'@typescript-eslint/no-require-imports': ['off'],
},
},
{
// Disable lints not needed in tests (mostly global imports).
name: 'rancher-desktop-spec',
files: ['**/*.spec.js', '**/*.spec.ts'],
languageOptions: {
globals: globals.jest,
},
rules: {
'@typescript-eslint/no-require-imports': 'off',
'import-x/first': 'off', // Often needed for mocks
},
},
{
// Files we imported from Rancher Dashboard.
name: 'rancher-dashboard-imports',
files: [
'pkg/rancher-desktop/plugins/*.js',
'pkg/rancher-desktop/utils/*.js',
],
languageOptions: {
globals: globals.browser,
},
},
{
// Files we imported from Rancher Dashboard.
name: 'rancher-dashboard-useless-assignments',
files: [
'pkg/rancher-desktop/components/SortableTable/*',
'pkg/rancher-desktop/store/*.js',
'pkg/rancher-desktop/utils/*.js',
],
rules: {
'no-useless-assignment': 'off',
},
},
{
// Compatibility: disable lints during the ESLint transition.
name: 'rancher-desktop-compatibility',
extends: [
{
// Files we imported from Rancher Dashboard.
name: 'rancher-dashboard-imports',
files: [
'pkg/rancher-desktop/components/SortableTable/**',
],
rules: {
'vue/eqeqeq': 'off',
},
},
{
// Files in workflows were previously excluded from linting
name: 'rancher-desktop-workflows',
ignores: ['.github/workflows/**'],
},
],
rules: {
'@typescript-eslint/class-literal-property-style': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/prefer-find': 'off',
'@typescript-eslint/prefer-for-of': 'off',
'array-callback-return': 'off',
'no-constant-binary-expression': 'off',
'no-unreachable-loop': 'off',
'no-use-before-define': 'off',
'no-useless-escape': 'off',
'prefer-rest-params': 'off',
'prefer-spread': 'off',
'vue/block-lang': 'off',
'vue/component-definition-name-casing': 'off',
'vue/multi-word-component-names': 'off',
'vue/no-deprecated-delete-set': 'off',
'vue/no-reserved-component-names': 'off',
'vue/no-side-effects-in-computed-properties': 'off',
'vue/no-v-for-template-key-on-child': 'off',
'vue/no-v-html': 'off',
'vue/order-in-components': 'off',
'vue/require-explicit-emits': 'off',
},
},
);