Skip to content

Commit 2b78397

Browse files
feat: Update the custom Stylelint plugin to use JSON tokens (#4828)
1 parent 9c1f44b commit 2b78397

File tree

4 files changed

+25
-39
lines changed

4 files changed

+25
-39
lines changed

.stylelintrc.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
1+
const fs = require('fs');
12
const path = require('path');
23

3-
const {tokenList} = require('./build/cjs/token-list');
4+
const tokenGroupsDir = path.join(__dirname, './src/tokens/token-groups');
5+
6+
/**
7+
* Allowed Polaris token custom properties.
8+
*
9+
* Result: ['--p-background', '--p-text', etc...]
10+
*/
11+
const polarisTokenCustomProperties = Array.from(
12+
new Set(
13+
fs
14+
.readdirSync(tokenGroupsDir)
15+
.map((file) => {
16+
const tokenGroup = require(path.join(tokenGroupsDir, file));
17+
18+
return Object.keys(tokenGroup).map((token) => `--p-${token}`);
19+
})
20+
.flat(),
21+
),
22+
);
423

524
/**
625
* Allowed custom property names in Polaris component styles.
@@ -19,7 +38,10 @@ module.exports = {
1938
polarisComponentCustomProperties,
2039
],
2140
allowedValues: {
22-
'/.+/': [polarisComponentCustomProperties, ...tokenList],
41+
'/.+/': [
42+
polarisComponentCustomProperties,
43+
...polarisTokenCustomProperties,
44+
],
2345
},
2446
},
2547
},

loom.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import type {} from '@shopify/loom-plugin-jest';
2727
// eslint-disable-next-line import/no-default-export
2828
export default createPackage((pkg) => {
2929
pkg.entry({root: './src/index.ts'});
30-
pkg.entry({name: 'token-list', root: './src/token-list.ts'});
3130
pkg.use(
3231
buildLibrary({
3332
rootEntrypoints: false,

src/components/Frame/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ function FrameExample() {
693693
>
694694
<Frame
695695
logo={logo}
696-
offset="6rem"
696+
offset="60px"
697697
globalRibbon={
698698
<div style={{background: '#C0FFEE', padding: '30px'}}>
699699
Global ribbon

src/token-list.ts

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

0 commit comments

Comments
 (0)