Skip to content

Commit 4eadf31

Browse files
committed
refactor: turn on some formatting rules
1 parent 6a4a91b commit 4eadf31

File tree

9 files changed

+99
-27
lines changed

9 files changed

+99
-27
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ interface OptionsConfig {
218218
* {
219219
* "html": true,
220220
* "css": true,
221-
* "json": true,
222221
* "graphql": false,
223222
* "markdown": false
224223
* "yaml": false

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
"eslint-config-svelte",
1616
"prettier"
1717
],
18+
"publishConfig": {
19+
"access": "public"
20+
},
1821
"exports": {
1922
".": {
2023
"types": "./dist/index.d.ts",
@@ -27,9 +30,6 @@
2730
"types": "./dist/index.d.ts",
2831
"bin": "./bin/index.js",
2932
"files": ["bin", "dist"],
30-
"publishConfig": {
31-
"access": "public"
32-
},
3333
"engines": {
3434
"node": ">=16.14.0"
3535
},
@@ -39,9 +39,9 @@
3939
"lint": "eslint .",
4040
"lint:fix": "eslint . --fix",
4141
"prepack": "nr build",
42+
"prepare": "simple-git-hooks",
4243
"release": "bumpp && pnpm publish",
43-
"typecheck": "tsc --noEmit",
44-
"prepare": "simple-git-hooks"
44+
"typecheck": "tsc --noEmit"
4545
},
4646
"peerDependencies": {
4747
"@unocss/eslint-plugin": ">=0.50.0",

src/configs/formatter.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import {
22
GLOB_CSS,
33
GLOB_GRAPHQL,
44
GLOB_HTML,
5-
GLOB_JSON,
6-
GLOB_JSON5,
7-
GLOB_JSONC,
85
GLOB_LESS,
96
GLOB_MARKDOWN,
107
GLOB_POSTCSS,
@@ -31,7 +28,6 @@ export async function formatter(
3128
css = true,
3229
graphql,
3330
html = true,
34-
json = true,
3531
markdown,
3632
toml,
3733
yaml,
@@ -101,12 +97,6 @@ export async function formatter(
10197
configs.push(cssConfig, scssConfig, lessConfig)
10298
}
10399

104-
if (json) {
105-
const jsonConfig = createPrettierFormatter([GLOB_JSON, GLOB_JSONC], 'json')
106-
const json5Config = createPrettierFormatter([GLOB_JSON5], 'json5')
107-
configs.push(jsonConfig, json5Config)
108-
}
109-
110100
if (markdown) {
111101
const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], 'markdown')
112102
configs.push(markdownConfig)

src/configs/imports.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ export async function imports(): Promise<FlatConfigItem[]> {
1616
'antfu/no-import-node-modules-by-path': 'error',
1717

1818
'import/first': 'error',
19-
'import/newline-after-import': [
20-
'error',
21-
{ considerComments: true, count: 1 },
22-
],
2319
'import/no-duplicates': 'error',
2420
'import/no-mutable-exports': 'error',
2521
'import/no-named-default': 'error',
@@ -42,6 +38,14 @@ export async function imports(): Promise<FlatConfigItem[]> {
4238
pathGroupsExcludedImportTypes: ['type'],
4339
},
4440
],
41+
42+
...{
43+
// format
44+
'import/newline-after-import': [
45+
'error',
46+
{ considerComments: true, count: 1 },
47+
],
48+
},
4549
},
4650
},
4751
{

src/configs/jsdoc.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ export async function jsdoc(): Promise<FlatConfigItem[]> {
2424
'jsdoc/require-returns-check': 'warn',
2525
'jsdoc/require-returns-description': 'warn',
2626
'jsdoc/require-yields-check': 'warn',
27+
28+
...{
29+
// format
30+
'jsdoc/check-alignment': 'warn',
31+
'jsdoc/multiline-blocks': 'warn',
32+
},
2733
},
2834
},
2935
]

src/configs/jsonc.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ export async function jsonc(
5454
'jsonc/valid-json-number': 'error',
5555
'jsonc/vue-custom-block/no-parsing-error': 'error',
5656

57+
...{
58+
// format
59+
'jsonc/array-bracket-spacing': ['error', 'never'],
60+
'jsonc/comma-dangle': ['error', 'never'],
61+
'jsonc/comma-style': ['error', 'last'],
62+
'jsonc/indent': ['error', 2],
63+
'jsonc/key-spacing': [
64+
'error',
65+
{ afterColon: true, beforeColon: false },
66+
],
67+
'jsonc/object-curly-newline': [
68+
'error',
69+
{ consistent: true, multiline: true },
70+
],
71+
'jsonc/object-curly-spacing': ['error', 'always'],
72+
'jsonc/object-property-newline': [
73+
'error',
74+
{ allowMultiplePropertiesPerLine: true },
75+
],
76+
'jsonc/quote-props': 'error',
77+
'jsonc/quotes': 'error',
78+
},
79+
5780
...overrides,
5881
},
5982
},

