Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue-eslint-parser and typescript-eslint problems #104

Open
yoyo930021 opened this issue Mar 5, 2021 · 57 comments
Open

vue-eslint-parser and typescript-eslint problems #104

yoyo930021 opened this issue Mar 5, 2021 · 57 comments

Comments

@yoyo930021
Copy link
Member

yoyo930021 commented Mar 5, 2021

Reason: typescript-eslint/typescript-eslint#2865 (comment)

Hi, I'm using vue-eslint-parser and typescript-eslint in company project.
At the same time, I also help to contribute typescript-eslint project for fixing vue problems.

This problems are only happens when using type rules in typescript-eslint.
You need to add parserOptions.project in project to enable it.
https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md

There are two main issues:

performance issue

issues: #65, typescript-eslint/typescript-eslint#1180

The problem is that vue-eslint-parser is designed with the AST not type information.
The vue-eslint-parser will split code frame from template to @typescript-eslint/parser.
typescript-eslint/typescript-eslint#1180 (comment)
Typescript program need to parse full project for generate type information.
When parsing code frame, typescript program will reparse file AST and rebuild type information in project.
The vue-eslint-parser will pass more code frames and same file path in single Vue SFC.

Possible solutions:

  1. Ignore parserOptions.project to close get type information when pass code frame.
  2. Try to use ESLint processors, like Svelte.
    Ref: Add fragment options to lint code fragment for Vue SFC performance typescript-eslint/typescript-eslint#1180 (comment)

[no-unsafe-*] rules

issues: typescript-eslint/typescript-eslint#2865

Strictly speaking, it isn't a problem with this project.
The typescript program can't parse Vue SFC file directly.

You may think it's strange, but why is it working now?
Because @typescript-eslint/parser will prioritize the content delivered from ESLint.
Typescript program will update by ESLint content not same as typescript program read.
But this problem is happens when ESLint not send file content and content from typescript program reading.
Example:

// App.vue
import HelloWorld from './components/HelloWorld.vue' // <- typescript program can't parse it. because it will read including template and style.

export default {
  name: 'App',
  components: {
    HelloWorld // <- so type information is `any`
  }
}

This problem will also have in <script setup> RFC.

Possible solutions:

  1. Override HelloWorld.vue content.
  2. Mock a HelloWorld.vue.ts file.

Maybe we need a common project for hacking typescript program.

Thanks for watching. Have a good day!

@ota-meshi
Copy link
Member

ota-meshi commented Mar 10, 2021

