@@ -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,17 @@ 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 ]
61+
5262 if ( category . categoryId === 'base' ) {
5363 return `/*
5464 * IMPORTANT!
@@ -79,12 +89,17 @@ module.exports = [
7989 parser: require('vue-eslint-parser'),
8090 sourceType: 'module',
8191 },
82- rules: ${ formatRules ( category . rules , category . categoryId ) } ,
92+ rules: ${ formatRules ( category . rules , category . categoryId , alwaysError ) } ,
8393 processor: 'vue/vue'
8494 }
8595]
8696`
8797 }
98+
99+ if ( alwaysError && hasWarningRules ( extendsCategoryId ) ) {
100+ extendsCategoryId += '-error'
101+ }
102+
88103 return `/*
89104 * IMPORTANT!
90105 * This file has been automatically generated,
@@ -97,7 +112,7 @@ module.exports = [
97112 ...config,
98113 {
99114 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 ) } ,
101116 }
102117]
103118`
@@ -110,6 +125,13 @@ for (const category of categories) {
110125 const content = formatCategory ( category )
111126
112127 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+ }
113135}
114136
115137// Format files.
0 commit comments