Skip to content

Commit cf70e1d

Browse files
lb-LB Johnston
andauthored
Prevent forced-color-adjust usage (#35). Fix #32
Co-authored-by: LB Johnston <lb.johnston@virginaustralia.com>
1 parent 87b9acd commit cf70e1d

5 files changed

Lines changed: 38 additions & 27 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Our default export contains all of our Stylelint rules, along with specific plug
7777
| [`no-invalid-position-at-import-rule`][30] | `{"ignoreAtRules":["use","forward"]}` |
7878
| [`no-irregular-whitespace`][31] | Enabled |
7979
| [`order/order`][32] | `[{"name":"include","type":"at-rule"},"declarations"]` |
80-
| [`property-disallowed-list`][33] | `["/left/","/right/","text-transform"]` |
80+
| [`property-disallowed-list`][33] | `["/forced-color-adjust/","/left/","/right/","text-transform"]` |
8181
| [`property-no-unknown`][34] | Enabled |
8282
| [`property-no-vendor-prefix`][35] | Enabled |
8383
| [`rule-empty-line-before`][36] | `"always", {"except":["after-single-line-comment","first-nested"]}` |
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`flags warnings with invalid css did error 1`] = `
4-
[
5-
"order/order",
6-
"scale-unlimited/declaration-strict-value",
7-
"scss/selector-no-union-class-name",
8-
"scss/at-rule-no-unknown",
9-
"scss/comment-no-empty",
10-
"block-no-empty",
11-
"color-named",
12-
"comment-no-empty",
13-
"declaration-block-no-duplicate-properties",
14-
"declaration-property-value-allowed-list",
15-
"declaration-property-value-disallowed-list",
16-
"length-zero-no-unit",
17-
"max-nesting-depth",
18-
"property-disallowed-list",
19-
"rule-empty-line-before",
20-
"selector-attribute-name-disallowed-list",
21-
"selector-class-pattern",
22-
"selector-max-combinators",
23-
"selector-max-id",
24-
"selector-max-specificity",
25-
"unit-no-unknown",
26-
]
4+
{
5+
"block-no-empty": 1,
6+
"color-named": 1,
7+
"comment-no-empty": 1,
8+
"declaration-block-no-duplicate-properties": 1,
9+
"declaration-property-value-allowed-list": 2,
10+
"declaration-property-value-disallowed-list": 3,
11+
"length-zero-no-unit": 1,
12+
"max-nesting-depth": 1,
13+
"order/order": 1,
14+
"property-disallowed-list": 3,
15+
"rule-empty-line-before": 8,
16+
"scale-unlimited/declaration-strict-value": 9,
17+
"scss/at-rule-no-unknown": 1,
18+
"scss/comment-no-empty": 1,
19+
"scss/selector-no-union-class-name": 1,
20+
"selector-attribute-name-disallowed-list": 1,
21+
"selector-class-pattern": 2,
22+
"selector-max-combinators": 2,
23+
"selector-max-id": 1,
24+
"selector-max-specificity": 5,
25+
"unit-no-unknown": 1,
26+
}
2727
`;

__tests__/index.test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,17 @@ describe('flags warnings with invalid css', () => {
4949
expect(data.errored).toBeTruthy();
5050

5151
// output unique error names to a snapshot
52-
expect([
53-
...new Set(data.results[0].warnings.map(({ rule }) => rule)),
54-
]).toMatchSnapshot();
52+
expect(
53+
data.results[0].warnings
54+
.map(({ rule }) => rule)
55+
.reduce(
56+
(rulesWithCount, rule) => ({
57+
...rulesWithCount,
58+
[rule]: (rulesWithCount[rule] || 0) + 1,
59+
}),
60+
{},
61+
),
62+
).toMatchSnapshot();
5563

5664
done();
5765
});

__tests__/scss-invalid.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
float: left;
8282
margin-right: 1em;
8383
text-align: right;
84+
forced-color-adjust: none;
8485
@include optionalItem; // should not be at the bottom
8586
}
8687

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ module.exports = {
4242
'declarations',
4343
],
4444
'property-disallowed-list': [
45+
// There are very few cases where it’s the correct approach.
46+
'/forced-color-adjust/',
4547
// Disallow positioning with physical properties. Use logical ones instead.
4648
'/left/',
4749
'/right/',

0 commit comments

Comments
 (0)