Skip to content

Commit

Permalink
Disallow forced-color-adjust
Browse files Browse the repository at this point in the history
Fixes #32
Update test snapshot for better granularity on rule check counts
  • Loading branch information
LB Johnston authored and thibaudcolas committed Jul 20, 2023
1 parent 87b9acd commit 95d1890
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Our default export contains all of our Stylelint rules, along with specific plug
| [`no-invalid-position-at-import-rule`][30] | `{"ignoreAtRules":["use","forward"]}` |
| [`no-irregular-whitespace`][31] | Enabled |
| [`order/order`][32] | `[{"name":"include","type":"at-rule"},"declarations"]` |
| [`property-disallowed-list`][33] | `["/left/","/right/","text-transform"]` |
| [`property-disallowed-list`][33] | `["/forced-color-adjust/","/left/","/right/","text-transform"]` |
| [`property-no-unknown`][34] | Enabled |
| [`property-no-vendor-prefix`][35] | Enabled |
| [`rule-empty-line-before`][36] | `"always", {"except":["after-single-line-comment","first-nested"]}` |
Expand Down
46 changes: 23 additions & 23 deletions __tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`flags warnings with invalid css did error 1`] = `
[
"order/order",
"scale-unlimited/declaration-strict-value",
"scss/selector-no-union-class-name",
"scss/at-rule-no-unknown",
"scss/comment-no-empty",
"block-no-empty",
"color-named",
"comment-no-empty",
"declaration-block-no-duplicate-properties",
"declaration-property-value-allowed-list",
"declaration-property-value-disallowed-list",
"length-zero-no-unit",
"max-nesting-depth",
"property-disallowed-list",
"rule-empty-line-before",
"selector-attribute-name-disallowed-list",
"selector-class-pattern",
"selector-max-combinators",
"selector-max-id",
"selector-max-specificity",
"unit-no-unknown",
]
{
"block-no-empty": 1,
"color-named": 1,
"comment-no-empty": 1,
"declaration-block-no-duplicate-properties": 1,
"declaration-property-value-allowed-list": 2,
"declaration-property-value-disallowed-list": 3,
"length-zero-no-unit": 1,
"max-nesting-depth": 1,
"order/order": 1,
"property-disallowed-list": 3,
"rule-empty-line-before": 8,
"scale-unlimited/declaration-strict-value": 9,
"scss/at-rule-no-unknown": 1,
"scss/comment-no-empty": 1,
"scss/selector-no-union-class-name": 1,
"selector-attribute-name-disallowed-list": 1,
"selector-class-pattern": 2,
"selector-max-combinators": 2,
"selector-max-id": 1,
"selector-max-specificity": 5,
"unit-no-unknown": 1,
}
`;
14 changes: 11 additions & 3 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,17 @@ describe('flags warnings with invalid css', () => {
expect(data.errored).toBeTruthy();

// output unique error names to a snapshot
expect([
...new Set(data.results[0].warnings.map(({ rule }) => rule)),
]).toMatchSnapshot();
expect(
data.results[0].warnings
.map(({ rule }) => rule)
.reduce(
(rulesWithCount, rule) => ({
...rulesWithCount,
[rule]: (rulesWithCount[rule] || 0) + 1,
}),
{},
),
).toMatchSnapshot();

done();
});
Expand Down
1 change: 1 addition & 0 deletions __tests__/scss-invalid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
float: left;
margin-right: 1em;
text-align: right;
forced-color-adjust: none;
@include optionalItem; // should not be at the bottom
}

Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ module.exports = {
'declarations',
],
'property-disallowed-list': [
// There are very few cases where it’s the correct approach.
'/forced-color-adjust/',
// Disallow positioning with physical properties. Use logical ones instead.
'/left/',
'/right/',
Expand Down

0 comments on commit 95d1890

Please sign in to comment.