src/configs/svelte.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,22 @@ export async function svelte(
8787
},
8888
],
8989

90+
...{
91+
// format
92+
'style/no-trailing-spaces': 'off', // superseded by svelte/no-trailing-spaces
93+
'svelte/derived-has-same-inputs-outputs': 'error',
94+
'svelte/html-closing-bracket-spacing': 'error',
95+
'svelte/html-quotes': ['error', { prefer: 'single' }],
96+
'svelte/indent': [
97+
'error',
98+
{ alignAttributesVertically: true, indent: 2 },
99+
],
100+
'svelte/mustache-spacing': 'error',
101+
'svelte/no-spaces-around-equal-signs-in-attribute': 'error',
102+
'svelte/no-trailing-spaces': 'error',
103+
'svelte/spaced-html-comment': 'error',
104+
},
105+
90106
...overrides,
91107
},
92108
},

src/configs/vue.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ export async function vue(
132132
ignoreConstructors: false,
133133
},
134134
],
135-
'vue/padding-line-between-blocks': ['error', 'always'],
136135
'vue/prefer-separate-static-class': 'error',
137136
'vue/prefer-template': 'error',
138137
'vue/prop-name-casing': ['error', 'camelCase'],
@@ -142,6 +141,47 @@ export async function vue(
142141
'vue/space-unary-ops': ['error', { nonwords: false, words: true }],
143142
'vue/valid-define-options': 'warn',
144143

144+
...{
145+
// format
146+
'vue/array-bracket-spacing': ['error', 'never'],
147+
'vue/arrow-spacing': ['error', { after: true, before: true }],
148+
'vue/block-spacing': ['error', 'always'],
149+
'vue/block-tag-newline': [
150+
'error',
151+
{
152+
multiline: 'always',
153+
singleline: 'always',
154+
},
155+
],
156+
'vue/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
157+
'vue/comma-dangle': ['error', 'always-multiline'],
158+
'vue/comma-spacing': ['error', { after: true, before: false }],
159+
'vue/comma-style': ['error', 'last'],
160+
'vue/html-comment-content-spacing': [
161+
'error',
162+
'always',
163+
{
164+
exceptions: ['-'],
165+
},
166+
],
167+
'vue/key-spacing': [
168+
'error',
169+
{ afterColon: true, beforeColon: false },
170+
],
171+
'vue/keyword-spacing': ['error', { after: true, before: true }],
172+
'vue/object-curly-newline': 'off',
173+
'vue/object-curly-spacing': ['error', 'always'],
174+
'vue/object-property-newline': [
175+
'error',
176+
{ allowMultiplePropertiesPerLine: true },
177+
],
178+
'vue/operator-linebreak': ['error', 'before'],
179+
'vue/padding-line-between-blocks': ['error', 'always'],
180+
'vue/quote-props': ['error', 'consistent-as-needed'],
181+
'vue/space-in-parens': ['error', 'never'],
182+
'vue/template-curly-spacing': 'error',
183+
},
184+
145185
...overrides,
146186
},
147187
},

src/types/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ export interface OptionsFormatters {
2828
*/
2929
css?: boolean
3030

31-
/**
32-
* Enable formatting support for Json.
33-
*/
34-
json?: boolean
35-
3631
/**
3732
* Enable formatting support for Markdown.
3833
*/
@@ -223,7 +218,6 @@ export interface OptionsConfig extends OptionsComponentExts {
223218
* {
224219
* "html": true,
225220
* "css": true,
226-
* "json": true,
227221
* "graphql": false,
228222
* "markdown": false
229223
* "yaml": false

0 commit comments

Comments
 (0)