@justeattakeaway/stylelint-config-pie 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [Fixed] - load extra tokens from pie-css correctly ([#2725](https://github.com/justeattakeaway/pie/pull/2725)) by [@raoufswe](https://github.com/raoufswe)
8
+
9
+ ## 0.9.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [Fixed] - enable pie-design-tokens rule and fix violations ([#2720](https://github.com/justeattakeaway/pie/pull/2720)) by [@raoufswe](https://github.com/raoufswe)
14
+
3
15
  ## 0.9.0
4
16
 
5
17
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/stylelint-config-pie",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Shareable Stylelint config for use with any front-end web projects across JET.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -67,13 +67,16 @@ function getTokens () {
67
67
  try {
68
68
  const loadFile = (path) => readFileSync(require.resolve(path), 'utf8');
69
69
 
70
- const validTokensFromCSS = parseTokensFromCSS(loadFile('@justeat/pie-design-tokens/dist/jet.css'));
71
- parseTokensFromCSS(loadFile('@justeat/pie-design-tokens/dist/jet-hsl-colors.css'), validTokensFromCSS);
70
+ let validTokensFromCSS;
72
71
 
73
72
  try {
74
- // pie-css defines extra tokens (e.g. z-index). Only loaded if installed.
75
- parseTokensFromCSS(loadFile('@justeattakeaway/pie-css/css/input.css'), validTokensFromCSS);
76
- } catch { /* skip if not installed */ }
73
+ // pie-css defines all design tokens and extra tokens (e.g. z-index). Use it as a source of truth if available.
74
+ validTokensFromCSS = parseTokensFromCSS(loadFile('@justeattakeaway/pie-css/dist/index.css'));
75
+ } catch {
76
+ // Fall back to the design-tokens package.
77
+ validTokensFromCSS = parseTokensFromCSS(loadFile('@justeat/pie-design-tokens/dist/jet.css'));
78
+ parseTokensFromCSS(loadFile('@justeat/pie-design-tokens/dist/jet-hsl-colors.css'), validTokensFromCSS);
79
+ }
77
80
 
78
81
  const metadata = JSON.parse(loadFile('@justeat/pie-design-tokens/metadata/tokensMetadata.json'));
79
82
  const tokens = new Map();
@@ -100,9 +103,11 @@ function reportTokenIssues (decl, result, tokens, validTokensFromCSS) {
100
103
  while (match !== null) {
101
104
  const [token, tokenWithoutPrefix] = match;
102
105
  const tokenInfo = tokens.get(tokenWithoutPrefix);
106
+ const isMotion = tokenInfo?.category === 'motion';
107
+ const isGlobalFontFamily = tokenWithoutPrefix.startsWith('font-family');
103
108
 
104
- // Skip motion as no alias tokens exist for this category
105
- if (tokenInfo?.isGlobal && tokenInfo.category !== 'motion') {
109
+ // Skip motion as no alias tokens exist for it and global font family tokens as they might be used globally when defining @font faces.
110
+ if (tokenInfo?.isGlobal && !isMotion && !isGlobalFontFamily) {
106
111
  report({
107
112
  ruleName,
108
113
  result,