Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Syntax error when generic type parameter contains = #233

Copy link
Copy link
Closed
@auvred

Description

@auvred
Issue body actions

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I'm using eslint-plugin-vue.
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-vue repo and open the issue in eslint-plugin-vue repo if there is no solution.
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

n/a

What version of eslint-plugin-vue and vue-eslint-parser are you using?

  • vue-eslint-parser@9.4.2

What did you do?

<!-- app.vue -->
<script lang="ts" setup generic="T extends () => string">
</script>
// index.js
const { parse } = require('vue-eslint-parser')
parse(require('fs').readFileSync('./app.vue', 'utf-8'), { parser: require('@typescript-eslint/parser') })

What did you expect to happen?

Parse the Vue SFC with no errors.

What actually happened?

/.../node_modules/vue-eslint-parser/index.js:894
            throw perr;
            ^

SyntaxError: '=>' expected.
    at ParseError.normalize (/.../node_modules/vue-eslint-parser/index.js:98:20)
    at parseScriptFragmentWithOption (/.../node_modules/vue-eslint-parser/index.js:891:33)
    at parseScriptFragment (/.../node_modules/vue-eslint-parser/index.js:880:12)
    at parseScriptElement (/.../node_modules/vue-eslint-parser/index.js:1171:20)
    at parseAsSFC (/.../node_modules/vue-eslint-parser/index.js:6438:18)
    at parseForESLint (/.../node_modules/vue-eslint-parser/index.js:6398:53)
    at Object.parse (/.../node_modules/vue-eslint-parser/index.js:6406:12)
    at [eval]:1:30
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:109:14 {
  code: undefined,
  index: 55,
  lineNumber: 1,
  column: 55
}

Link to Minimal Reproducible Example

mkdir repro
cd repro
echo '{"dependencies":{"@typescript-eslint/parser":"^7.8.0","vue-eslint-parser":"9.4.2"}}' > package.json
npm i
node -p "require('vue-eslint-parser').parse('<script lang=\"ts\" setup generic=\"T extends () => string\">\n</script>', {parser: require('@typescript-eslint/parser')})"

Additional comments

This issue seems to have appeared after #221 -> #222

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.