Vize

css/prefer-nested-selectors

Recommend using CSS nesting for descendant selectors

Bad · Good

Default severity: warning
Presets: opinionated, nuxt
Automatic fix: None; review the suggested change
Applies to: CSS inside SFC style blocks
Options: No rule-specific options. Severity and preset selection are configurable.

Configuration (Vite+)

import { defineConfig } from "@vizejs/vite-plugin/vite-plus";

export default defineConfig({
  lint: {
    vize: {
      "preset": "incremental",
      "rules": {
        "css/prefer-nested-selectors": "warn"
      }
    },
  },
});
vp run lint

Bad

The .card .title descendant selector repeats the parent selector in a flat rule.

<style scoped>
.card .title { color: red; }
</style>

Good

The .title rule is nested inside .card, keeping the parent-child styling relationship together.

<style scoped>
.card { .title { color: red; } }
</style>

Good avoids this rule's finding under the configuration above; other rules may still report diagnostics.

Implementation · All rules