vuejs / eslint-config-typescript

ESLint configuration for Vue 3 + TypeScript projects
MIT License
133 stars 30 forks source link

14.0.0 Parsing error: Invalid ecmaVersion on components with no <script> tag #87

Closed chrisnruud closed 1 month ago

chrisnruud commented 1 month ago

Vue components doesn't need script tags, eslint fails when trying to parse components with no script tag with

npx eslint src/components/FailingBecauseNoScript.vue

/Users/repositories/eslint9test/src/components/FailingBecauseNoScript.vue
  0:0  error  Parsing error: Invalid ecmaVersion

✖ 1 problem (1 error, 0 warnings)

reproduction available in https://github.com/chrisnruud/eslint9test

chrisnruud commented 1 month ago

Debugging via espree seems that ecmaversion that is passed in is "2025"

debug: ecmaversion is 2025
eslint:languages:js Invalid ecmaVersion.
  eslint:languages:js Error: Invalid ecmaVersion.
    at normalizeEcmaVersion (/Users/aurora/repositories/eslint9test/node_modules/espree/dist/espree.cjs:354:15)
    at normalizeOptions (/Users/aurora/repositories/eslint9test/node_modules/espree/dist/espree.cjs:385:25)
    at new Espree (/Users/aurora/repositories/eslint9test/node_modules/espree/dist/espree.cjs:486:29)
    at Object.parse (/Users/aurora/repositories/eslint9test/node_modules/espree/dist/espree.cjs:836:12)
    at parseScript$1 (/Users/aurora/repositories/eslint9test/node_modules/vue-eslint-parser/index.js:1142:18)
    at parseAsSFC (/Users/aurora/repositories/eslint9test/node_modules/vue-eslint-parser/index.js:6435:18)
    at Object.parseForESLint (/Users/aurora/repositories/eslint9test/node_modules/vue-eslint-parser/index.js:6402:53)
    at Object.parse (/Users/aurora/repositories/eslint9test/node_modules/eslint/lib/languages/js/index.js:186:26)
    at ParserService.parseSync (/Users/aurora/repositories/eslint9test/node_modules/eslint/lib/services/parser-service.js:36:33)
    at #flatVerifyWithoutProcessors (/Users/aurora/repositories/eslint9test/node_modules/eslint/lib/linter/linter.js:1683:47) +3ms

And this again seems to be an upstream issue with eslint-plugin-vue that supplies espree 9.6.1 that doesnt support es2025 (16) but v10 does.

chrisnruud commented 1 month ago

Seems like this issue was resolvable by re-creating package.json, which suggests that the current npm create vue@latest does some minor package mismanagment

karachungen commented 1 month ago

Adding "espree": "^10.2.0", to package.json helped me as well

haoqunjiang commented 1 month ago

It is indeed a bug, though very subtle. Fixed in 14.0.1.

Thanks for reporting!