Skip to content

Parsing fails on scriptless Vue files with typescript-eslint parser #125

Closed
@MatthiasKunnen

Description

@MatthiasKunnen

When using an eslint config that specifies parserOptions.parser.ts, eslint errors while parsing files that do not have at least an empty <script lang="ts"></script>.

The eslint error is:

Error: Error while loading rule '@typescript-eslint/await-thenable': 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 /src/error.vue
    at Object.getParserServices (/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/getParserServices.js:16:15)
    at create (/node_modules/@typescript-eslint/eslint-plugin/dist/rules/await-thenable.js:41:37)
    at Object.create (/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/RuleCreator.js:13:24)
    at createRuleListeners (/node_modules/eslint/lib/linter/linter.js:761:21)
    at /node_modules/eslint/lib/linter/linter.js:931:31
    at Array.forEach (<anonymous>)
    at runRules (/node_modules/eslint/lib/linter/linter.js:876:34)
    at Linter._verifyWithoutProcessors (/node_modules/eslint/lib/linter/linter.js:1175:31)
    at Linter._verifyWithConfigArray (/node_modules/eslint/lib/linter/linter.js:1273:21)
    at Linter.verify (/node_modules/eslint/lib/linter/linter.js:1228:25)

Config:

module.exports = {
    env: {
        es6: true,
        browser: true,
        node: true,
    },
    overrides: [
        {
            files: [
                '*.vue',
            ],
            plugins: [
                'vue', // With or without this, the error occurs
                '@typescript-eslint',
            ],
            parser: 'vue-eslint-parser',
            parserOptions: {
                parser: {
                    '<template>': 'espree',
                    ts: '@typescript-eslint/parser',
                },
                project: ['./tsconfig.json'],
                extraFileExtensions: ['.vue'],
            },
            rules: {
                '@typescript-eslint/await-thenable': 'error',
            },
        },
    ],
}

Reproduction: https://github.com/MatthiasKunnen/eslint-plugin-vue-ts-script.

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