1
1
import { TSESLint } from '@typescript-eslint/utils' ;
2
+ // @ts -expect-error .d.ts file for eslint-plugin-vue has been implemented but not released yet
3
+ // if the following line fails to build after updating the version, simply remove this comment
4
+ import pluginVue from 'eslint-plugin-vue' ;
2
5
3
- const htmlIndent = 4 ;
6
+ // .d.ts file for eslint-plugin-vue has been implemented but not released yet, if the
7
+ // following line fails to build after updating the version, simply remove this comment
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/consistent-type-assertions
9
+ const recommendedConfigArray = pluginVue . configs [ 'flat/recommended' ] as TSESLint . FlatConfig . ConfigArray ;
10
+ const recommendedRules = recommendedConfigArray
11
+ . reduce < Record < string , TSESLint . Linter . RuleEntry | undefined > > ( ( acc , config ) => ( { ...acc , ...config . rules } ) , { } ) ;
12
+ const updatedRules = Object . entries < TSESLint . Linter . RuleEntry | undefined > ( recommendedRules )
13
+ . filter ( ( entry ) : entry is [ string , TSESLint . Linter . RuleEntry ] => entry [ 1 ] != null )
14
+ . map ( ( [ key , value ] ) => [ key , warningEntryToError ( value ) ] ) ;
4
15
5
16
export const vueRules : TSESLint . Linter . RulesRecord = {
17
+ // yes, we know this works correctly
18
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
19
+ ...Object . fromEntries ( updatedRules ) as TSESLint . Linter . RulesRecord ,
6
20
'vue/block-lang' : [
7
21
'error' ,
8
22
{
@@ -24,7 +38,30 @@ export const vueRules: TSESLint.Linter.RulesRecord = {
24
38
} ,
25
39
] ,
26
40
'vue/html-button-has-type' : 'error' ,
27
- 'vue/html-indent' : [ 'error' , htmlIndent ] ,
28
41
'vue/no-ref-object-destructure' : 'error' ,
29
42
'vue/no-undef-properties' : 'error' ,
43
+ // disable stylistic rules
44
+ 'vue/html-indent' : 'off' ,
45
+ 'vue/max-attributes-per-line' : 'off' ,
46
+ 'vue/html-self-closing' : 'off' ,
47
+ 'vue/singleline-html-element-content-newline' : 'off' ,
48
+ 'vue/multiline-html-element-content-newline' : 'off' ,
49
+ 'vue/html-closing-bracket-newline' : 'off' ,
30
50
} ;
51
+
52
+ function warningEntryToError ( value : TSESLint . Linter . RuleEntry ) : TSESLint . Linter . RuleEntry {
53
+ const level = Array . isArray ( value ) ? value [ 0 ] : value ;
54
+ const updatedLevel = warningLevelToError ( level ) ;
55
+
56
+ return Array . isArray ( value ) ? [ updatedLevel , ...value . slice ( 1 ) ] : updatedLevel ;
57
+ }
58
+
59
+ function warningLevelToError ( level : TSESLint . Linter . RuleLevel ) : TSESLint . Linter . RuleLevel {
60
+ if ( level === 'warn' ) {
61
+ return 'error' ;
62
+ } else if ( level === 1 ) {
63
+ return 'error' ;
64
+ }
65
+
66
+ return level ;
67
+ }
0 commit comments