Skip to content

Commit 9ab9313

Browse files
chloericesam-b-roseaaronccasanova
authored
[stylelint-polaris] Disallow component overrides using selector-disallowed-list (#8467)
### WHY are these changes introduced? Fixes #7850 ### WHAT is this pull request doing? This PR configures the `selector-disallowed-list` rule in `@shopify/stylelint-polaris` to disallow Polaris React component style overrides via classname. This will make the tracking of overrides much more performant than manually finding and counting them as we do currently. <img width="844" alt="Screenshot 2023-02-22 at 5 37 31 PM" src="https://user-images.githubusercontent.com/18447883/220776076-f558a3cd-8a31-4c2b-95a3-b51fa9f813b9.png"> ### 🎩 checklist - [x] Tested in polaris-react SCSS files - [ ] Added rule documentation - [ ] Tested in Polaris Coverage (wip) --------- Co-authored-by: Sam Rose <sam.rose@shopify.com> Co-authored-by: Aaron Casanova <32409546+aaronccasanova@users.noreply.github.com>
1 parent 3840f49 commit 9ab9313

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changeset/thin-tools-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/stylelint-polaris': major
3+
---
4+
5+
Configured `selector-disallowed-list` to disallow Polaris component class name overrides

stylelint-polaris/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ const stylelintPolarisCoverageOptions = {
371371
},
372372
],
373373
conventions: {
374+
'selector-disallowed-list': [
375+
[/class[*^~]?='Polaris-[a-z_-]+'/gi],
376+
{
377+
message:
378+
'Overriding Polaris styles is disallowed. Please consider contributing instead',
379+
},
380+
],
374381
'polaris/custom-property-allowed-list': {
375382
// Allows definition of custom properties not prefixed with `--p-`, `--pc-`, or `--polaris-version-`
376383
allowedProperties: [/--(?!(p|pc|polaris-version)-).+/],

0 commit comments

Comments
 (0)