CSS linting for React components library - #834
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Stylelint-based CSS validation to the React component library and integrates it into existing CI linting.
Changes:
- Adds Stylelint configuration and dependencies.
- Updates lint scripts and documentation.
- Normalizes existing CSS to satisfy lint rules.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/react-components/stylelint.config.mjs |
Defines CSS lint rules. |
packages/react-components/package.json |
Adds Stylelint dependencies and scripts. |
packages/react-components/package-lock.json |
Locks new dependencies. |
packages/react-components/README.md |
Documents lint commands. |
packages/react-components/src/components/AccordionGroup/AccordionGroup.css |
Simplifies logical margins. |
packages/react-components/src/components/AlertBanner/AlertBanner.css |
Consolidates icon alignment. |
packages/react-components/src/components/AlertDialog/AlertDialog.css |
Consolidates icon alignment. |
packages/react-components/src/components/Calendar/Calendar.css |
Uses flex-flow shorthand. |
packages/react-components/src/components/Footer/Footer.css |
Modernizes layout and media syntax. |
packages/react-components/src/components/Header/Header.css |
Uses border shorthand. |
packages/react-components/src/components/Icons/SvgBcLogo/SvgBcLogo.css |
Normalizes zero and color values. |
packages/react-components/src/components/Radio/Radio.css |
Uses modern pseudo-element syntax. |
packages/react-components/src/components/RadioGroup/RadioGroup.css |
Removes a duplicate selector. |
packages/react-components/src/components/Tag/Tag.css |
Replaces a mistyped radius variable. |
packages/react-components/src/components/ToggleButton/ToggleButton.css |
Uses flex-flow shorthand. |
Files not reviewed (1)
- packages/react-components/package-lock.json: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
mkernohanbc
approved these changes
Aug 17, 2026
mkernohanbc
left a comment
Contributor
There was a problem hiding this comment.
This all looks eminently sensible to me. I also agree that no-descending-specificity looks like a good guardrail — I've added that refactoring work to the backlog in #841.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As part of investigating #833, I found we were not codifying our CSS conventions in the React components library. This pull request adds linting via
stylelintwith a rule set that extends theirstylelint-config-standardand adds our own rules to it. The currentnpm run lint:cssscript should return no errors. Thelintscript is updated to run both our TypeScript linting and CSS linting, so the existing GitHub Actions workflow that runsnpm run lintwill continue to work as expected.Changes to existing styles to pass new rules
None of these changes will have any visual effect:
AccordionGroup.cssdeclaration-block-no-redundant-longhand-propertiesmargin-block-startandmargin-block-endAlertBanner.cssdeclaration-block-no-redundant-longhand-propertiesalign-selfandjustify-selfAlertDialog.cssdeclaration-block-no-redundant-longhand-propertiesalign-selfandjustify-selfCalendar.cssdeclaration-block-no-redundant-longhand-propertiesalign-selfandjustify-selfFooter.cssdeclaration-block-no-redundant-longhand-propertiesflex-directionandflex-wraptoflex-flowrow-gapandcolumn-gaptogapgrid-column-gapandgrid-row-gaptogrid-gapproperty-no-deprecatedgapinstead of deprecatedgrid-gapmedia-feature-range-notationwidth <=instead ofmax-widthHeader.cssdeclaration-block-no-redundant-longhand-propertiesborder-bottom-color,border-bottom-style, andborder-bottom-widthtoborder-bottomSvgBcLogo.csscolor-hex-length#fffto match default rulelength-zero-no-unit0to match default ruleRadio.cssselector-pseudo-element-colon-notation::beforepseudo-elementRadioGroup.cssno-duplicate-selectorsTag.csscustom-property-patternToggleButton.cssdeclaration-block-no-redundant-longhand-propertiesflex-directionandflex-wraptoflex-flowFuture work
I added one TODO in the rule set here: https://github.com/bcgov/design-system/blob/feature/react-components-css-linting/packages/react-components/stylelint.config.mjs#L18
I think that
no-descending-specificityis a good rule to follow, but there's too much refactoring to include it in this PR. We can endeavour to tighten up that rule after fixing the issues it flags. See below for example output with that rule turned on.