UnoCSS Preset Block.
- 🔥 Disable non-standard unocss class names
pnpm i -D unocss-preset-block unocss
// uno.config.ts
import { defineConfig } from 'unocss'
import { presetBlock } from 'unocss-preset-block'
export default defineConfig({
presets: [
// ...
presetBlock(),
],
})
Disable px/rem unit
<!-- bad -->
<div class="m-1rem">...</div>
<!-- good -->
<div class="m-4">...</div>
Disable magic-number
<!-- bad -->
<div class="text-3">...</div>
<!-- good -->
<div class="text-xs">...</div>
Disable consecutive dashes
<!-- bad -->
<div class="m--3">...</div>
<!-- good -->
<div class="-m-3">...</div>
Recommended to work with @unocss/eslint-plugin
// .eslintrc.js
module.exports = {
plugins: [
// ...
'@unocss',
],
rules: {
// ...
'@unocss/blocklist': ['error']
},
}