@@ -28,10 +28,11 @@ const extendsCategories = {
2828 'vue3-use-with-caution' : 'vue3-recommended'
2929}
3030
31- function formatRules ( rules , categoryId ) {
31+ function formatRules ( rules , categoryId , alwaysError ) {
3232 const obj = Object . fromEntries (
3333 rules . map ( ( rule ) => {
34- let options = errorCategories . has ( categoryId ) ? 'error' : 'warn'
34+ let options =
35+ alwaysError || errorCategories . has ( categoryId ) ? 'error' : 'warn'
3536 const defaultOptions =
3637 rule . meta && rule . meta . docs && rule . meta . docs . defaultOptions
3738 if ( defaultOptions ) {
@@ -47,8 +48,16 @@ function formatRules(rules, categoryId) {
4748 return JSON . stringify ( obj , null , 2 )
4849}
4950
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 ]
5261 if ( extendsCategoryId == null ) {
5362 return `/*
5463 * IMPORTANT!
@@ -63,7 +72,7 @@ module.exports = {
6372 plugins: [
6473 'vue'
6574 ],
66- rules: ${ formatRules ( category . rules , category . categoryId ) } ,
75+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) } ,
6776 overrides: [
6877 {
6978 files: '*.vue',
@@ -73,14 +82,18 @@ module.exports = {
7382}
7483`
7584 }
85+ if ( alwaysError && hasWarningRules ( extendsCategoryId ) ) {
86+ extendsCategoryId += '-error'
87+ }
88+
7689 return `/*
7790 * IMPORTANT!
7891 * This file has been automatically generated,
7992 * in order to update its content execute "npm run update"
8093 */
8194module.exports = {
8295 extends: require.resolve('./${ extendsCategoryId } '),
83- rules: ${ formatRules ( category . rules , category . categoryId ) }
96+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) }
8497}
8598`
8699}
@@ -92,6 +105,13 @@ for (const category of categories) {
92105 const content = formatCategory ( category )
93106
94107 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+ }
95115}
96116
97117// Format files.
0 commit comments