Svelte 出现 Unused css selector

501 阅读1分钟

Svelte SvelteKit 出现a11y-invalid-attribute css-unused-selector a11y-label-has-associated-control unused-export-let a11y-missing-attribute a11y-missing-content a11y-mouse-events-have-key-events 等等提示。出现此类提示的原因很多,虽然不影响使用,但是对于打包查找真正的报错太有影响。这里我们可以先选择禁用此类提示。

当然还是需要去了解一下 a11y

无障碍(A11Y)风格指南

配置 svelte.config.js

当错误不同的时候 把code 输出一下,复制到禁用提示的数组中即可。

const config = {
    onwarn: (warning, handler) => {
        const { code, frame } = warning;
        // console.log('-----------------------------', code, '-----------------------------')
        const _warning = [
            'a11y-invalid-attribute',
            'css-unused-selector',
            'a11y-label-has-associated-control',
            'unused-export-let',
            'a11y-missing-attribute',
            'a11y-missing-content',
            'a11y-mouse-events-have-key-events'
        ]
        if (_warning.includes(code))
            return;

        handler(warning);
    },
    kit: {}
}
export default config;

技术支持 Svelte Ui 框架

有无兴趣靓仔?了解一下:BeerUi