1
1
import type { FlatESLintConfigItem } from 'eslint-define-config'
2
-
import { packages } from '@eslint-stylistic/metadata'
3
-
import { pluginStylisticJs, pluginStylisticTs, pluginTs } from '../plugins'
4
-
import { OFF } from '../flags'
2
+
import { pluginStylistic } from '../plugins'
5
3
6
-
const tsPackage = packages.find(i => i.shortId === 'ts')!
7
-
8
-
export const javascriptStylistic: FlatESLintConfigItem[] = [
4
+
export const stylistic: FlatESLintConfigItem[] = [
9
5
{
10
6
plugins: {
11
-
style: pluginStylisticJs,
7
+
style: pluginStylistic,
12
8
},
13
9
rules: {
14
10
'antfu/consistent-list-newline': 'error',
15
11
'antfu/if-newline': 'error',
16
12
17
-
'comma-dangle': ['error', 'always-multiline'],
18
13
'curly': ['error', 'multi-or-nest', 'consistent'],
19
-
'quotes': ['error', 'single'],
20
-
'semi': ['error', 'never'],
21
14
22
15
'style/array-bracket-spacing': ['error', 'never'],
23
16
'style/arrow-spacing': ['error', { after: true, before: true }],
24
17
'style/block-spacing': ['error', 'always'],
25
18
'style/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
19
+
'style/comma-dangle': ['error', 'always-multiline'],
26
20
'style/comma-spacing': ['error', { after: true, before: false }],
27
21
'style/comma-style': ['error', 'last'],
28
22
'style/computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
@@ -68,6 +62,7 @@ export const javascriptStylistic: FlatESLintConfigItem[] = [
68
62
'style/key-spacing': ['error', { afterColon: true, beforeColon: false }],
69
63
'style/keyword-spacing': ['error', { after: true, before: true }],
70
64
'style/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
65
+
'style/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }],
71
66
'style/multiline-ternary': ['error', 'always-multiline'],
72
67
'style/no-mixed-spaces-and-tabs': 'error',
73
68
'style/no-multi-spaces': 'error',
@@ -79,7 +74,9 @@ export const javascriptStylistic: FlatESLintConfigItem[] = [
79
74
'style/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
80
75
'style/operator-linebreak': ['error', 'before'],
81
76
'style/padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }],
77
+
'style/quotes': ['error', 'single'],
82
78
'style/rest-spread-spacing': ['error', 'never'],
79
+
'style/semi': ['error', 'never'],
83
80
'style/semi-spacing': ['error', { after: true, before: false }],
84
81
'style/space-before-blocks': ['error', 'always'],
85
82
'style/space-before-function-paren': ['error', { anonymous: 'always', asyncArrow: 'always', named: 'never' }],
@@ -99,62 +96,8 @@ export const javascriptStylistic: FlatESLintConfigItem[] = [
99
96
}],
100
97
'style/template-curly-spacing': 'error',
101
98
'style/template-tag-spacing': ['error', 'never'],
99
+
'style/type-annotation-spacing': ['error', {}],
102
100
'style/yield-star-spacing': ['error', 'both'],
103
101
},
104
102
},
105
103
]
106
-
107
-
export const typescriptStylistic: FlatESLintConfigItem[] = [
108
-
{
109
-
plugins: {
110
-
'style-ts': pluginStylisticTs,
111
-
'ts': pluginTs as any,
112
-
},
113
-
rules: {
114
-
...stylisticJsToTS(javascriptStylistic[0].rules!),
115
-
116
-
'comma-dangle': OFF,
117
-
'quotes': OFF,
118
-
'semi': OFF,
119
-
120
-
'style-ts/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }],
121
-
'style-ts/type-annotation-spacing': ['error', {}],
122
-
123
-
'ts/comma-dangle': ['error', 'always-multiline'],
124
-
'ts/quotes': ['error', 'single'],
125
-
'ts/semi': ['error', 'never'],
126
-
},
127
-
},
128
-
]
129
-
130
-
// TODO: move to ESLint Stylistic
131
-
function stylisticJsToTS(input: Record<string, any>) {
132
-
return {
133
-
// turn off all stylistic rules from style
134
-
...Object.fromEntries(
135
-
Object.entries(input)
136
-
.map(([key]) => {
137
-
if (!key.startsWith('style/'))
138
-
return null!
139
-
const basename = key.replace('style/', '')
140
-
if (tsPackage.rules.find(i => i.name === basename))
141
-
return [key, OFF]
142
-
return null!
143
-
})
144
-
.filter(Boolean),
145
-
),
146
-
// rename all stylistic rules from style to style/ts
147
-
...Object.fromEntries(
148
-
Object.entries(input)
149
-
.map(([key, value]) => {
150
-
if (!key.startsWith('style/'))
151
-
return null!
152
-
const basename = key.replace('style/', '')
153
-
return tsPackage.rules.find(i => i.name === basename)
154
-
? [`style-ts/${basename}`, value]
155
-
: null!
156
-
})
157
-
.filter(Boolean),
158
-
),
159
-
}
160
-
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4