vuejs / eslint-config-typescript

eslint-config-typescript for vue projects
MIT License
115 stars 27 forks source link

Error while loading rule '@typescript-eslint/naming-convention' #44

Open VinceFanZ opened 2 years ago

VinceFanZ commented 2 years ago

Hi,

"@vue/eslint-config-typescript": "^11.0.0",

I set the rules.

.eslintrc.js:

module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: [
    'plugin:vue/vue3-essential',
    'plugin:vue-pug/vue3-recommended',
    '@vue/standard',
    '@vue/eslint-config-typescript/recommended'
  ],
  parserOptions: {
    ecmaVersion: 2020
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'prefer-regex-literals': 'off',
    'multiline-ternary': 'off',
    indent: ['error', 2, { SwitchCase: 1, ignoredNodes: ['PropertyDefinition'] }],
    'space-before-function-paren': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/camelcase': 'off',
    camelcase: 'off',
    '@typescript-eslint/member-delimiter-style': 'off',
    '@typescript-eslint/no-use-before-define': 'off',
    '@typescript-eslint/no-var-requires': 'off',
    '@typescript-eslint/no-inferrable-types': 'off',
    '@typescript-eslint/naming-convention': [
      'warn',
      {
        selector: 'interface',
        format: ['PascalCase'],
        custom: {
          regex: '^I[A-Z]',
          match: true
        },
        filter: {
          regex: '[wW]indow',
          match: false
        }
      }
    ],
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    'vue/multi-word-component-names': 'off',
    'vue/no-reserved-component-names': 'off',
    'vue/return-in-computed-property': 'warn'
  }
}

The result lint reported an error.

npm run lint 

> vue-cli-service lint

 ERROR  Error: Error while loading rule '@typescript-eslint/naming-convention': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
        Occurred while linting /Users/test/.eslintrc.js
brc-dd commented 2 years ago

Experiencing same issue. This is the commit that broke this: 8c3628cc43ce93c197d1f6b749712d2c0b2ebe4e. Using the previous commit is working fine:

"@vue/eslint-config-typescript": "github:vuejs/eslint-config-typescript#c32ab92"
freakzlike commented 2 years ago

I fixed my error by setting the parserOptions.parser inside the .eslintrc.js:

parserOptions: {
  parser: '@typescript-eslint/parser'
},
antonkulakov-it commented 9 months ago

works for me: adding to .eslintrc.js

parserOptions: {
  parser: 'tsconfig.json'
},