tenado
tenado

Reputation: 109

ESlint doesn't work on .vue file with typescript

I had build my project with vue ui, this is my package.json

"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-typescript": "^4.1.0",
"@vue/eslint-config-standard": "^4.0.0",
"@vue/eslint-config-typescript": "^4.0.0",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^6.0.1",
"typescript": "~3.5.3",

this is my .eslintrc.js file

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/essential',
    '@vue/standard',
    '@vue/typescript'
  ],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    "indent": ['error', 4]
  },
  parserOptions: {
    parser: '@typescript-eslint/parser'
  },
  overrides: [
    {
      files: [
        '**/__tests__/*.{j,t}s?(x)',
        '**/tests/unit/**/*.spec.{j,t}s?(x)'
      ],
      env: {
        jest: true
      }
    }
  ]
}

And this is my visual studio code setting, settings.json

{
  "eslint.alwaysShowStatus": true,
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
      "javascript",
      "javascriptreact",
      { "language": "vue", "autoFix": true },
      { "language": "typescript", "autoFix": true },
      { "language": "typescriptreact", "autoFix": true }
  ]
}

it works fine on .ts file, but do not on .vue file (class without any eslint tips). so what should i do to fix it, any ideas ?

Upvotes: 4

Views: 3678

Answers (1)

Milesq
Milesq

Reputation: 378

How do you run eslint? In the .eslintrc.json file you did not declare eslint to read .vue files. You should run eslint with --ext flag. (eslnit . --ext .vue)

Upvotes: 1

Related Questions