Skip to content

Commit 24b6862

Browse files
committedApr 5, 2024·
feat(eslint-config): improve vue stylistic settings
1 parent 004f972 commit 24b6862

File tree

3 files changed

+68
-26
lines changed

3 files changed

+68
-26
lines changed
 

Diff for: ‎docs/pages/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ watch(projectsSectionVisible, () => {
114114
:ui="{
115115
to: 'hover:ring-2 dark:hover:ring-gray-500 hover:ring-gray-500 hover:bg-gray-100/50',
116116
icon: { base: 'w-10 h-10 flex-shrink-0 text-gray-100' },
117-
body: { base: 'h-full', background: 'bg-gradient-to-b from-gray-900 to-gray-950' }
117+
body: { base: 'h-full', background: 'bg-gradient-to-b from-gray-900 to-gray-950' },
118118
}"
119119
/>
120120
</UPageGrid>

Diff for: ‎packages/eslint-config/src/flat/configs/typescript.ts

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@ export default function typescript(options: NuxtESLintConfigOptions): FlatConfig
3535
? {}
3636
: pluginTs.configs.strict.rules),
3737

38+
// Include typescript eslint rules in *.vue files
39+
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
40+
'constructor-super': 'off', // ts(2335) & ts(2377)
41+
'getter-return': 'off', // ts(2378)
42+
'no-const-assign': 'off', // ts(2588)
43+
'no-dupe-args': 'off', // ts(2300)
44+
'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
45+
'no-dupe-keys': 'off', // ts(1117)
46+
'no-func-assign': 'off', // ts(2539)
47+
'no-import-assign': 'off', // ts(2539) & ts(2540)
48+
'no-new-symbol': 'off', // ts(7009)
49+
'no-obj-calls': 'off', // ts(2349)
50+
'no-redeclare': 'off', // ts(2451)
51+
'no-setter-return': 'off', // ts(2408)
52+
'no-this-before-super': 'off', // ts(2376)
53+
'no-undef': 'off', // ts(2304)
54+
'no-unreachable': 'off', // ts(7027)
55+
'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358)
56+
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
57+
'prefer-const': 'error', // ts provides better types with const
58+
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
59+
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
60+
'valid-typeof': 'off', // ts(2367)
61+
3862
'@typescript-eslint/no-non-null-assertion': 'off',
3963
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false, prefer: 'type-imports' }],
4064
},

Diff for: ‎packages/eslint-config/src/flat/configs/vue.ts

+43-25
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default function vue(options: NuxtESLintConfigOptions): FlatConfigItem[]
1111
const resolved = resolveOptions(options)
1212
const hasTs = resolved.features.typescript !== false
1313

14+
const {
15+
indent = 2,
16+
commaDangle = 'always-multiline',
17+
} = typeof resolved.features.stylistic === 'boolean' ? {} : resolved.features.stylistic
18+
1419
return [
1520
{
1621
name: 'nuxt/vue/setup',
@@ -68,32 +73,45 @@ export default function vue(options: NuxtESLintConfigOptions): FlatConfigItem[]
6873
'vue/component-tags-order': undefined,
6974
'vue/block-order': 'warn',
7075

71-
// Include typescript eslint rules in *.vue files
72-
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended.ts
73-
'constructor-super': 'off', // ts(2335) & ts(2377)
74-
'getter-return': 'off', // ts(2378)
75-
'no-const-assign': 'off', // ts(2588)
76-
'no-dupe-args': 'off', // ts(2300)
77-
'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
78-
'no-dupe-keys': 'off', // ts(1117)
79-
'no-func-assign': 'off', // ts(2539)
80-
'no-import-assign': 'off', // ts(2539) & ts(2540)
81-
'no-new-symbol': 'off', // ts(7009)
82-
'no-obj-calls': 'off', // ts(2349)
83-
'no-redeclare': 'off', // ts(2451)
84-
'no-setter-return': 'off', // ts(2408)
85-
'no-this-before-super': 'off', // ts(2376)
86-
'no-undef': 'off', // ts(2304)
87-
'no-unreachable': 'off', // ts(7027)
88-
'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358)
89-
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
90-
'prefer-const': 'error', // ts provides better types with const
91-
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
92-
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
93-
'valid-typeof': 'off', // ts(2367)
94-
9576
...(resolved.features.stylistic
96-
? {}
77+
? {
78+
'vue/array-bracket-spacing': ['error', 'never'],
79+
'vue/arrow-spacing': ['error', { after: true, before: true }],
80+
'vue/block-spacing': ['error', 'always'],
81+
'vue/block-tag-newline': [
82+
'error',
83+
{
84+
multiline: 'always',
85+
singleline: 'always',
86+
},
87+
],
88+
'vue/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
89+
'vue/html-indent': ['error', indent],
90+
'vue/html-quotes': ['error', 'double'],
91+
'vue/comma-dangle': ['error', commaDangle],
92+
'vue/comma-spacing': ['error', { after: true, before: false }],
93+
'vue/comma-style': ['error', 'last'],
94+
'vue/html-comment-content-spacing': [
95+
'error',
96+
'always',
97+
{ exceptions: ['-'] },
98+
],
99+
'vue/key-spacing': ['error', { afterColon: true, beforeColon: false }],
100+
'vue/keyword-spacing': ['error', { after: true, before: true }],
101+
'vue/object-curly-newline': 'off',
102+
'vue/object-curly-spacing': ['error', 'always'],
103+
'vue/object-property-newline': [
104+
'error',
105+
{ allowMultiplePropertiesPerLine: true },
106+
],
107+
'vue/one-component-per-file': 'off',
108+
'vue/operator-linebreak': ['error', 'before'],
109+
'vue/padding-line-between-blocks': ['error', 'always'],
110+
'vue/quote-props': ['error', 'consistent-as-needed'],
111+
'vue/require-default-prop': 'off',
112+
'vue/space-in-parens': ['error', 'never'],
113+
'vue/template-curly-spacing': 'error',
114+
}
97115
: {
98116
// Disable Vue's default stylistic rules when stylistic is not enabled
99117
'vue/html-closing-bracket-newline': undefined,

0 commit comments

Comments
 (0)
Please sign in to comment.