Skip to content

Commit 8166c59

Browse files
committed
feat: update stylistic plugins
1 parent 0c8c42e commit 8166c59

File tree

9 files changed

+55
-38
lines changed

9 files changed

+55
-38
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Add the following settings to your `.vscode/settings.json`:
111111

112112
## Customization
113113

114-
Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), provides a much better organization and composition.
114+
Since v1.0, we migrated to [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new). It provides a much better organization and composition.
115115

116116
Normally you only need to import the `coderwyd` preset:
117117

@@ -143,7 +143,7 @@ export default coderwyd({
143143
})
144144
```
145145

146-
The `coderwyd` factory functions also accepts arbitrary numbers of constom configs overrides:
146+
The `coderwyd` factory function also accepts any number of arbitrary custom config overrides:
147147

148148
```js
149149
// eslint.config.js
@@ -166,7 +166,7 @@ export default coderwyd(
166166
)
167167
```
168168

169-
Going more advanced, you can also import the very fine-grained configs and compose them as you wish:
169+
Going more advanced, you can also import fine-grained configs and compose them as you wish:
170170

171171
```js
172172
// eslint.config.js
@@ -225,7 +225,7 @@ Since flat config requires us to explicitly provide the plugin names (instead of
225225
| `test/*` | `vitest/*` | [eslint-plugin-vitest](https://github.com/veritem/eslint-plugin-vitest) |
226226
| `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
227227

228-
When you want to overrides rules, or disable them inline, you need to update to the new prefix:
228+
When you want to override rules, or disable them inline, you need to update to the new prefix:
229229

230230
```diff
231231
-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions

eslint.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createRequire } from 'node:module'
22
import sortKeys from 'eslint-plugin-sort-keys'
3-
3+
import styleMigrate from '@stylistic/eslint-plugin-migrate'
44
import coderwyd from './dist/index.js'
55

66
const require = createRequire(import.meta.url)
@@ -18,4 +18,13 @@ export default coderwyd(
1818
'sort-keys/sort-keys-fix': 'error',
1919
},
2020
},
21+
{
22+
files: ['src/configs/*.ts'],
23+
plugins: {
24+
'style-migrate': styleMigrate,
25+
},
26+
rules: {
27+
'style-migrate/migrate': ['error', { namespaceTo: 'style' }],
28+
},
29+
},
2130
)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"yaml-eslint-parser": "^1.2.2"
7272
},
7373
"devDependencies": {
74+
"@stylistic/eslint-plugin-migrate": "^0.0.6",
7475
"@types/eslint": "^8.44.3",
7576
"@types/node": "^20.8.2",
7677
"@types/react": "^18.2.25",

pnpm-lock.yaml

Lines changed: 19 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configs/ignores.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export function ignores(): FlatESLintConfigItem[] {
55
return [
66
{
77
ignores: GLOB_EXCLUDE,
8-
name: 'coderwyd:ignores:basic',
98
},
109
]
1110
}

src/configs/javascript.ts

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,14 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
4040
rules: {
4141
'accessor-pairs': ['error', { enforceForClassMembers: true, setWithoutGet: true }],
4242

43-
'antfu/top-level-function': 'error',
44-
4543
'array-callback-return': 'error',
4644
'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
4745
'block-scoped-var': 'error',
4846
'constructor-super': 'error',
4947
'default-case-last': 'error',
5048
'dot-notation': ['error', { allowKeywords: true }],
51-
'eol-last': 'error',
5249
'eqeqeq': ['error', 'smart'],
53-
'max-statements-per-line': ['error', { max: 1 }],
5450
'new-cap': ['error', { capIsNew: false, newIsCap: true, properties: true }],
55-
'new-parens': 'error',
5651
'no-alert': 'error',
5752
'no-array-constructor': 'error',
5853
'no-async-promise-executor': 'error',
@@ -63,7 +58,6 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
6358
'no-cond-assign': ['error', 'always'],
6459
'no-console': ['error', { allow: ['warn', 'error'] }],
6560
'no-const-assign': 'error',
66-
'no-constant-condition': 'warn',
6761
'no-control-regex': 'error',
6862
'no-debugger': 'error',
6963
'no-delete-var': 'error',
@@ -79,9 +73,7 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
7973
'no-extend-native': 'error',
8074
'no-extra-bind': 'error',
8175
'no-extra-boolean-cast': 'error',
82-
'no-extra-parens': ['error', 'functions'],
8376
'no-fallthrough': 'error',
84-
'no-floating-decimal': 'error',
8577
'no-func-assign': 'error',
8678
'no-global-assign': 'error',
8779
'no-implied-eval': 'error',
@@ -94,14 +86,6 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
9486
'no-lone-blocks': 'error',
9587
'no-loss-of-precision': 'error',
9688
'no-misleading-character-class': 'error',
97-
'no-mixed-operators': ['error', {
98-
allowSamePrecedence: true,
99-
groups: [
100-
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
101-
['&&', '||'],
102-
['in', 'instanceof'],
103-
],
104-
}],
10589
'no-multi-str': 'error',
10690
'no-new': 'error',
10791
'no-new-func': 'error',
@@ -133,6 +117,8 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
133117
'DebuggerStatement',
134118
'LabeledStatement',
135119
'WithStatement',
120+
'TSEnumDeclaration[const=true]',
121+
'TSExportAssignment',
136122
],
137123
'no-self-assign': ['error', { props: true }],
138124
'no-self-compare': 'error',
@@ -202,7 +188,6 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
202188
'prefer-rest-params': 'error',
203189
'prefer-spread': 'error',
204190
'prefer-template': 'error',
205-
'quote-props': ['error', 'consistent-as-needed'],
206191
'sort-imports': [
207192
'error',
208193
{
@@ -213,19 +198,18 @@ export function javascript(options: OptionsIsInEditor & OptionsOverrides = {}):
213198
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
214199
},
215200
],
201+
216202
'symbol-description': 'error',
217203
'unicode-bom': ['error', 'never'],
218-
219204
'unused-imports/no-unused-imports': isInEditor ? OFF : 'error',
205+
220206
'unused-imports/no-unused-vars': [
221207
'error',
222208
{ args: 'after-used', argsIgnorePattern: '^_', vars: 'all', varsIgnorePattern: '^_' },
223209
],
224-
225210
'use-isnan': ['error', { enforceForIndexOf: true, enforceForSwitchCase: true }],
226211
'valid-typeof': ['error', { requireStringLiterals: true }],
227212
'vars-on-top': 'error',
228-
'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
229213
'yoda': ['error', 'never'],
230214

231215
...overrides,

src/configs/markdown.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ export function markdown(options: OptionsComponentExts & OptionsOverrides = {}):
3838
'antfu/no-cjs-exports': OFF,
3939
'antfu/no-ts-export-equal': OFF,
4040

41-
'eol-last': OFF,
4241
'no-alert': OFF,
4342
'no-console': OFF,
4443
'no-undef': OFF,
4544
'no-unused-expressions': OFF,
4645
'no-unused-vars': OFF,
47-
4846
'node/prefer-global/process': OFF,
4947

5048
'style/comma-dangle': OFF,
49+
'style/eol-last': OFF,
5150

5251
'ts/consistent-type-imports': OFF,
5352
'ts/no-namespace': OFF,

src/configs/stylistic.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function stylistic(): FlatESLintConfigItem[] {
1212
rules: {
1313
'antfu/consistent-list-newline': 'error',
1414
'antfu/if-newline': 'error',
15+
'antfu/top-level-function': 'error',
1516

1617
'curly': ['error', 'multi-or-nest', 'consistent'],
1718

@@ -24,6 +25,7 @@ export function stylistic(): FlatESLintConfigItem[] {
2425
'style/comma-style': ['error', 'last'],
2526
'style/computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
2627
'style/dot-location': ['error', 'property'],
28+
'style/eol-last': 'error',
2729
'style/indent': ['error', 2, {
2830
ArrayExpression: 1,
2931
CallExpression: { arguments: 1 },
@@ -65,8 +67,20 @@ export function stylistic(): FlatESLintConfigItem[] {
6567
'style/key-spacing': ['error', { afterColon: true, beforeColon: false }],
6668
'style/keyword-spacing': ['error', { after: true, before: true }],
6769
'style/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
70+
'style/max-statements-per-line': ['error', { max: 1 }],
6871
'style/member-delimiter-style': ['error', { multiline: { delimiter: 'none' } }],
6972
'style/multiline-ternary': ['error', 'always-multiline'],
73+
'style/new-parens': 'error',
74+
'style/no-extra-parens': ['error', 'functions'],
75+
'style/no-floating-decimal': 'error',
76+
'style/no-mixed-operators': ['error', {
77+
allowSamePrecedence: true,
78+
groups: [
79+
['==', '!=', '===', '!==', '>', '>=', '<', '<='],
80+
['&&', '||'],
81+
['in', 'instanceof'],
82+
],
83+
}],
7084
'style/no-mixed-spaces-and-tabs': 'error',
7185
'style/no-multi-spaces': 'error',
7286
'style/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
@@ -77,6 +91,7 @@ export function stylistic(): FlatESLintConfigItem[] {
7791
'style/object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
7892
'style/operator-linebreak': ['error', 'before'],
7993
'style/padded-blocks': ['error', { blocks: 'never', classes: 'never', switches: 'never' }],
94+
'style/quote-props': ['error', 'consistent-as-needed'],
8095
'style/quotes': ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }],
8196
'style/rest-spread-spacing': ['error', 'never'],
8297
'style/semi': ['error', 'never'],
@@ -100,6 +115,7 @@ export function stylistic(): FlatESLintConfigItem[] {
100115
'style/template-curly-spacing': 'error',
101116
'style/template-tag-spacing': ['error', 'never'],
102117
'style/type-annotation-spacing': ['error', {}],
118+
'style/wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
103119
'style/yield-star-spacing': ['error', 'both'],
104120
},
105121
},

src/configs/typescript.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export function typescript(
8585
'antfu/no-ts-export-equal': 'error',
8686

8787
'no-dupe-class-members': OFF,
88-
'no-extra-parens': OFF,
8988
'no-invalid-this': OFF,
9089
'no-loss-of-precision': OFF,
9190
'no-redeclare': OFF,
@@ -99,7 +98,6 @@ export function typescript(
9998
'ts/no-dupe-class-members': 'error',
10099
'ts/no-dynamic-delete': OFF,
101100
'ts/no-explicit-any': OFF,
102-
'ts/no-extra-parens': ['error', 'functions'],
103101
'ts/no-extraneous-class': OFF,
104102
'ts/no-invalid-this': 'error',
105103
'ts/no-invalid-void-type': OFF,

0 commit comments

Comments
 (0)