`@typescript-eslint/eslint-plugin` crashes when applying rules to Vue SFC `<script>` not parsed with `@typescript-eslint/parser`
See original GitHub issueWhile using @typescript-eslint/recommended-requiring-type-checking
with vue-eslint-parser
as parser
, @typescript-eslint/parser
can’t check for types when there is no <script>
used in a Vue SFC.
Stacktrace:
Oops! Something went wrong! :(
ESLint: 8.17.0
Error: Error while loading rule '@typescript-eslint/dot-notation': 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/drjume/Desktop/falconDev/my-falcondev/apps/web/src/views/NotFoundView.vue
at getParserServices (/Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/@typescript-eslint+utils@5.27.1_ud6rd4xtew5bv4yhvkvu24pzm4/node_modules/@typescript-eslint/utils/dist/eslint-utils/getParserServices.js:16:15)
at create (/Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/@typescript-eslint+eslint-plugin@5.27.1_aq7uryhocdbvbqum33pitcm3y4/node_modules/@typescript-eslint/eslint-plugin/dist/rules/dot-notation.js:85:81)
at Object.create (/Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/@typescript-eslint+utils@5.27.1_ud6rd4xtew5bv4yhvkvu24pzm4/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:42:20)
at createRuleListeners (/Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/eslint@8.17.0/node_modules/eslint/lib/linter/linter.js:922:21)
at /Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/eslint@8.17.0/node_modules/eslint/lib/linter/linter.js:1104:31
at Array.forEach (<anonymous>)
at runRules (/Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/eslint@8.17.0/node_modules/eslint/lib/linter/linter.js:1041:34)
at Linter._verifyWithoutProcessors (/Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/eslint@8.17.0/node_modules/eslint/lib/linter/linter.js:1389:31)
at /Users/drjume/Desktop/falconDev/my-falcondev/node_modules/.pnpm/eslint@8.17.0/node_modules/eslint/lib/linter/linter.js:1798:29
at Array.map (<anonymous>)
When adding an empty <script setup lang="ts"></script>
the error is not shown anymore when running eslint.
The issue seems to be, that the parserServices
or a property of it is missing when there is no <script>
in a Vue SFC:
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
`@typescript-eslint/eslint-plugin` crashes when applying rules ...
`@typescript-eslint/eslint-plugin` crashes when applying rules to Vue SFC `<script>` not parsed with `@typescript-eslint/parser`.
Read more >False positives when using with Vue SFC · Issue #883 - GitHub
Since the analysis by @typescript-eslint/parser fails, the vue file is reported as a parsing error.
Read more >@typescript-eslint/eslint-plugin | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >Add ESLint to a Meteor + Vue + Typescript project
I can get it successfully parsing and formatting Typescript files but it is throwing syntax errors for the .vue files. ESLint related ...
Read more >General Advice on Setup & Resolving Issues - SonarCloud
Yes we do use Vue.JS SFC. Those files do have some of those. ... Speaking from experience, typescript-eslint parser fails to parse a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for posting issue.
I think it’s technically impossible. TypeScript cannot provide type information for virtual filenames. This means that if we assign a virtual file name, you will not be able to use “recommended-requiring-type-checking”.
I fixed my error by setting the
parserOptions.parser
inside the.eslintrc.js
: