Recently integrated Vue into an existing project and encountered a peculiar linting error:
error: 'components' is not defined (no-undef) at src/App.vue:13:3:
11 |
12 | @Component({
> 13 | components: { HelloWorld },
| ^
14 | })
15 | export default class App extends Vue {}
16 | </script>
This issue persists whenever I add any other attribute to the object.
Eslint Configuration
// .eslintrc.js
module.exports = {
root: true,
env: {
node: true,
},
extends: [
"eslint:recommended",
"plugin:vue/essential",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint",
],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"@typescript-eslint/explicit-member-accessibility": ["error"],
},
overrides: [
{
files: [
"**/__tests__/*.{j,t}s?(x)",
"**/tests/unit/**/*.spec.{j,t}s?(x)",
],
env: {
mocha: true,
},
},
],
};
Package.json
"eslint": "^7.18.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
Typescript
Using typescript in this setup for your information.