@@ -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,16 @@ 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 ]
52
61
if ( extendsCategoryId == null ) {
53
62
return `/*
54
63
* IMPORTANT!
@@ -63,7 +72,7 @@ module.exports = {
63
72
plugins: [
64
73
'vue'
65
74
],
66
- rules: ${ formatRules ( category . rules , category . categoryId ) } ,
75
+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) } ,
67
76
overrides: [
68
77
{
69
78
files: '*.vue',
@@ -73,14 +82,18 @@ module.exports = {
73
82
}
74
83
`
75
84
}
85
+ if ( alwaysError && hasWarningRules ( extendsCategoryId ) ) {
86
+ extendsCategoryId += '-error'
87
+ }
88
+
76
89
return `/*
77
90
* IMPORTANT!
78
91
* This file has been automatically generated,
79
92
* in order to update its content execute "npm run update"
80
93
*/
81
94
module.exports = {
82
95
extends: require.resolve('./${ extendsCategoryId } '),
83
- rules: ${ formatRules ( category . rules , category . categoryId ) }
96
+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) }
84
97
}
85
98
`
86
99
}
@@ -92,6 +105,13 @@ for (const category of categories) {
92
105
const content = formatCategory ( category )
93
106
94
107
fs . writeFileSync ( filePath , content )
108
+
109
+ if ( hasWarningRules ( category . categoryId ) ) {
110
+ fs . writeFileSync (
111
+ path . join ( ROOT , `${ category . categoryId } -error.js` ) ,
112
+ formatCategory ( category , true )
113
+ )
114
+ }
95
115
}
96
116
97
117
// Format files.
0 commit comments