Skip to content

Commit dc6a25e

Browse files
authored
refactor!: migrate from eslint-stylistic to prettier (#412)
* chore: use prettier * refactor: re-organize special cases * chore: fix lint * chore: run build:typegen * chore: update prettier config * chore remove unused plugin
1 parent d690882 commit dc6a25e

35 files changed

+283
-1246
lines changed

.github/renovate.json5

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": ["github>coderwyd/renovate-config"]
2+
extends: ['github>coderwyd/renovate-config'],
33
}

.vscode/settings.json

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,6 @@
66
"eslint.options": {
77
"flags": ["unstable_ts_config"]
88
},
9-
"editor.formatOnSave": false,
10-
"eslint.validate": [
11-
"html",
12-
"css",
13-
"less",
14-
"scss",
15-
"json",
16-
"jsonc",
17-
"yaml",
18-
"yml",
19-
"markdown",
20-
"toml",
21-
"gql",
22-
"graphql"
23-
],
24-
// "eslint.runtime": "node",
25-
"eslint.rules.customizations": [
26-
{ "rule": "style/*", "severity": "off", "fixable": true },
27-
{ "rule": "*-indent", "severity": "off", "fixable": true },
28-
{ "rule": "*-spacing", "severity": "off", "fixable": true },
29-
{ "rule": "*-spaces", "severity": "off", "fixable": true },
30-
{ "rule": "*-order", "severity": "off", "fixable": true },
31-
{ "rule": "*-dangle", "severity": "off", "fixable": true },
32-
{ "rule": "*-newline", "severity": "off", "fixable": true },
33-
{ "rule": "*quotes", "severity": "off", "fixable": true },
34-
{ "rule": "*semi", "severity": "off", "fixable": true }
35-
],
36-
"prettier.enable": false,
37-
"cSpell.words": [
38-
"antfu",
39-
"astro",
40-
"coderwyd",
41-
"rspack",
42-
"unocss"
43-
]
9+
"editor.formatOnSave": true,
10+
"cSpell.words": ["antfu", "astro", "coderwyd", "rspack", "unocss"]
4411
}

README.md

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
- ✨ Support Vue, React, Svelte.
1111
- 🎯 Designed to work with TypeScript, Vue out-of-box
1212
- 🏆 Reasonable defaults, best practices, only one-line of config
13-
- 🎨 Use ESlint to format HTML, CSS, LESS, SCSS, YAML, TOML, Markdown, JSON, JSONC.
1413

1514
## Usage
1615

@@ -59,43 +58,14 @@ Add the following settings to your `.vscode/settings.json`:
5958

6059
```jsonc
6160
{
62-
// Disable the default formatter, use eslint instead
63-
"prettier.enable": false,
61+
"prettier.enable": true,
6462
"editor.formatOnSave": false,
6563

6664
// Auto fix
6765
"editor.codeActionsOnSave": {
6866
"source.fixAll": "explicit",
69-
"source.organizeImports": "never"
67+
"source.organizeImports": "never",
7068
},
71-
72-
// Silent the stylistic rules in you IDE, but still auto fix them
73-
"eslint.rules.customizations": [
74-
{ "rule": "style/*", "severity": "off", "fixable": true },
75-
{ "rule": "format/*", "severity": "off", "fixable": true },
76-
{ "rule": "*-indent", "severity": "off", "fixable": true },
77-
{ "rule": "*-spacing", "severity": "off", "fixable": true },
78-
{ "rule": "*-spaces", "severity": "off", "fixable": true },
79-
{ "rule": "*-order", "severity": "off", "fixable": true },
80-
{ "rule": "*-dangle", "severity": "off", "fixable": true },
81-
{ "rule": "*-newline", "severity": "off", "fixable": true },
82-
{ "rule": "*quotes", "severity": "off", "fixable": true },
83-
{ "rule": "*semi", "severity": "off", "fixable": true }
84-
],
85-
86-
// Enable eslint for all supported languages
87-
"eslint.validate": [
88-
"html",
89-
"css",
90-
"less",
91-
"scss",
92-
"json",
93-
"jsonc",
94-
"yaml",
95-
"yml",
96-
"markdown",
97-
"toml"
98-
]
9969
}
10070
```
10171

