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

How to suppress warnings in svelte with sveltekit? #1079

Closed
jonathanblancor opened this issue Jun 28, 2021 · 3 comments
Closed

How to suppress warnings in svelte with sveltekit? #1079

jonathanblancor opened this issue Jun 28, 2021 · 3 comments

Comments

@jonathanblancor
Copy link

jonathanblancor commented Jun 28, 2021

I understand that warnings are disabled when running svelte-check command (with --compiler-warnings css-unused-selector:ignore,unused-export-let:error).

Now, is there a way to integrate this when running svelte-kit dev and disable the warnings in the VS Code console in development?

@dummdidumm
Copy link
Member

Related to #855 . If this is adopted and all tools use that property, this would be the way.

@jonathanblancor
Copy link
Author

Thanks! I'm closing this one then.

@craigcosmo
Copy link

To disable almost all the blue warning in sveltekit, do this

open setting.json in vscode and add this

"svelte.plugin.svelte.compilerWarnings": {
		"css-unused-selector": "ignore",
		"unused-export-let": "ignore",
		"a11y-aria-attributes": "ignore",
		"a11y-incorrect-aria-attribute-type": "ignore",
		"a11y-unknown-aria-attribute": "ignore",
		"a11y-hidden": "ignore",
		"a11y-autocomplete-valid": "ignore",
		"a11y-misplaced-role": "ignore",
		"a11y-no-static-element-interactions": "ignore",
		"a11y-unknown-role": "ignore",
		"a11y-no-abstract-role": "ignore",
		"svelte-ignore a11y-autofocus": "ignore",
		"a11y-no-redundant-roles": "ignore",
		"a11y-role-has-required-aria-props": "ignore",
		"a11y-accesskey": "ignore",
		"a11y-autofocus": "ignore",
		"a11y-misplaced-scope": "ignore",
		"a11y-positive-tabindex": "ignore",
		"a11y-invalid-attribute": "ignore",
		"a11y-missing-attribute": "ignore",
		"a11y-img-redundant-alt": "ignore",
		"a11y-label-has-associated-control": "ignore",
		"a11y-media-has-caption": "ignore",
		"a11y-distracting-elements": "ignore",
		"a11y-structure": "ignore",
		"a11y-mouse-events-have-key-events": "ignore",
		"a11y-missing-content": "ignore",
		"a11y-click-events-have-key-events": "ignore",
		"a11y-no-noninteractive-element-interactions": "ignore"
	},

Then open the svelte.config.js file and do this

const config = {
	preprocess: vitePreprocess(),
	onwarn: (warning, handler) => {
		if (warning.code.startsWith('a11y-')) return
		if (warning.code === 'missing-exports-condition') return
		if (warning.code === 'a11y-no-static-element-interactions') return
		if (warning.code === 'svelte-ignore a11y-autofocus') return
		if (warning.code.startsWith('css-unused-selector')) return
		handler(warning)
	},
	kit: {
		adapter: adapter(),
	},
}

Add more rules you hate into those files/config.

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

3 participants