@@ -28,10 +28,11 @@ const extendsCategories = {
28
28
'vue3-use-with-caution' : 'vue3-recommended'
29
29
}
30
30
31
- function formatRules ( rules , categoryId ) {
31
+ function formatRules ( rules , categoryId , alwaysError ) {
32
32
const obj = Object . fromEntries (
33
33
rules . map ( ( rule ) => {
34
- let options = errorCategories . has ( categoryId ) ? 'error' : 'warn'
34
+ let options =
35
+ alwaysError || errorCategories . has ( categoryId ) ? 'error' : 'warn'
35
36
const defaultOptions =
36
37
rule . meta && rule . meta . docs && rule . meta . docs . defaultOptions
37
38
if ( defaultOptions ) {
@@ -47,8 +48,17 @@ function formatRules(rules, categoryId) {
47
48
return JSON . stringify ( obj , null , 2 )
48
49
}
49
50
50
- function formatCategory ( category ) {
51
- const extendsCategoryId = extendsCategories [ category . categoryId ]
51
+ function hasWarningRules ( categoryId ) {
52
+ return (
53
+ categoryId !== 'base' &&
54
+ categoryId !== 'vue3-essential' &&
55
+ categoryId !== 'vue2-essential'
56
+ )
57
+ }
58
+
59
+ function formatCategory ( category , alwaysError = false ) {
60
+ let extendsCategoryId = extendsCategories [ category . categoryId ]
61
+
52
62
if ( category . categoryId === 'base' ) {
53
63
return `/*
54
64
* IMPORTANT!
@@ -79,12 +89,17 @@ module.exports = [
79
89
parser: require('vue-eslint-parser'),
80
90
sourceType: 'module',
81
91
},
82
- rules: ${ formatRules ( category . rules , category . categoryId ) } ,
92
+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) } ,
83
93
processor: 'vue/vue'
84
94
}
85
95
]
86
96
`
87
97
}
98
+
99
+ if ( alwaysError && hasWarningRules ( extendsCategoryId ) ) {
100
+ extendsCategoryId += '-error'
101
+ }
102
+
88
103
return `/*
89
104
* IMPORTANT!
90
105
* This file has been automatically generated,
@@ -97,7 +112,7 @@ module.exports = [
97
112
...config,
98
113
{
99
114
name: 'vue/${ category . categoryId . replace ( / ^ v u e 3 - / u, '' ) } /rules',
100
- rules: ${ formatRules ( category . rules , category . categoryId ) } ,
115
+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) } ,
101
116
}
102
117
]
103
118
`
@@ -110,6 +125,13 @@ for (const category of categories) {
110
125
const content = formatCategory ( category )
111
126
112
127
fs . writeFileSync ( filePath , content )
128
+
129
+ if ( hasWarningRules ( category . categoryId ) ) {
130
+ fs . writeFileSync (
131
+ path . join ( ROOT , `${ category . categoryId } -error.js` ) ,
132
+ formatCategory ( category , true )
133
+ )
134
+ }
113
135
}
114
136
115
137
// Format files.
0 commit comments