@@ -157,15 +127,6 @@ interface OptionsConfig extends OptionsComponentExts {
157127
*/
158128
typescript?: boolean | OptionsTypescript
159129

160-
/**
161-
* Enable JSX related rules.
162-
*
163-
* Currently only stylistic rules are included.
164-
*
165-
* @default true
166-
*/
167-
jsx?: boolean
168-
169130
/**
170131
* Enable test support.
171132
*
@@ -226,14 +187,6 @@ interface OptionsConfig extends OptionsComponentExts {
226187
*/
227188
unocss?: boolean | OptionsUnoCSS
228189

229-
/**
230-
* Enable stylistic rules.
231-
*
232-
* @see https://eslint.style/
233-
* @default true
234-
*/
235-
stylistic?: boolean | (StylisticConfig & OptionsOverrides)
236-
237190
/**
238191
* Enable regexp rules.
239192
*
@@ -242,23 +195,6 @@ interface OptionsConfig extends OptionsComponentExts {
242195
*/
243196
regexp?: boolean | (OptionsRegExp & OptionsOverrides)
244197

245-
/**
246-
* Use external formatters to format files.
247-
*
248-
* @default
249-
* {
250-
* "html": true,
251-
* "css": true,
252-
* "graphql": false,
253-
* "markdown": false
254-
* "yaml": false
255-
* "toml": false
256-
* }
257-
*
258-
* When set to `true`, it will enable all formatters.
259-
*/
260-
formatter?: boolean | OptionsFormatters
261-
262198
/**
263199
* Control to disable some rules in editors.
264200
* @default auto-detect based on the process.env

eslint.config.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
// @ts-expect-error missing types
2-
import styleMigrate from '@stylistic/eslint-plugin-migrate'
3-
41
import { defineConfig } from './src'
52

63
export default defineConfig(
74
{
85
vue: true,
96
react: false,
107
typescript: true,
11-
formatter: true,
128
},
139
{
1410
files: ['src/**/*.ts'],
1511
rules: {
1612
'perfectionist/sort-objects': 'error',
1713
},
1814
},
19-
{
20-
files: ['src/configs/*.ts'],
21-
plugins: {
22-
'style-migrate': styleMigrate,
23-
},
24-
rules: {
25-
'style-migrate/migrate': ['error', { namespaceTo: 'style' }],
26-
},
27-
},
2815
)

package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,35 +83,33 @@
8383
"dependencies": {
8484
"@antfu/install-pkg": "^0.4.1",
8585
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
86-
"@stylistic/eslint-plugin": "^2.8.0",
8786
"@toml-tools/parser": "^1.0.0",
8887
"@typescript-eslint/eslint-plugin": "^8.7.0",
8988
"@typescript-eslint/parser": "^8.7.0",
9089
"@vitest/eslint-plugin": "^1.1.4",
9190
"eslint-config-flat-gitignore": "^0.3.0",
92-
"eslint-merge-processors": "^0.1.0",
91+
"eslint-config-prettier": "^9.1.0",
9392
"eslint-plugin-antfu": "^2.7.0",
9493
"eslint-plugin-command": "^0.2.5",
9594
"eslint-plugin-eslint-comments": "^3.2.0",
96-
"eslint-plugin-format": "^0.1.2",
9795
"eslint-plugin-import-x": "^4.3.0",
9896
"eslint-plugin-jsdoc": "^50.2.4",
9997
"eslint-plugin-jsonc": "^2.16.0",
10098
"eslint-plugin-n": "^17.10.3",
10199
"eslint-plugin-no-only-tests": "^3.3.0",
102100
"eslint-plugin-perfectionist": "^3.7.0",
101+
"eslint-plugin-prettier": "^5.2.1",
103102
"eslint-plugin-regexp": "^2.6.0",
104103
"eslint-plugin-unicorn": "^55.0.0",
105104
"eslint-plugin-unused-imports": "^4.1.4",
106105
"eslint-plugin-vue": "^9.28.0",
107-
"eslint-processor-vue-blocks": "^0.1.2",
108106
"eslint-typegen": "^0.3.2",
109107
"globals": "^15.9.0",
110108
"jsonc-eslint-parser": "^2.4.0",
111109
"local-pkg": "^0.5.0",
112110
"parse-gitignore": "^2.0.0",
113111
"picocolors": "^1.1.0",
114-
"prettier-plugin-toml": "^2.0.1",
112+
"prettier": "^3.3.3",
115113
"prompts": "^2.4.2",
116114
"vue-eslint-parser": "^9.4.3",
117115
"yargs": "^17.7.2"
@@ -120,7 +118,7 @@
120118
"@antfu/ni": "^0.23.0",
121119
"@eslint-react/eslint-plugin": "^1.14.2",
122120
"@eslint/config-inspector": "^0.5.4",
123-
"@stylistic/eslint-plugin-migrate": "^2.8.0",
121+
"@types/eslint-config-prettier": "^6.11.3",
124122
"@types/fs-extra": "^11.0.4",
125123
"@types/node": "^22.6.1",
126124
"@types/prompts": "^2.4.9",

0 commit comments

Comments
 (0)