Thank you for organizing information.
(I take a long time to read English, so first I'm trying to understand performance issues. 😅)
I understand, thanks to your explanation, that the main cause is to call as many TS parsers as there are directives.

Ignore parserOptions.project to close get type information when pass code frame.

If this method solves the problem, I think it's the simplest change.
Is it possible for you to make this change and see if it improves performance?

Try to use ESLint processors, like Svelte.
Ref: typescript-eslint/typescript-eslint#1180 (comment)

I don't think we can use the ESLint processors.
It's difficult to change in vue-eslint-parser to do something similar to preprocessors, but I think it's more likely than ESLint processors.
As far as I can think of now, it's difficult to analyze variables in template scope.

@yoyo930021
Copy link
Member Author

yoyo930021 commented Mar 11, 2021

(I take a long time to read English, so first I'm trying to understand performance issues. 😅)

My English is poor. If you don't understand what do I talk about, maybe I can ask for help. 😅

Ignore parserOptions.project to close get type information when pass code frame.

If this method solves the problem, I think it's the simplest change.
Is it possible for you to make this change and see if it improves performance?

I will try again about this solution, and send a PR.
Maybe we can split two parser options for code frame and script. Ref: #65 (comment)

Try to use ESLint processors, like Svelte.
Ref: typescript-eslint/typescript-eslint#1180 (comment)

I don't think we can use the ESLint processors.
It's difficult to change in vue-eslint-parser to do something similar to preprocessors, but I think it's more likely than ESLint processors.
As far as I can think of now, it's difficult to analyze variables in template scope.

In the long run, we hope that the template can get the type information and rules.
There is actually no difference between parser and processors.
The parser also can compile templates to typescript and get type information with @typescript-eslint.
Perhaps the question is whether there is a need?

@mariusheine
Copy link

Are there any information, progress or ideas for the problem with the [no-unsafe-*] rules?

@JounQin
Copy link

JounQin commented Jul 6, 2021

@ota-meshi Even after #116, there is no way to only enable typescript rules for <script lang="ts">, right? Because we can only enable rules for *.vue files, not *.vue/*.ts.

@ota-meshi
Copy link
Member

I know it.
I wrote #116 as "Related" because it may solve the performance issue depending on how it is used.

@ota-meshi
Copy link
Member

I changed parserOptions.parser to allow multiple parsers.
If someone has an environment where they can try out performance issues, can you use the following configuration to see if it improves performance and share the results?

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

If performance improves, I think it's a useful workaround for many.

@tjk
Copy link

tjk commented Jul 13, 2021

@ota-meshi I tried your patch and it made a huge difference!

Before (~10 seconds):

$ npx eslint --debug --fix frontend-next/src/components/connection/filters/app-filter.vue
...
  eslint:cli-engine Lint .../frontend-next/src/components/connection/filters/app-filter.vue +0ms
  eslint:linter Linting code for .../frontend-next/src/components/connection/filters/app-filter.vue (pass 1) +0ms
  eslint:linter Verify +0ms
  eslint:linter With ConfigArray: .../frontend-next/src/components/connection/filters/app-filter.vue +0ms
  eslint:linter Apply the processor: 'vue/.vue' +0ms
  eslint:linter A code block was found: '(unnamed)' +1ms
  eslint:linter Generating fixed text for .../frontend-next/src/components/connection/filters/app-filter.vue (pass 1) +9s
...
.../frontend-next/src/components/connection/filters/app-filter.vue
  108:22  warning  The "update:value" event has been triggered but not declared on `emits` option  vue/require-explicit-emits

After (~instant):

$ npx eslint --debug --fix frontend-next/src/components/connection/filters/app-filter.vue
...
  eslint:cli-engine Lint .../frontend-next/src/components/connection/filters/app-filter.vue +0ms
  eslint:linter Linting code for .../frontend-next/src/components/connection/filters/app-filter.vue (pass 1) +0ms
  eslint:linter Verify +0ms
  eslint:linter With ConfigArray: .../frontend-next/src/components/connection/filters/app-filter.vue +1ms
  eslint:linter Apply the processor: 'vue/.vue' +0ms
  eslint:linter A code block was found: '(unnamed)' +0ms
  eslint:traverser Unknown node type "ChainExpression": Estimated visitor keys ["type","start","end","loc","range","expression"] +0ms
  eslint:linter Generating fixed text for .../frontend-next/src/components/connection/filters/app-filter.vue (pass 1) +135ms
...
.../frontend-next/src/components/connection/filters/app-filter.vue
  108:22  warning  The "update:value" event has been triggered but not declared on `emits` option  vue/require-explicit-emits

Produced same lint warning both times so reassuring. Is Unknown node type "ChainExpression": Estimated visitor keys ["type","start","end","loc","range","expression"] something to look into?

@lovetingyuan
Copy link

I changed parserOptions.parser to allow multiple parsers.
If someone has an environment where they can try out performance issues, can you use the following configuration to see if it improves performance and share the results?

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

If performance improves, I think it's a useful workaround for many.

how to set different parser options for each parserOptions.parser ? @ota-meshi

@ota-meshi
Copy link
Member

There is no way to do that.

@simllll
Copy link

simllll commented Aug 16, 2021

If I run it via CLI
e.g. eslint src/file.ts --ext ts
it throws 7:13 error Parsing error: Unexpected token {
for
image

it seems it always picks "espree" instead of the rule that should forward it to the typesint-eslint/parser in case it's a ts file?

a possible workaround for now:

overrides: [
		{
			// enable the rule specifically for TypeScript files
			files: ['*.ts', '*.tsx'],
			parserOptions: {
				parser: '@typescript-eslint/parser'
			}
		}
	],

@yoyo930021
Copy link
Member Author

yoyo930021 commented Aug 24, 2021

If I run it via CLI
e.g. eslint src/file.ts --ext ts
it throws 7:13 error Parsing error: Unexpected token {
for
image

it seems it always picks "espree" instead of the rule that should forward it to the typesint-eslint/parser in case it's a ts file?

a possible workaround for now:

overrides: [
		{
			// enable the rule specifically for TypeScript files
			files: ['*.ts', '*.tsx'],
			parserOptions: {
				parser: '@typescript-eslint/parser'
			}
		}
	],

Try this config.

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "js": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

@yoyo930021
Copy link
Member Author

@ota-meshi Thank you for the help.
I'm sorry for being late to reply.

Test result:

Project 1

  • Previous
    • 56.40s
    • 60.02s
  • Now
    • 31.76s
    • 34.21s

Project 2

  • Previous
    • 355.39s
    • 333.68s
  • Now
    • 51.07s
    • 56.20s

The effect is remarkable.

@yoyo930021
Copy link
Member Author

Are there any information, progress or ideas for the problem with the [no-unsafe-*] rules?

No method other than hacking @typescript-eslint/parser. =_=

@MatthiasKunnen
Copy link

MatthiasKunnen commented Aug 31, 2021

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

I have an issue with this, if a vue file does not contain at least one TS script, the following error occurs:

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/views/EmptyView.vue
    at Object.getParserServices (node_modules/@typescript-eslint/eslint-plugin-tslint/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/getParserServices.js:16:15)
    at create (node_modules/@typescript-eslint/eslint-plugin-tslint/dist/rules/config.js:70:65)
    at Object.create (node_modules/@typescript-eslint/eslint-plugin-tslint/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 node_modules/eslint/lib/linter/linter.js:1299:29
    at Array.map (<anonymous>)

Vue file:

<template>
    <div class="view" />
</template>

Adding <script lang="ts"></script> fixes the issue.

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

@lovetingyuan
Copy link

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

I have an issue with this, if a vue file does not contain at least one TS script, the following error occurs:

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/views/EmptyView.vue
    at Object.getParserServices (node_modules/@typescript-eslint/eslint-plugin-tslint/node_modules/@typescript-eslint/experimental-utils/dist/eslint-utils/getParserServices.js:16:15)
    at create (node_modules/@typescript-eslint/eslint-plugin-tslint/dist/rules/config.js:70:65)
    at Object.create (node_modules/@typescript-eslint/eslint-plugin-tslint/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 node_modules/eslint/lib/linter/linter.js:1299:29
    at Array.map (<anonymous>)

Vue file:

<template>
    <div class="view" />
</template>

Adding <script lang="ts"></script> fixes the issue.

Then you have to set parserOptions.project

@MatthiasKunnen
Copy link

I did. The first code block in my comment is a quote, not my actual config. My config is:

{
     parser: 'vue-eslint-parser',
     parserOptions: {
         parser: {
             '<template>': 'espree',
             js: 'espree',
             ts: '@typescript-eslint/parser',
         },
         project: ['./tsconfig.json'],
         extraFileExtensions: ['.vue'],
     },
}

@lovetingyuan
Copy link

lovetingyuan commented Aug 31, 2021

I did. The first code block in my comment is a quote, not my actual config. My config is:

{
     parser: 'vue-eslint-parser',
     parserOptions: {
         parser: {
             '<template>': 'espree',
             js: 'espree',
             ts: '@typescript-eslint/parser',
         },
         project: ['./tsconfig.json'],
         extraFileExtensions: ['.vue'],
     },
}

In fact, @typescript-eslint/parser will not be applied for pure ts file, so you have to change js: 'espree' to js: '@typescript-eslint/parser'
You can see here:

@MatthiasKunnen
Copy link

I already tried that before. The problem is not with the js parser setting. With or without it, set to espreeor @typescript-eslint/parser, vue files cause the aforementioned error unless a script with lang="ts" is present.

Try out this repository: https://github.com/MatthiasKunnen/eslint-plugin-vue-ts-script.

@lovetingyuan
Copy link

I already tried that before. The problem is not with the js parser setting. With or without it, set to espreeor @typescript-eslint/parser, vue files cause the aforementioned error unless a script with lang="ts" is present.

Try out this repository: https://github.com/MatthiasKunnen/eslint-plugin-vue-ts-script.

of course you have to set the lang attribute. If it is omitted, the build tool also can not process your vue sfc written with ts.

@MatthiasKunnen
Copy link

MatthiasKunnen commented Sep 1, 2021

of course you have to set the lang attribute. If it is omitted, the build tool also can not process your vue sfc written with ts.

@lovetingyuan, have you even looked at the linked repository? Please refrain from further replies with irrelevant information which cause unnecessary notifications and time waste for subscribers to this issue.

@rndmerle
Copy link

rndmerle commented Sep 2, 2021

This config also works on our project (even if we had to keep that under an override for { files: ['**/*.vue'], parser: 'vue-eslint-parser' }.
And I confirm we had to add <script lang="ts">export default {}</script> to some of our stateless components missing it.

@simllll
Copy link

simllll commented Sep 2, 2021

Try this config.

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "js": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

that's exactly what I have, but still need to override it for .ts files to get it working correctly.

@Darkproduct
Copy link

I'm currently struggling to get linting to work on my Laravel - Vue2 project with JavaScript and TypeScript. For debugging I created this small project, but I stumble from one issue to another.

First it seemed like I can't get the fragmented parser option, introduced in typescript-eslint/typescript-eslint#1180 to work, then I find typescript-eslint @TYPED_LINTING.md and now I'm stuck at:

$ eslint --config resources/js/.eslintrc.js --fix resources/js --ext .vue,.js,.ts

C:\fakepath\ts-test\resources\js\.eslintrc.js
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: resources\js\.eslintrc.js.
The file must be included in at least one of the projects provided

I've added those files to the tsconfig.json and even tried creating a tsconfig.eslint.json. But this doesn't work.

It it not at all clear to me, how @typescript-eslint/parser and this project should be configured to get proper linting.

@segevfiner
Copy link

segevfiner commented Aug 11, 2022

Getting the same error. It looks like tsconfigRootDir and project isn't getting passed along to to @typescript-eslint/parser. Though even if it will get passed, it won't necessarily work due to the other issues described in this issue.

Scratch that. It is probably the missing <script setup lang="ts"> issue. I wonder if vue-eslint-parser can workaround this.

@AsukaSoryu0
Copy link

trash for vue3 ts lint。。。

@yoyo837
Copy link

yoyo837 commented Sep 27, 2023

I changed parserOptions.parser to allow multiple parsers. If someone has an environment where they can try out performance issues, can you use the following configuration to see if it improves performance and share the results?

{
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": {
            "ts": "@typescript-eslint/parser",
            "<template>": "espree"
        }
    }
}

If performance improves, I think it's a useful workaround for many.

I got Parsing error: Maximum call stack size exceeded by the config.

n0099 added a commit to n0099/open-tbm that referenced this issue Dec 18, 2023
…s/vue-eslint-parser#104 (comment) @ .eslintrc.cjs

* re-order `overrides` to specify `settings.import/resolver.vite` over `*.vue`, `settings.import/resolver.typescript` over `*.ts` & rules over `.eslintrc.cjs`,

* `eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call` @ main.ts
* `eslint-disable` @ stats.js
* fix the return type of `_.defaultsDeep()` is `any` @ `useQueryForm.fillParamDefaultValue()`
- `shims-vue.d.ts` following vuejs/vue-eslint-parser#104 (comment)
$ yarn add -D typescript-eslint-parser-for-extra-files
@ fe
@Shinigami92
Copy link

I dont know if this issue is the right place, but I want to make it popular because I sinked in around 2h of try and error for this.

extraFileExtensions: ['.vue'] is not read if it is in the eslint config overrides section.
It needs to be in parserOptions.extraFileExtensions in the root config.
All other override stuff, even parserOptions then can be put into overrides.files: ['*.vue']

@ehoogeveen-medweb
Copy link

One additional hurdle that I haven't seen mentioned yet: vue-eslint-parser does not appear to support either EXPERIMENTAL_useProjectService: true (which supports project references via TypeScript's project service) or project: true (which uses the nearest tsconfig.json as the project configuration for each file). You have to use the traditional way of passing the tsconfigs as an array of glob patterns.

@Stanzilla
Copy link

The docs are also wrong/outdated when it comes to flat config, it does not allow a "parser" key in language options, i.e.

languageOptions: {
      ecmaVersion: 5,
      sourceType: "script",
      parser: "vue-eslint-parser",
      parserOptions: {
        parser: "@typescript-eslint/parser",
        tsconfigRootDir: import.meta.dirname,
        extraFileExtensions: [".vue"],
        projectService: true,
      },
    },

fails with ConfigError: Config (unnamed): Key "languageOptions": Key "parser": Expected object with parse() or parseForESLint() method.

@higherorderfunctor
Copy link

@Stanzilla use imports instead of strings.

import tsParser from '@typescript-eslint/parser';
import vueParser from 'vue-eslint-parser';

languageOptions: {
      ecmaVersion: 5,
      sourceType: "script",
      parser: vueParser,
      parserOptions: {
        parser: tsParser,
        tsconfigRootDir: import.meta.dirname,
        extraFileExtensions: [".vue"],
        projectService: true,
      },
    },

@Stanzilla
Copy link

import tsParser from '@typescript-eslint/parser';
import vueParser from 'vue-eslint-parser';

that gives me

/Users/stan/projects/personal/WeakAuras-Companion/src/App.vue
  0:0  error  Parsing error: "parserOptions.programs" has been provided for @typescript-eslint/parser.
The file was not found in any of the provided program instance(s): src/App.vue

@higherorderfunctor
Copy link

higherorderfunctor commented Jun 3, 2024

@Stanzilla @ehoogeveen-medweb maybe this issue I opened is relevant?

typescript-eslint/typescript-eslint#9205

I (re)discovered a bug in v7 where extra file extensions aren't forwarded to tsserver. It was already fixed in rc-v8 when I reported.

This was the main headache for me with vue files not working with project services. Vue files were assigned to an inferred project with default compiler options instead of whats in my tsconfigs.

Also, depending, on the complexity of your tsconfigs, extends may not be getting processed. If your default project extends from a base tsconfig with the compiler options needed to resolve types, they are never read.

I have a v7 example showing an imported png resolving to any (not reading compilerOptions.types due to inferred program) that I was able to fix with a patch. The other issue still exists in v8. My v8 example is slightly different but could result in the same problem. By keeping enough options in the default tsconfig to build and moving only the types option to the base tsconfig, the png should also fail to resolve to anything but any.

So depending on your setup it may be one or both of these bugs causing issues.

v7 https://github.com/higherorderfunctor/example-typescript-eslint-bug/blob/main/eslint.config.js

v8 https://github.com/higherorderfunctor/example-typescript-eslint-bug/blob/rc-v8/eslint.config.js

@n0099
Copy link

n0099 commented Jun 5, 2024

@Stanzilla try run eslint with env var TSESTREE_SINGLE_RUN=false
typescript-eslint/typescript-eslint#4093
typescript-eslint/typescript-eslint#8922

since passing @typescript-eslint specified parserOptions to vue-eslint-parser

languageOptions: {
    parser: vueParser,
    parserOptions: {
        parser: tsParser,
+       allowAutomaticSingleRunInference: false,
+       disallowAutomaticSingleRunInference: true,
    }
}

won't work as it's not going to forward them as parserOptions of the given parserOptions.parser:

// others
// [key: string]: any

n0099 added a commit to n0099/open-tbm that referenced this issue Jun 5, 2024
…@typescript-eslint/parser.

The file was not found in any of the provided program instance(s):` by vuejs/vue-eslint-parser#104 (comment)
* reset `languageOptions.parserOptions.ecmaVersion` to `latest` as it's set to `2018` by `pluginImportX.configs.recommended`
- rules from `@typescript-eslint` for file `eslint.config.js`
* simplify the importing of `vite.config.ts`
* ignore files generated by yarn
- rule `@typescript-eslint/no-throw-literal`: typescript-eslint/typescript-eslint#9083
@ eslint.config.js

$ yarn eslint --fix
@ fe
n0099 added a commit to n0099/open-tbm that referenced this issue Jun 5, 2024
…@typescript-eslint/parser.

The file was not found in any of the provided program instance(s):` by vuejs/vue-eslint-parser#104 (comment)
* reset `languageOptions.parserOptions.ecmaVersion` to `latest` as it's set to `2018` by `pluginImportX.configs.recommended`
- rules from `@typescript-eslint` for file `eslint.config.js`
* simplify the importing of `vite.config.ts`
* ignore files generated by yarn
- rule `@typescript-eslint/no-throw-literal`: typescript-eslint/typescript-eslint#9083
@ eslint.config.js

$ yarn eslint --fix
@ fe
n0099 added a commit to n0099/open-tbm that referenced this issue Jun 5, 2024
…@typescript-eslint/parser.

The file was not found in any of the provided program instance(s):` by vuejs/vue-eslint-parser#104 (comment)
* reset `languageOptions.parserOptions.ecmaVersion` to `latest` as it's set to `2018` by `pluginImportX.configs.recommended`
- rules from `@typescript-eslint` for file `eslint.config.js`
* simplify the importing of `vite.config.ts`
* ignore files generated by yarn
- rule `@typescript-eslint/no-throw-literal`: typescript-eslint/typescript-eslint#9083
@ eslint.config.js

$ yarn eslint --fix
@ fe
@Stanzilla
Copy link

@Stanzilla try run eslint with env var TSESTREE_SINGLE_RUN=false typescript-eslint/typescript-eslint#4093 typescript-eslint/typescript-eslint#8922

since passing @typescript-eslint specified parserOptions to vue-eslint-parser

languageOptions: {
    parser: vueParser,
    parserOptions: {
        parser: tsParser,
+       allowAutomaticSingleRunInference: false,
+       disallowAutomaticSingleRunInference: true,
    }
}

won't work as it's not going to forward them as parserOptions of the given parserOptions.parser:

// others
// [key: string]: any

Thanks, that helps a bit!

1 similar comment
@Stanzilla
Copy link

@Stanzilla try run eslint with env var TSESTREE_SINGLE_RUN=false typescript-eslint/typescript-eslint#4093 typescript-eslint/typescript-eslint#8922

since passing @typescript-eslint specified parserOptions to vue-eslint-parser

languageOptions: {
    parser: vueParser,
    parserOptions: {
        parser: tsParser,
+       allowAutomaticSingleRunInference: false,
+       disallowAutomaticSingleRunInference: true,
    }
}

won't work as it's not going to forward them as parserOptions of the given parserOptions.parser:

// others
// [key: string]: any

Thanks, that helps a bit!

@Stanzilla
Copy link

I have this now which works fairly well:

import pluginVue from "eslint-plugin-vue";
import unocss from "@unocss/eslint-config/flat";
import eslint from "@eslint/js";
import tsEslint from "typescript-eslint";
import tsParser from "@typescript-eslint/parser";
import vueParser from "vue-eslint-parser";

export default [
  eslint.configs.recommended,
  ...tsEslint.configs.recommendedTypeChecked,
  ...pluginVue.configs["flat/recommended"],
  unocss,
  {
    languageOptions: {
      parser: vueParser,
      parserOptions: {
        parser: tsParser,
        sourceType: "module",
        extraFileExtensions: [".vue"],
        project: true,
      },
    },
  },
  {
    ignores: [
      "dist",
      "node_modules",
      "dist_electron",
      "dist-electron",
      "release",
      "index.html",
      "tools/**/*.js",
      "uno.config.ts",
      "vite.config.ts",
      "*.d.ts",
    ],
    rules: {
      "no-console": "off",
      "no-undef": "off",
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-implicit-any": "off",
      "@typescript-eslint/no-unsafe-call": "off",
      "@typescript-eslint/no-unsafe-return": "off",
      "@typescript-eslint/no-unsafe-member-access": "off",
      "@typescript-eslint/no-unsafe-assignment": "off",
      "@typescript-eslint/no-unsafe-argument": "off",
      "@typescript-eslint/no-floating-promises": "off",
      "@typescript-eslint/no-unnecessary-type-assertion": "off",
      "@typescript-eslint/no-base-to-string": "off",
      "@typescript-eslint/restrict-template-expressions": "off",
      "@typescript-eslint/require-await": "off",
      "vue/multi-word-component-names": "off",
      "vue/component-tags-order": [
        "error",
        {
          order: [["script", "template"], "style"],
        },
      ],
      "vue/html-self-closing": "off",
      "vue/html-indent": "off",
      "vue/html-closing-bracket-newline": "off",
      "vue/singleline-html-element-content-newline": "off",
    },
  },
];

@MartinX3
Copy link

MartinX3 commented Jul 2, 2024

I use a vuetify or quasar starter with typescript and script setup.

It just works.

@vlechemin
Copy link

@Stanzilla try run eslint with env var TSESTREE_SINGLE_RUN=false typescript-eslint/typescript-eslint#4093 typescript-eslint/typescript-eslint#8922

since passing @typescript-eslint specified parserOptions to vue-eslint-parser

languageOptions: {
    parser: vueParser,
    parserOptions: {
        parser: tsParser,
+       allowAutomaticSingleRunInference: false,
+       disallowAutomaticSingleRunInference: true,
    }
}

won't work as it's not going to forward them as parserOptions of the given parserOptions.parser:

// others
// [key: string]: any

Thanks. While this workaround works, it significantly impacts performance, increasing the time from 2 minutes to 16 minutes.

@n0099
Copy link

n0099 commented Jul 9, 2024

@repnop
Copy link

repnop commented Oct 23, 2024

running into this problem myself (over 1k no-unsafe-* lints triggering) after upgrading to ESLint v9, but it seems to only happen with prop values? everything else seemingly comes out clean, but for whatever reason, no matter how I access any of the props, it triggers the lint. it'd be nice to not need to disable a bunch of the lints because of this so they can catch actual problems & not muddy the waters with code that isn't actually broken, but doesn't really seem like there's a workaround. fwiw the typescript server in VSCode is able to properly give me types on hover and such, so obviously it works in some capacity already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests