Skip to content

Commit c510184

Browse files
committed
refactor: reuse existing list
1 parent 3e9fb11 commit c510184

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

tools/update-lib-configs.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ function formatRules(rules, categoryId, alwaysError) {
4848
return JSON.stringify(obj, null, 2)
4949
}
5050

51-
function hasWarningRules(categoryId) {
52-
return (
53-
categoryId !== 'base' &&
54-
categoryId !== 'vue3-essential' &&
55-
categoryId !== 'vue2-essential'
56-
)
57-
}
58-
5951
function formatCategory(category, alwaysError = false) {
6052
let extendsCategoryId = extendsCategories[category.categoryId]
6153
if (extendsCategoryId == null) {
@@ -82,7 +74,7 @@ module.exports = {
8274
}
8375
`
8476
}
85-
if (alwaysError && hasWarningRules(extendsCategoryId)) {
77+
if (alwaysError && !errorCategories.has(extendsCategoryId)) {
8678
extendsCategoryId += '-error'
8779
}
8880

@@ -106,7 +98,7 @@ for (const category of categories) {
10698

10799
fs.writeFileSync(filePath, content)
108100

109-
if (hasWarningRules(category.categoryId)) {
101+
if (!errorCategories.has(category.categoryId)) {
110102
fs.writeFileSync(
111103
path.join(ROOT, `${category.categoryId}-error.js`),
112104
formatCategory(category, true)

tools/update-lib-flat-configs.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ function formatRules(rules, categoryId, alwaysError) {
4848
return JSON.stringify(obj, null, 2)
4949
}
5050

51-
function hasWarningRules(categoryId) {
52-
return (
53-
categoryId !== 'base' &&
54-
categoryId !== 'vue3-essential' &&
55-
categoryId !== 'vue2-essential'
56-
)
57-
}
58-
5951
function formatCategory(category, alwaysError = false) {
6052
let extendsCategoryId = extendsCategories[category.categoryId]
6153

@@ -96,7 +88,7 @@ module.exports = [
9688
`
9789
}
9890

99-
if (alwaysError && hasWarningRules(extendsCategoryId)) {
91+
if (alwaysError && !errorCategories.has(extendsCategoryId)) {
10092
extendsCategoryId += '-error'
10193
}
10294

@@ -126,7 +118,7 @@ for (const category of categories) {
126118

127119
fs.writeFileSync(filePath, content)
128120

129-
if (hasWarningRules(category.categoryId)) {
121+
if (!errorCategories.has(category.categoryId)) {
130122
fs.writeFileSync(
131123
path.join(ROOT, `${category.categoryId}-error.js`),
132124
formatCategory(category, true)

0 commit comments

Comments
 (0)