Skip to content

Commit cc7452d

Browse files
committed
refactor(no-import-compiler-macros): check only in <script setup>
1 parent 553abe6 commit cc7452d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/rules/no-import-compiler-macros.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55
'use strict'
66

7+
const utils = require('../utils')
8+
79
const COMPILER_MACROS = new Set([
810
'defineProps',
911
'defineEmits',
@@ -43,9 +45,13 @@ module.exports = {
4345
* @returns {RuleListener}
4446
*/
4547
create(context) {
48+
const scriptSetup = utils.getScriptSetupElement(context)
49+
if (!scriptSetup) {
50+
return {}
51+
}
4652
const sourceCode = context.getSourceCode()
4753

48-
return {
54+
return utils.defineScriptSetupVisitor(context, {
4955
ImportDeclaration(node) {
5056
if (node.specifiers.length === 0 || !VUE_MODULES.has(node.source.value))
5157
return
@@ -96,6 +102,6 @@ module.exports = {
96102
})
97103
}
98104
}
99-
}
105+
})
100106
}
101107
}

0 commit comments

Comments
 (0)