Skip to content

Error parsing spread syntax with lang="pug" #228

Closed
@vglfr

Description

@vglfr

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

  • I'm using eslint-plugin-svelte. (*.svelte file linting does not work with the parser alone. You should also use eslint-plugin-svelte with it.)
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-svelte repo and open the issue in eslint-plugin-svelte 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?

8.25.0

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

What did you do?

Configuration

.eslintrc.yaml

env:
  browser: true
  es6: true
extends:
  - "eslint:recommended"
  - "plugin:svelte/recommended"
parserOptions:
  ecmaVersion: 2020
  sourceType: module

Test.svelte

<script>
  let objs = [{a: 1, b: 2}, {a: 2, b: 3}]
</script>

<template lang="pug">
  +each("objs as obj")
    p("{...obj}") {obj.a}
</template>

What did you expect to happen?

Successful parse.

What actually happened?

$ eslint Test.svelte

/home/projects/node-zm1om6/Test.svelte
7:8 error Parsing error: Unexpected token

✖ 1 problem (1 error, 0 warnings)

Link to Minimal Reproducible Example

https://stackblitz.com/edit/node-zm1om6?file=Test.svelte

Additional comments

With ("{...obj}") dropped linter issues no-unused-vars and no-undef. It seems eslint-plugin-svelte processes markup as plaintext.

With svelte-preprocess in place Svelte compiler won't issue a warning; however a genuine error would likely result in incorrect line number. Apparently preprocessor does not map original pug to resulting html (same issue with sass). Not good in compiler, it's probably a no-go for linter.

That sounds like a load of work and wontfix. However if you think it's feasible please outline the solution, I'd like to dig in.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions