vuejs / eslint-plugin-vue

Official ESLint plugin for Vue.js
https://eslint.vuejs.org/
MIT License
4.38k stars 649 forks source link

Flat config : Parsing error: Unexpected token ) #2452

Closed Robin-Ln closed 1 month ago

Robin-Ln commented 1 month ago

I get parsed error with with the config "flat/recommended"

Tell us about your environment

Please show your full configuration:

import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import pluginVue from 'eslint-plugin-vue';
import tseslint from 'typescript-eslint';
import prettierConfig from './prettier.config.mjs';

export default tseslint.config(
  eslint.configs.recommended,
  ...tseslint.configs.recommended,
  ...pluginVue.configs['flat/recommended'],
  eslintPluginPrettierRecommended,
  {
    rules: {
      'prettier/prettier': ['error', prettierConfig]
    }
  }
);

What did you expect to happen?

don't get parse error

What actually happened?

eslint:linter With flat config: /Users/rlouarn/git/monorepo-test/apps/demo/src/components/HelloWorld.vue +0ms
  eslint:linter Apply the processor: { preprocess: [Function: preprocess], postprocess: [Function: postprocess], supportsAutofix: true, meta: { name: 'eslint-plugin-vue', version: '9.25.0' } } +0ms
  eslint:linter A code block was found: '(unnamed)' +0ms
  eslint:linter Parsing: /Users/rlouarn/git/monorepo-test/apps/demo/src/components/HelloWorld.vue +0ms
  eslint:linter Parsing error: Unexpected token )
  eslint:linter SyntaxError: Unexpected token )
    at Espree.raise (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/espree@10.0.1/node_modules/espree/dist/espree.cjs:674:25)
    at Espree.unexpected (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/espree@10.0.1/node_modules/espree/dist/espree.cjs:719:18)
    at pp$5.parseParenAndDistinguishExpression (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:3055:51)
    at pp$5.parseExprAtom (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2890:43)
    at pp$5.parseExprSubscripts (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2715:21)
    at pp$5.parseMaybeUnary (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2681:19)
    at pp$5.parseExprOp (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2633:43)
    at pp$5.parseExprOp (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2638:21)
    at pp$5.parseExprOps (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2610:93)
    at pp$5.parseMaybeConditional (/Users/rlouarn/git/monorepo-test/node_modules/.pnpm/acorn@8.11.3/node_modules/acorn/dist/acorn.js:2591:21) +6ms
  eslint:linter Generating fixed text for /Users/rlouarn/git/monorepo-test/apps/demo/src/components/HelloWorld.vue (pass 1) +0ms
  eslint:source-code-fixer Applying fixes +7ms
  eslint:source-code-fixer shouldFix parameter was false, not attempting fixes +0ms

apps/demo/src/components/HelloWorld.vue
  4:29  error  Parsing error: Unexpected token )

Repository to reproduce this issue https://gitlab.com/robin.louarn/monorepo-test

pnpm install && pnpm --filter @my-company/app-demo lint --debug

waynzh commented 1 month ago

Duplicate of #2449. This https://github.com/vuejs/eslint-plugin-vue/issues/2449#issuecomment-2056322342 might be helpful.

Robin-Ln commented 1 month ago

Thx that fix my bug !

FloEdelmann commented 1 month ago

Please feel free to submit a PR to improve the docs in this regard, if you find them lacking.