Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Parser failed to recognize variables used in Pug template #727

Open
@thanhdatvo

Description

@thanhdatvo

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

  • I'm usingeslint-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 ineslint-plugin-svelte repo and open the issue ineslint-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?

9.18.0

What version ofeslint-plugin-svelte andsvelte-eslint-parser are you using?

  • svelte-eslint-parser@1.3.0
  • eslint-plugin-svelte@3.0.0

What did you do?

Configuration

eslint.config.js

importprettierfrom'eslint-config-prettier';import{includeIgnoreFile}from'@eslint/compat';importjsfrom'@eslint/js';importsveltefrom'eslint-plugin-svelte';importglobalsfrom'globals';import{fileURLToPath}from'node:url';importtsfrom'typescript-eslint';importsvelteConfigfrom'./svelte.config.js';constgitignorePath=fileURLToPath(newURL('./.gitignore',import.meta.url));exportdefaultts.config(includeIgnoreFile(gitignorePath),js.configs.recommended,...ts.configs.recommended,...svelte.configs.recommended,prettier,...svelte.configs.prettier,{languageOptions:{globals:{ ...globals.browser, ...globals.node}},rules:{// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors'no-undef':'off'}},{files:['**/*.svelte','**/*.svelte.ts','**/*.svelte.js'],languageOptions:{parserOptions:{projectService:true,extraFileExtensions:['.svelte'],parser:ts.parser,svelteConfig}}});

tsconfig.json

{"extends":"./.svelte-kit/tsconfig.json","compilerOptions": {"allowJs":true,"checkJs":true,"esModuleInterop":true,"forceConsistentCasingInFileNames":true,"resolveJsonModule":true,"skipLibCheck":true,"sourceMap":true,"strict":true,"moduleResolution":"bundler"}// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files//// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes// from the referenced tsconfig.json - TypeScript does not merge them in}

+page.svelte

<scriptlang="ts">// import '../app.css';let say: { data: { title:string } }=$props();// function hello() {// console.log('Hello World');// }const hello= ()=> {console.log('Hello World');};let count=$state(0);const increment= ()=> (count+=1);</script><!-- <div>Oh</div> --><templatelang="pug">  .bg-gray-200.p-4.text-center    | hello world  .text-blue-600.p-4.bg-gray-100.text-center     | {say.data.title}  p     | hello  button(onclick!="{hello}").text-blue-100     | Click  div      h1          | Counter:{count}      button(onclick!="{increment}")         | Click me</template>

What did you expect to happen?

There should be no warning in eslint about:

'say' is assigned a value but never used.'hello' is assigned a value but never used.'increment' is assigned a value but never used.

These warning appears when I use template with lang="pug", this does not happen when I use template with lang="html"

What actually happened?

There are warning

'say' is assigned a value but never used.'hello' is assigned a value but never used.'increment' is assigned a value but never used.
ImageImage

Link toGitHub Repo with Minimal Reproducible Example

https://github.com/thanhdatvo/svelte5-with-pug

Additional comments

I ran the code in +page.svelte in the playground website and the same warnings appeared

https://sveltejs.github.io/svelte-eslint-parser/playground/#eJyFUTtPwzAQ/ivXCKmpkJ0UAUObdmFhY2TJkjomjXBty77wUMh/xxcnhUpIJIMf3+PO3/WJMLVMNknhhWstgqp0sysT9GWyL3WJWQbtyRqHsOQ8q6zlwvvlliAlEXz1uYEe6gorWrENtxvw6FrdwBD+HVxZZ6xPV9vJ7qXTAluj4SiVMukK+gkoURjtjZJcmSZdPhIMz8apenkWD7QSDaM8+AeH3T6a/OswnBsXptNI3XmsUKZ5xKNzq4WTJzni0T2N9OsdrIlYZDEtSkgXC8agqNs3EKrynsKTH8icrNldnocYn45FFuA9MBYEBcqTVaHmHLXtmpi1BuCHhjWu+mQ3ec4tu+WjlQitSEc4wNf07nd61SQaSQfVSXY/yWabdTj/soDZow9z4zQ0Pk5siEYWLmrEy0OHaHRqtFCteF2EhvsRHcpk9atyqHRWPxAzqsO744a+4xpg3o88ClW6TT+mO/wQ/6h5ngnVvXQhDpzkOItsTjcEmgzfkDTwFw==

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp