-
Notifications
You must be signed in to change notification settings - Fork 127
/
Copy patheslint.config.js
188 lines (177 loc) · 4.95 KB
/
eslint.config.js
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
import pluginJs from '@eslint/js'
import stylistic from '@stylistic/eslint-plugin'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import importPlugin from 'eslint-plugin-import'
import tailwind from 'eslint-plugin-tailwindcss'
import unusedImports from 'eslint-plugin-unused-imports'
import pluginVue from 'eslint-plugin-vue'
import * as pluginVueScopedCss from 'eslint-plugin-vue-scoped-css'
import globals from 'globals'
import neostandard, { resolveIgnoresFromGitignore } from 'neostandard'
import tseslint from 'typescript-eslint'
import vueParser from 'vue-eslint-parser'
const baseConfig = [
{
files: ['**/*.{js,ts,vue}'],
},
{
languageOptions: {
globals: {
// Add browser environment globals (window, document, etc.) to prevent
// ESLint from flagging them as undefined
...globals.browser,
// Add Node.js environment globals (process, require, etc.) to prevent
// ESLint from flagging them as undefined
...globals.node,
// Add ES2021 environment globals (BigInt, WeakRef, etc.) to prevent
// ESLint from flagging them as undefined
...globals.es2021,
},
},
},
pluginJs.configs.recommended,
]
const tailwindConfig = [
...tailwind.configs['flat/recommended'],
{
settings: {
tailwindcss: {
whitelist: [
'vp-raw',
'^fwb\\-.*$', // Whitelist all classnames that start with "fwb-"
],
},
},
},
]
const vueConfig = [
...defineConfigWithVueTs(
pluginVue.configs['flat/recommended'],
vueTsConfigs.recommended,
),
{
languageOptions: {
parserOptions: {
parser: tseslint.parser,
},
},
},
{
rules: {
'vue/block-order': ['error', { order: ['template', 'script', 'style'] }],
'vue/component-name-in-template-casing': ['error', 'kebab-case'],
},
},
]
const vueScopedCssConfig = [
...pluginVueScopedCss.configs['flat/recommended'],
{
rules: {
'vue-scoped-css/enforce-style-type': ['error', { allows: ['scoped', 'plain'] }],
},
},
]
const standardConfig = [
// Neostandard includes the @stylistic/eslint-plugin, but we need to import it
// ourselves to add custom rules; this unfortunately seems to be an all or
// nothing situation
...neostandard({
ignores: resolveIgnoresFromGitignore(),
noJsx: true,
ts: true,
vue: true,
}),
importPlugin.flatConfigs.recommended,
{
plugins: {
'unused-imports': unusedImports,
},
rules: {
'unused-imports/no-unused-imports': 'error',
'import/no-duplicates': ['error', { 'prefer-inline': true }],
},
},
{
rules: {
// Disable ESLint's import resolution in favor of TypeScript's more accurate
// module resolution which handles aliases, types, and dynamic imports correctly
'import/no-unresolved': 0,
// Enforce consistent import ordering by grouping imports into categories:
// Node built-ins first, followed by external packages, internal modules,
// relative imports, and finally type imports
'import/order': [
'error', {
'alphabetize': {
caseInsensitive: true,
order: 'asc',
orderImportKind: 'asc',
},
'groups': [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
'newlines-between': 'always',
},
],
// Sort named imports within each import declaration
// e.g. import { aaa, bbb, ccc } from 'module'
'sort-imports': [
'error', {
ignoreDeclarationSort: true,
ignoreCase: true,
},
],
},
},
]
const stylisticConfig = [
// The recommended-flat config includes things like trailing commas that are
// not included Neostandard's recommended config
stylistic.configs.customize({
flat: true,
jsx: false,
}),
{
plugins: {
'@stylistic': stylistic,
},
rules: {
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
'@stylistic/quote-props': ['error', 'consistent-as-needed'],
'@stylistic/space-before-function-paren': ['error', 'always'],
},
},
]
// Must be last in the configuration order to properly override conflicting rules
// TypeScript's type system handles many checks more accurately than ESLint,
// including import resolution, type checking, and variable usage
const typeScriptConfig = [
...tseslint.configs.strict,
{
languageOptions: {
parser: vueParser,
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
},
},
]
export default [
...baseConfig,
...tailwindConfig,
...vueConfig,
...vueScopedCssConfig,
...standardConfig,
...stylisticConfig,
...typeScriptConfig,
]