Skip to content

Commit 5ba7106

Browse files
committed
feat(no-deprecated-imports): add new rule
1 parent 7dcc889 commit 5ba7106

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/configs/base.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ module.exports = {
1515
'vuetify/no-deprecated-events': 'error',
1616
'vuetify/no-deprecated-props': 'error',
1717
'vuetify/no-deprecated-slots': 'error',
18+
'vuetify/no-deprecated-imports': 'error',
1819
},
1920
}

src/rules/no-deprecated-imports.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
meta: {
3+
type: 'problem',
4+
docs: {
5+
description: 'disallow import from "vuetify/lib/util/colors", suggest "vuetify/util/colors" instead',
6+
category: 'Best Practices',
7+
recommended: false,
8+
},
9+
fixable: 'code',
10+
schema: [],
11+
},
12+
create (context) {
13+
return {
14+
ImportDeclaration (node) {
15+
const source = node.source.value
16+
if (source === 'vuetify/lib/util/colors') {
17+
context.report({
18+
node,
19+
message: 'Import from "vuetify/lib/util/colors" is deprecated. Use "vuetify/util/colors" instead.',
20+
fix (fixer) {
21+
const fixedSource = source.replace('vuetify/lib/util/colors', 'vuetify/util/colors')
22+
return fixer.replaceText(node.source, `'${fixedSource}'`)
23+
},
24+
})
25+
}
26+
},
27+
}
28+
},
29+
}

0 commit comments

Comments
 (0)