diff --git a/lib/rules/no-restricted-component-options.js b/lib/rules/no-restricted-component-options.js
index f50f091d5..5af68053c 100644
--- a/lib/rules/no-restricted-component-options.js
+++ b/lib/rules/no-restricted-component-options.js
@@ -173,13 +173,25 @@ module.exports = {
/** @type {ParsedOption[]} */
const options = context.options.map(parseOption)
- return utils.defineVueVisitor(context, {
- onVueObjectEnter(node) {
- for (const option of options) {
- verify(node, option.test, option.message)
+ return utils.compositingVisitors(
+ utils.defineVueVisitor(context, {
+ onVueObjectEnter(node) {
+ for (const option of options) {
+ verify(node, option.test, option.message)
+ }
}
- }
- })
+ }),
+ utils.defineScriptSetupVisitor(context, {
+ onDefineOptionsEnter(node) {
+ if (node.arguments.length === 0) return
+ const define = node.arguments[0]
+ if (define.type !== 'ObjectExpression') return
+ for (const option of options) {
+ verify(define, option.test, option.message)
+ }
+ }
+ })
+ )
/**
* @param {ObjectExpression} node
diff --git a/tests/lib/rules/no-restricted-component-options.js b/tests/lib/rules/no-restricted-component-options.js
index 87ff4e41f..484f6700c 100644
--- a/tests/lib/rules/no-restricted-component-options.js
+++ b/tests/lib/rules/no-restricted-component-options.js
@@ -101,6 +101,11 @@ tester.run('no-restricted-component-options', rule, {
`,
options: [['foo', 'bar']]
+ },
+ {
+ filename: 'test.vue',
+ code: ``,
+ options: ['Foo']
}
],
invalid: [
@@ -304,6 +309,17 @@ tester.run('no-restricted-component-options', rule, {
line: 5
}
]
+ },
+ {
+ filename: 'test.vue',
+ code: ``,
+ options: ['Foo'],
+ errors: [
+ {
+ message: 'Using `Foo` is not allowed.',
+ line: 1
+ }
+ ]
}
]
})