vuejs / language-tools

âš¡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.65k stars 375 forks source link

How to add your rules to my ESLint config? #3428

Open romanhrynevych opened 1 year ago

romanhrynevych commented 1 year ago

I have searched that your package is now out of the box inside WebStorm 2023.2 beta build 232.8660.7

image

Your linter starts show me errors that i previously don't see at all 🙂

image

But if I run lint command, i don't see them inside it, how can I update my config?

image

My .eslintrc.cjs is slightly big, but it is here 👇 :

module.exports = {
  env: {
    browser: true,
    es2021: true,
    node: true,
  },
  extends: [
    'plugin:vue/vue3-recommended',
    'eslint:recommended',
    '@vue/typescript/recommended',
    'prettier',
    'plugin:storybook/recommended',
    'plugin:@typescript-eslint/strict',
    'plugin:@typescript-eslint/strict-type-checked',
  ],
  overrides: [],
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: {
      js: '@typescript-eslint/parser',
      ts: '@typescript-eslint/parser',
      '<template>': 'espree',
    },
    ecmaVersion: 2015,
    sourceType: 'module',
    allowImportExportEverywhere: true,
    project: true,
    tsconfigRootDir: __dirname,
  },
  plugins: ['@typescript-eslint', 'prettier', 'simple-import-sort'],
  rules: {
    'vue/require-default-prop': 'off',
    'vue/no-v-model-argument': 'off',
    'vue/multi-word-component-names': 'off',
    'vue/no-multiple-template-root': 0,
    'vue/component-name-in-template-casing': [
      'error',
      'kebab-case',
      {
        registeredComponentsOnly: true,
      },
    ],
    '@typescript-eslint/await-thenable': 'off',
    '@typescript-eslint/no-unsafe-return': 'off',
    '@typescript-eslint/no-for-in-array': 'error',
    '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
    '@typescript-eslint/array-type': [
      'error',
      { default: 'array-simple', readonly: 'array-simple' },
    ],
    '@typescript-eslint/prefer-optional-chain': 'error',
    'no-implied-eval': 'off',
    '@typescript-eslint/no-implied-eval': 'error',
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': 'error',
    'require-await': 'off',
    '@typescript-eslint/require-await': 'error',
    'default-param-last': ['error'],
    '@typescript-eslint/consistent-type-imports': [
      'error',
      {
        prefer: 'type-imports',
      },
    ],
    'no-restricted-imports': [
      'error',
      {
        patterns: ['../'],
      },
    ],
    '@typescript-eslint/no-duplicate-enum-values': 'error',
    '@typescript-eslint/no-duplicate-type-constituents': 'error',
    '@typescript-eslint/no-inferrable-types': 'error',
    '@typescript-eslint/method-signature-style': ['error', 'property'],
    '@typescript-eslint/naming-convention': [
      'error',
      {
        selector: 'variable',
        types: ['boolean'],
        format: ['PascalCase'],
        prefix: ['is', 'should', 'has', 'can', 'did', 'will'],
      },
      {
        selector: 'typeParameter',
        format: ['PascalCase'],
        prefix: ['T'],
      },
      {
        selector: 'interface',
        format: ['PascalCase'],
        custom: {
          regex: '^I[A-Z]',
          match: false,
        },
      },
      {
        selector: ['variable', 'function'],
        format: ['camelCase'],
        leadingUnderscore: 'allow',
      },
    ],
    'vue/block-lang': [
      'error',
      {
        script: {
          lang: 'ts',
        },
      },
    ],
    'vue/define-props-declaration': ['error', 'type-based'],
    'vue/new-line-between-multi-line-property': [
      'error',
      {
        minLineOfMultilineProperty: 4,
      },
    ],
    'vue/padding-line-between-tags': [
      'error',
      [{ blankLine: 'always', prev: '*', next: '*' }],
    ],
    'simple-import-sort/imports': [
      'error',
      {
        groups: [
          // Packages `Vue` related packages come first.
          ['^vue', '^@?\\w'],
          // Components
          ['^@/components?\\w'],
          // Enums
          ['^@/ts/enums?\\w'],
          // Interfaces
          ['^@/ts/interfaces?\\w'],
          // Utils
          ['^@/utils?\\w'],
          // Store
          ['^pinia', '^@/stores?\\w'],
          // Absolute imports and other imports such as Vue-style `@/foo`.
          // Anything not matched in another group.
          ['^'],
          // Relative imports.
          // Anything that starts with a dot.
          ['^\\.'],
        ],
      },
    ],
    'simple-import-sort/exports': 'error',
  },
  root: true,
};
xiaoxiangmoe commented 1 year ago

This error cannot be reported by eslint.

If you want the ability to report these kinds of errors in cli, you should consider configuring vue-tsc.

Here is a sample project https://github.com/vuejs/create-vue. This project is configured with vue-tsc, hope it can help you.

romanhrynevych commented 1 year ago

@xiaoxiangmoe Thanks, but i don't see any normal readme how to config that plugin, for example add scope for directories and file extensions, maybe there is another link with extended Docs?

davidmatter commented 3 weeks ago

Do you still require support or can this be closed?