sveltejs / eslint-plugin-svelte3

An ESLint plugin for Svelte v3 components.
MIT License
373 stars 44 forks source link

No documentation how to override rules #193

Open ToP29 opened 2 years ago

ToP29 commented 2 years ago

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 commented 1 year ago

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:

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. https://github.com/sveltejs/language-tools/issues/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 commented 1 year ago

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 commented 1 year ago

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.