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

No documentation how to override rules #193

Open
ToP29 opened this issue Nov 1, 2022 · 3 comments
Open

No documentation how to override rules #193

ToP29 opened this issue Nov 1, 2022 · 3 comments

Comments

@ToP29
Copy link

ToP29 commented Nov 1, 2022

For example missing-declaration is warn and I think it should be error, because if something is not defined, lint step should fail with error. But if I try to add "missing-declaration": "error" or "svelte3/missing-declaration": "error" to my .eslintrc.json rules, I will get error Definition for rule 'missing-declaration' was not found
I think that it should be documented how to override linter rules and possibly even have some list of rules that we can use.

@th0rgall
Copy link

th0rgall commented Dec 15, 2022

I was trying to figure out how to do this too. These docs seemed relevant: https://eslint.org/docs/latest/user-guide/configuring/rules#rules-from-plugins

For my specific problem though (disabling svelte(security-anchor-rel-noreferrer) warnings in VSCode), I figured out there are more variables at play beyond this plugin:

  • the Svelte VSCode extension
  • the Svelte language server

When adding ESLint rules, none of the following worked for me to remove warning from VSCode, neither when adding to the top-level ESLint config or svelte processor overrides entry:

rules: {
    'svelte3(security-anchor-rel-noreferrer)': 'off',
    'svelte/security-anchor-rel-noreferrer': 'off',
    'svelte3/security-anchor-rel-noreferrer': 'off',
    'security-anchor-rel-noreferrer': 'off',
    'svelte(security-anchor-rel-noreferrer)': 'off',
    'svelte3/svelte3/svelte3(security-anchor-rel-noreferrer)': 'off',
    'svelte3/svelte3/security-anchor-rel-noreferrer': 'off'
}

However, configuring the Svelte extension like this removed the warnings:

// .vscode/settings.json
{
  "svelte.plugin.svelte.compilerWarnings": {
    "security-anchor-rel-noreferrer": "ignore"
  },
}

More configuration (outside of ESLint) is possible, I used these links as references:

  1. Use onwarn and other options from svelte.config.js for every tool language-tools#855
  2. https://issueantenna.com/repo/sveltejs/language-tools/issues/650

Particularly, that first reference mentions that you can remove ESLint warnings like this in your ESLint config. I haven't tested this yet:

settings: {
  'svelte3/ignore-warnings': ({ code }) => code === 'a11y-no-onchange',
  // ...
},

@josefaidt
Copy link

I'm also stumped on this, but for an issue related to using web components. I don't want to remove or disable the a11y rules, but rather configure them to recognize web components by prefix
image

@mckravchyk
Copy link

mckravchyk commented Dec 27, 2022

I was trying to get rid of missing-declarations rule and svelte3/ignore-warnings seems to work.

It's somewhat buggy in VS Code though. Whenever I introduce new code that violates the rule, there will be a warning until it's restarted.

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

No branches or pull requests

4 participants