Skip to content

Commit 72edf46

Browse files
committed
migrate to stylelint 16
1 parent e8a2c00 commit 72edf46

22 files changed

+1847
-14447
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
node: [16, 18, 20]
14+
node: [18, 20, 'lts/*']
1515
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
1818
with:
1919
node-version: ${{ matrix.node }}
2020

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
node_modules
2-
dist
32
*.log*
43
.eslintcache

.rollup.mjs

Lines changed: 0 additions & 19 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changes to Stylelint Value No Unknown Custom Properties
22

3+
### 6.0.0 (Dec 28, 2023)
4+
5+
- Updated: peer `stylelint` to >=16 (breaking)
6+
- Removed `false` option, use `null` instead
7+
38
### 5.0.0 (November 6, 2023)
49

510
- Ensure this can work with Stylelint 15 too. (thanks [@alex-e-leon](https://github.com/alex-e-leon)!)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add [Stylelint Value No Unknown Custom Properties] to your [stylelint configurat
2323
"stylelint-value-no-unknown-custom-properties"
2424
],
2525
"rules": {
26-
"csstools/value-no-unknown-custom-properties": true || false || null
26+
"csstools/value-no-unknown-custom-properties": true || null
2727
}
2828
}
2929
```
@@ -79,9 +79,9 @@ While the following patterns are considered violations:
7979

8080
Custom Properties can be imported using the second option.
8181

82-
### false
82+
### `null`
8383

84-
If the first option is `false` or `null`, then
84+
If the first option is `null`, then
8585
[Stylelint Value No Unknown Custom Properties] does nothing.
8686

8787
---

test.js renamed to index.test.mjs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
const { messages, ruleName } = require('.');
2-
const skipBasicChecks = true;
1+
2+
import { testRule } from 'stylelint-test-rule-node';
3+
import plugin from './src/index.mjs';
4+
5+
const rule = plugin.rule;
6+
const messages = plugin.rule.messages;
7+
38
let accept = [], reject = [];
49

510
/* Test basic checks
611
/* ========================================================================== */
712

8-
testRule({ plugins: ['.'], ruleName, config: null });
9-
testRule({ plugins: ['.'], ruleName, config: false });
10-
testRule({ plugins: ['.'], ruleName, config: true });
13+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: null, accept: [{ code: '' }] });
14+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: true, accept: [{ code: '' }] });
1115

1216
/* Test disabled
1317
/* ========================================================================== */
@@ -16,7 +20,7 @@ accept = [
1620
{ code: 'body { color: var(--brand-blue); }', description: 'ignored custom property' },
1721
];
1822

19-
testRule({ plugins: ['.'], ruleName, skipBasicChecks, config: null, accept });
23+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: null, accept });
2024

2125
/* Test enabled
2226
/* ========================================================================== */
@@ -36,7 +40,7 @@ reject = [
3640
{ code: '@import \'./test/import-custom-properties123.css\'; body { color: var(--brand-red); }', message: messages.unexpected('--brand-red', 'color') },
3741
];
3842

39-
testRule({ plugins: ['.'], ruleName, skipBasicChecks, config: true, accept, reject });
43+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: true, accept, reject });
4044

4145

4246
/* Test fallbacks
@@ -48,7 +52,7 @@ accept = [
4852
reject = [
4953
{ code: 'body { color: var(--brand-blue, var(--brand-red)); }', message: messages.unexpected('--brand-red', 'color') },
5054
];
51-
testRule({ plugins: ['.'], ruleName, skipBasicChecks, config: true, accept, reject });
55+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: true, accept, reject });
5256

5357
/* Test enabled: not var()s
5458
/* ========================================================================== */
@@ -58,7 +62,7 @@ accept = [
5862
{ code: 'body { color: var(); }' },
5963
];
6064

61-
testRule({ plugins: ['.'], ruleName, skipBasicChecks, config: true, accept });
65+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: true, accept });
6266

6367
/* Test enabled: { importFrom }
6468
/* ========================================================================== */
@@ -73,58 +77,61 @@ reject = [
7377

7478
testRule({
7579
plugins: ['.'],
76-
ruleName,
80+
ruleName: rule.ruleName,
7781
config: [true, {
7882
importFrom: {
7983
customProperties: {
8084
'--brand-blue': '#fff',
8185
},
8286
},
8387
}],
84-
skipBasicChecks,
88+
accept,
89+
reject,
8590
});
8691

8792
accept = [
88-
{ code: 'body { background-color: var(--brand-red); background: var(--brand-green); border-color: var(--brand-white); color: var(--brand-blue); }' },
93+
{ code: 'body { background-color: var(--brand-red); background: var(--brand-green); color: var(--brand-blue); }' },
8994
];
9095
reject = [
9196
{ code: 'body { color: var(--brand-blu); }', message: messages.unexpected('--brand-blu', 'color') },
9297
{ code: 'body { color: var(--brand-bluez); }', message: messages.unexpected('--brand-bluez', 'color') },
9398
];
9499

95-
/*
96-
FIXME: This creates a segmentation fault in node
97-
98100
testRule({
99101
plugins: ['.'],
100-
ruleName,
102+
ruleName: rule.ruleName,
101103
config: [true, {
102104
importFrom: [
103-
'./test/import-custom-properties.js',
104105
'./test/import-custom-properties.json',
105106
'./test/import-custom-properties.css',
106107
],
107108
}],
108-
skipBasicChecks,
109109
accept,
110110
reject,
111111
});
112112

113+
accept = [
114+
{ code: 'body { border-color: var(--brand-white); }' },
115+
];
116+
117+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/dummy-module-package/import-custom-properties.js'] }], accept, reject });
118+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/dummy-package/import-custom-properties.js'] }], accept, reject });
119+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/import-custom-properties.cjs'] }], accept, reject });
120+
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/import-custom-properties.mjs'] }], accept, reject });
121+
113122
accept = [
114123
{ code: '@import "import-custom-properties-absolute.css"; body { background-color: var(--brand-red); background: var(--brand-green); }' },
115124
];
116125
reject = [];
117126

118127
testRule({
119128
plugins: ['.'],
120-
ruleName,
129+
ruleName: rule.ruleName,
121130
config: [true, {
122131
resolver: {
123132
paths: './test',
124133
},
125134
}],
126-
skipBasicChecks,
127135
accept,
128136
reject,
129137
});
130-
*/

0 commit comments

Comments
 (0)