diff --git a/README.md b/README.md index 4ef106767..7fb35d5dd 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ module.exports = { All component-related rules are being applied to code that passes any of the following checks: * `Vue.component()` expression +* `Vue.extend()` expression +* `Vue.mixin()` expression * `export default {}` in `.vue` or `.jsx` file If you however want to take advantage of our rules in any of your custom objects that are Vue components, you might need to use special comment `// @vue/component` that marks object in the next line as a Vue component in any file, e.g.: diff --git a/lib/utils/index.js b/lib/utils/index.js index 4667c437d..4f03abd23 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -384,7 +384,7 @@ module.exports = { callee.object.type === 'Identifier' && callee.object.name === 'Vue' && callee.property.type === 'Identifier' && - (callee.property.name === 'component' || callee.property.name === 'mixin') && + ['component', 'mixin', 'extend'].indexOf(callee.property.name) > -1 && node.arguments.length && node.arguments.slice(-1)[0].type === 'ObjectExpression' diff --git a/tests/lib/utils/vue-component.js b/tests/lib/utils/vue-component.js index 0dd2d0cf3..87b8738af 100644 --- a/tests/lib/utils/vue-component.js +++ b/tests/lib/utils/vue-component.js @@ -126,6 +126,12 @@ function invalidTests (ext) { parserOptions, errors: [makeError(1)] }, + { + filename: `test.${ext}`, + code: `Vue.extend({})`, + parserOptions, + errors: [makeError(1)] + }, { filename: `test.${ext}`, code: `