Skip to content

Commit

Permalink
migrate to stylelint 16
Browse files Browse the repository at this point in the history
  • Loading branch information
romainmenke committed Dec 28, 2023
1 parent e8a2c00 commit 72edf46
Show file tree
Hide file tree
Showing 22 changed files with 1,847 additions and 14,447 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18, 20]
node: [18, 20, 'lts/*']
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
dist
*.log*
.eslintcache
19 changes: 0 additions & 19 deletions .rollup.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changes to Stylelint Value No Unknown Custom Properties

### 6.0.0 (Dec 28, 2023)

- Updated: peer `stylelint` to >=16 (breaking)
- Removed `false` option, use `null` instead

### 5.0.0 (November 6, 2023)

- Ensure this can work with Stylelint 15 too. (thanks [@alex-e-leon](https://github.com/alex-e-leon)!)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Add [Stylelint Value No Unknown Custom Properties] to your [stylelint configurat
"stylelint-value-no-unknown-custom-properties"
],
"rules": {
"csstools/value-no-unknown-custom-properties": true || false || null
"csstools/value-no-unknown-custom-properties": true || null
}
}
```
Expand Down Expand Up @@ -79,9 +79,9 @@ While the following patterns are considered violations:

Custom Properties can be imported using the second option.

### false
### `null`

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

---
Expand Down
49 changes: 28 additions & 21 deletions test.js → index.test.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const { messages, ruleName } = require('.');
const skipBasicChecks = true;

import { testRule } from 'stylelint-test-rule-node';
import plugin from './src/index.mjs';

const rule = plugin.rule;
const messages = plugin.rule.messages;

let accept = [], reject = [];

/* Test basic checks
/* ========================================================================== */

testRule({ plugins: ['.'], ruleName, config: null });
testRule({ plugins: ['.'], ruleName, config: false });
testRule({ plugins: ['.'], ruleName, config: true });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: null, accept: [{ code: '' }] });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: true, accept: [{ code: '' }] });

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

testRule({ plugins: ['.'], ruleName, skipBasicChecks, config: null, accept });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: null, accept });

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

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


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

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

testRule({ plugins: ['.'], ruleName, skipBasicChecks, config: true, accept });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: true, accept });

/* Test enabled: { importFrom }
/* ========================================================================== */
Expand All @@ -73,58 +77,61 @@ reject = [

testRule({
plugins: ['.'],
ruleName,
ruleName: rule.ruleName,
config: [true, {
importFrom: {
customProperties: {
'--brand-blue': '#fff',
},
},
}],
skipBasicChecks,
accept,
reject,
});

accept = [
{ code: 'body { background-color: var(--brand-red); background: var(--brand-green); border-color: var(--brand-white); color: var(--brand-blue); }' },
{ code: 'body { background-color: var(--brand-red); background: var(--brand-green); color: var(--brand-blue); }' },
];
reject = [
{ code: 'body { color: var(--brand-blu); }', message: messages.unexpected('--brand-blu', 'color') },
{ code: 'body { color: var(--brand-bluez); }', message: messages.unexpected('--brand-bluez', 'color') },
];

/*
FIXME: This creates a segmentation fault in node
testRule({
plugins: ['.'],
ruleName,
ruleName: rule.ruleName,
config: [true, {
importFrom: [
'./test/import-custom-properties.js',
'./test/import-custom-properties.json',
'./test/import-custom-properties.css',
],
}],
skipBasicChecks,
accept,
reject,
});

accept = [
{ code: 'body { border-color: var(--brand-white); }' },
];

testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/dummy-module-package/import-custom-properties.js'] }], accept, reject });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/dummy-package/import-custom-properties.js'] }], accept, reject });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/import-custom-properties.cjs'] }], accept, reject });
testRule({ plugins: ['.'], ruleName: rule.ruleName, config: [true, { importFrom: ['./test/import-custom-properties.mjs'] }], accept, reject });

accept = [
{ code: '@import "import-custom-properties-absolute.css"; body { background-color: var(--brand-red); background: var(--brand-green); }' },
];
reject = [];

testRule({
plugins: ['.'],
ruleName,
ruleName: rule.ruleName,
config: [true, {
resolver: {
paths: './test',
},
}],
skipBasicChecks,
accept,
reject,
});
*/
Loading

0 comments on commit 72edf46

Please sign in to comment.