1---2name: dotnet-stylelint3description: Use Stylelint in .NET repositories that ship CSS, SCSS, or other stylesheet assets alongside web frontends. Use when a repo needs a dedicated CLI lint gate for selectors, properties, duplicate styles, naming conventions, or design-system rule enforcement.4---56# Stylelint for Stylesheets in .NET Repositories78## Trigger On910- the repo has `stylelint.config.*`, `.stylelintrc*`, or CSS and SCSS assets under frontend folders11- the user asks for CSS linting, duplicate style cleanup, naming convention enforcement, or design-system guardrails12- the repo needs a stylesheet gate beyond formatting alone1314## Do Not Use For1516- JavaScript or TypeScript ownership; route that to `dotnet-eslint` or `dotnet-biome`17- runtime accessibility, performance, SEO, or header checks; route that to `dotnet-webhint`18- repos that intentionally use only Biome for CSS linting and do not want a separate stylesheet linter1920## Inputs2122- the nearest `AGENTS.md`23- `package.json`24- `stylelint.config.*` or `.stylelintrc*`25- the stylesheet file types in scope: CSS, SCSS, Less, embedded styles, or generated output2627## Workflow28291. Confirm what Stylelint should own:30 - plain CSS only31 - CSS plus SCSS32 - embedded styles in HTML, Markdown, or framework files332. Prefer repo-local installation and checked-in config.343. Start from a known shared config such as `stylelint-config-standard`, then add syntax-specific packages only when the repo truly needs them.354. Add repeatable scripts to `package.json`, for example:36 - `stylelint "**/*.{css,scss}"`37 - `stylelint "**/*.{css,scss}" --fix`385. Keep ignore patterns explicit so build output, vendored assets, and generated CSS do not pollute the signal.396. Treat autofix as controlled cleanup:40 - run on a bounded scope first41 - inspect the diff42 - rerun the frontend build if the repo compiles styles437. Use Stylelint for semantic CSS and selector policy, not as a replacement for site-level audits.4445## Bootstrap When Missing46471. Detect current state:48 - `rg --files -g 'package.json' -g 'stylelint.config.*' -g '.stylelintrc*'`49 - `rg -n '"stylelint"|"stylelint-config-" --glob 'package.json' .`502. Prefer a repo-local install:51 - `npm install --save-dev stylelint stylelint-config-standard`523. Add syntax packages only when the repo needs them for SCSS or embedded styles.534. Create or refine `stylelint.config.js`, `stylelint.config.mjs`, or the existing config format.545. Add repeatable commands to `AGENTS.md` and `package.json`, then verify with:55 - `npx stylelint "**/*.{css,scss}"`56 - `npx stylelint "**/*.{css,scss}" --fix`576. Return `status: configured` if Stylelint is now wired and repeatable, or `status: improved` if the existing baseline was tightened.587. Return `status: not_applicable` only when another documented tool already owns stylesheet linting and migration is not requested.5960## Handle Failures6162- `Unknown rule` usually means the config expects a plugin or a different Stylelint major version.63- `Unknown word` on SCSS, Vue, or mixed-content files usually means the repo needs the matching custom syntax package instead of plain CSS parsing.64- Massive autofix churn usually means generated assets or third-party CSS slipped into the lint target.65- Design-system rule noise should be handled by tuning the checked-in config, not by skipping the linter entirely.6667## Current 17.8 Guidance6869- Stylelint `17.8.0` adds `languageOptions.directionality`, `property-layout-mappings`, `relative-selector-nesting-notation`, and `selector-no-deprecated`. Re-run the repo baseline after upgrading so any new selector or layout findings are reviewed instead of preserved by default.70- Use `languageOptions.directionality` explicitly when the repo styles bidirectional UI or logical properties. That keeps direction-sensitive rules aligned with the intended writing direction rather than inferred behavior.71- The earlier `*syntax` deprecation under `declaration-property-value-no-unknown` still matters on the 17.x line. If the repo still relies on those options, move the compatibility into `customSyntax` or parser selection instead of extending deprecated rule config.72- Keep repo ignores focused on generated or vendored assets. Re-check any broad ignore globs after upgrading so they are not masking selector or layout regressions that the new rules now catch.7374## Official Sources7576- [Stylelint 17.8.0 release notes](https://github.com/stylelint/stylelint/releases/tag/17.8.0)77- `references/release-notes.md`7879## Deliver8081- explicit stylesheet lint ownership82- checked-in config and repeatable commands83- clear scope boundaries for CSS, SCSS, and generated assets8485## Validate8687- the lint target matches the repo's real stylesheet sources88- ignores exclude generated or vendored assets89- Stylelint ownership does not conflict with Biome without an explicit plan90- fixes were verified against the repo's stylesheet build flow when one exists9192## Ralph Loop93941. Plan: analyze current state, target outcome, constraints, and risks.952. Execute one step and produce a concrete delta.963. Review the result and capture findings.974. Apply fixes in small batches and rerun checks.985. Update the plan after each iteration.996. Repeat until outcomes are acceptable.1007. If a dependency is missing, bootstrap it or return `status: not_applicable` with a reason.101102### Required Result Format103104- `status`: `complete` | `clean` | `improved` | `configured` | `not_applicable` | `blocked`105- `plan`: concise plan and current step106- `actions_taken`: concrete changes made107- `verification`: commands, checks, or review evidence108- `remaining`: unresolved items or `none`109110## Example Requests111112- "Add Stylelint for the SCSS in this ASP.NET Core app."113- "Block duplicate selectors and invalid CSS in CI."114- "Fix the current Stylelint violations without touching generated CSS."115116## References117118- [release-notes.md](references/release-notes.md) - Current 17.8.0 release changes that matter for repo config, rule tuning, and selector/layout validation