Skip to content

Add ESLint Processor to differentiate Vue SFC <script> langs to apply different rules, parsers, etc. #1910

Open
@DrJume

Description

@DrJume

Tell us about your environment

  • ESLint version: 8.17.0
  • eslint-plugin-vue version: 9.1.0
  • Node version: 16.15.1

The problem you want to solve.

It would be awesome to be able to filter .vue with lang="ts" in ESLint overrides.
Currently, it seems to be not possible.

But if there was an ESLint Processor for Vue, it would be possible to filter for the <script> lang (or even <template>?):
https://eslint.org/docs/user-guide/configuring/plugins#specifying-processor.

Your take on the correct solution to problem.

Implement an ESLint Processor for Vue SFCs.
Something like the following could be possible?

.eslintrc.js

{
    plugin: 'vue',
    processor: 'vue/sfc-processor',
    parser: 'vue-eslint-parser', // why not 'vue/parser'?
    overrides: [
        {
            files: ['*.vue'],
            rules: {
                // ...
            }
        },
        {
            files: ['**/*.vue/*.ts'],
            parser: '@typescript-eslint/parser',
            extends: [
                'plugin:@typescript-eslint/recommended',
                'plugin:@typescript-eslint/recommended-requiring-type-checking',
            ]
        }
    ]
}

Additional context

Addresses:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions