Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint-disable comments in svelte html don't work with eslint-plugin-eslint-comments #328

Open
2 tasks done
DetachHead opened this issue Dec 19, 2022 · 4 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@DetachHead
Copy link
Contributor

DetachHead commented Dec 19, 2022

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

  • 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.30.0

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

2.14.1

What did you do?

Configuration
module.exports = {
  root: true,
  parser: "@typescript-eslint/parser",
  "extends": ["plugin:svelte/recommended", "plugin:eslint-comments/recommended"],
  plugins: ["@typescript-eslint"],
  ignorePatterns: ["*.cjs"],
  settings: {
    'import/parsers': {
      '@typescript-eslint/parser': [ '.ts', '.tsx', '.cts', '.mts' ],
      'espree': [ '.js', 'jsx', '.cjs', '.mjs' ],
    }
  },
  rules: {
    'svelte/html-self-closing':'error',
    'eslint-comments/require-description': 'error'
  },
  overrides: [
    {
      files: ["*.svelte"],
      parser: "svelte-eslint-parser",
      parserOptions: {
        parser: "@typescript-eslint/parser",
      },
    },
  ]
};
<script>
    // error: eslint-comments/require-description
    //eslint-disable-next-line
    console.log(1)
</script>

<!-- no error -->
<!-- eslint-disable-next-line -->
<input value="asdf">

What did you expect to happen?

eslint-comments/require-description error on the html comment

What actually happened?

no error on the html comment

Link to GitHub Repo with Minimal Reproducible Example

https://github.com/DetachHead/eslint-plugin-svelte-issue/tree/d0eb35b9d72cd26928488f7bbe8cb0ee0f0d1222

Additional comments

i'm not sure whether this is an issue with this plugin or eslint-plugin-eslint-comments, so i'm raising it in both projects

mysticatea/eslint-plugin-eslint-comments#74

@ota-meshi
Copy link
Member

ota-meshi commented Dec 19, 2022

Thank you for posting the issue. eslint-disable HTML comments provided by eslint-plugin-svelte are completely different from eslint-disable comments provided by ESLint.
https://sveltejs.github.io/eslint-plugin-svelte/rules/comment-directive/
Therefore, they are not compatible with eslint-plugin-eslint-comments. If we want to do similar checks, we need to add our own functionality to eslint-plugin-svelte, like the reportUnusedDisableDirectives option.
https://sveltejs.github.io/eslint-plugin-svelte/rules/comment-directive/#options

@ota-meshi ota-meshi added the enhancement New feature or request label Dec 19, 2022
@OJFord
Copy link

OJFord commented Feb 5, 2023

I'm not using esling-plugin-eslint-comments, but I'm finding that:

    <!-- eslint-disable-next-line svelte/no-at-html-tags -->
    {@html foobar}

doesn't work either. Is that expected? Is there another way to ignore rules from this plugin on specific lines?

(This is one particular case where I do want the tag, and it's guarded by a check that it's been stripped of anything potentially malicious.)

@DetachHead
Copy link
Contributor Author

@OJFord that works for me. could you share some more info like your eslint config or maybe some of the surrounding code?

@attisimon
Copy link

Hello! Just a note that I have tried this out, with a different rule from @intlify and it seems to be working for me, the rule is disabled as expected:

<!-- eslint-disable-next-line @intlify/svelte/no-raw-text -->
<strong>Raw string</strong>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants