-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
78 lines (75 loc) · 2.25 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
import { createConfigForNuxt } from '@nuxt/eslint-config/flat';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
// Run `npx @eslint/config-inspector` to inspect the resolved config interactively
const config = await createConfigForNuxt({
features: {
tooling: true,
stylistic: true,
typescript: true,
standalone: true,
},
dirs: {
src: ['./playground', './test/fixtures/*'],
},
})
// Enable extra goodies normally disabled
.overrideRules(
{
'unicorn/number-literal-case': 'error',
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: true, prefer: 'type-imports', fixStyle: 'inline-type-imports' }]
}
)
// Resolves conflicts
.overrideRules(
{
'import/order': 'off',
'@stylistic/indent-binary-ops': ['off'],
'@stylistic/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
multilineDetection: 'brackets',
},
],
}
)
.insertAfter('nuxt/import/rules', {
name: 'simple-import-sort',
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
})
// .overrideRules(eslintPluginPrettierRecommended.rules ?? {})//Throws error. Workaround below.
.overrideRules(Object.fromEntries(
Object.entries(eslintPluginPrettierRecommended.rules ?? {})
.map(([rule, settings]) => {
return [`@stylistic/${rule}`, settings];
}),
))
.prepend({ ignores: ['docs/**'] });
// Workaround for prettier overrides
const prettierRules = Object.keys(eslintPluginPrettierRecommended.rules);
for (const { rules } of Object.values(config)) {
if (typeof rules !== 'object') {
continue;
}
for (const rule of Object.keys(rules)) {
if (prettierRules.includes(rule)) {
rules[rule] = eslintPluginPrettierRecommended.rules[rule];
}
}
}
// console.log(config.map(({name, rules}) => ({name, rules})));
export default config;