{"id":555,"hash":"881e58fa10158639887c5472a8dc5e6a453ad4885cd1644988b3babc342427a1","pattern":"How to disable Svelte warning &quot;Unused CSS selector&quot;","full_message":"The approach of my graphic designer for formatting our Svelte application is having a systematic set of classes in LESS, importing the appropriate LESS file in the component or page, and then applying those classes wherever he needs them. As a result we have an abundant amount of unused classes, which we might use at a later point.\n\nThe great thing about Svelte is that unused CSS is not compiled, so all those (yet) redundant classes are not in the way anyway. However, whenever we compile, we get a big list of warnings: \"Unused CSS selector\". This is a major nuisance, because it makes it harder to notice when an actual error is created. Plus it just looks ugly.\n\nI checked the documentation and there is a way to suppress warnings, but that only works for the HTML part.\n\nIs there any way of getting rid of these warnings? Note that we use Svelte Preprocess.","ecosystem":"npm","package_name":"svelte","package_version":null,"solution":"Updated solution compatible with Svelte 5 and SvelteKit 2 for suppress css-unused-selector and a11y-invalid-attribute. Only need to edit svelte.config.js\n\nNote: one of the previous anwser uses css-unused-selector (with adash) which no longer appears to work. The correct option name is  css_unused_selector (with an underscore).\n\n// svelte.config.js\nimport adapter from '@sveltejs/adapter-auto';\n/** @type {import('@sveltejs/kit').Config} */\nconst config = {\n    kit: {\n        adapter: adapter()\n    },\n    onwarn: (warning, handler) => {\n        const { code, frame } = warning;\n        // console.log(code); // <= uncomment to check other warnings\n        if (code === \"css_unused_selector\")\n            return;\n        if (code === \"a11y_invalid_attribute\")\n            return;\n        handler(warning);\n    }\n};\nexport default config;","confidence":0.7000000000000001,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/60677782/how-to-disable-svelte-warning-unused-css-selector","votes":34,"created_at":"2026-04-19T04:51:20.926870+00:00","updated_at":"2026-04-19T04:51:20.926870+00:00"}