@atlaskit/eslint-plugin-design-system 13.43.1 → 13.44.0

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,23 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.44.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`bc69c1d196bae`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bc69c1d196bae) -
8
+ Removed `shouldEnforceFallbacks` option from the `use-tokens-typography` rule. The auto-fixer no
9
+ longer adds `fontFallback` imports from `@atlaskit/theme/typography`.
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 13.43.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 13.43.1
4
22
 
5
23
  ### Patch Changes
@@ -14,9 +14,6 @@ var ruleSchema = exports.ruleSchema = {
14
14
  failSilently: {
15
15
  type: 'boolean'
16
16
  },
17
- shouldEnforceFallbacks: {
18
- type: 'boolean'
19
- },
20
17
  enableUnsafeAutofix: {
21
18
  type: 'boolean'
22
19
  },
@@ -32,7 +29,6 @@ var ruleSchema = exports.ruleSchema = {
32
29
  };
33
30
  var defaultConfig = {
34
31
  failSilently: false,
35
- shouldEnforceFallbacks: false,
36
32
  enableUnsafeAutofix: false,
37
33
  patterns: ['style-object', 'font-weight', 'font-family', 'untokenized-properties', 'banned-properties', 'restricted-capitalisation']
38
34
  };
@@ -37,10 +37,7 @@ var StyleObject = exports.StyleObject = {
37
37
  }
38
38
  var fontSizeNode = refs.fontSizeNode,
39
39
  fontSizeRaw = refs.fontSizeRaw,
40
- tokensImportNode = refs.tokensImportNode,
41
- themeImportNode = refs.themeImportNode,
42
- shouldAddFallback = refs.shouldAddFallback,
43
- shouldAddFallbackImport = refs.shouldAddFallbackImport;
40
+ tokensImportNode = refs.tokensImportNode;
44
41
  var fontSizeValue = (0, _utils.normaliseValue)('fontSize', fontSizeRaw);
45
42
 
46
43
  // -- Font weight --
@@ -158,18 +155,15 @@ var StyleObject = exports.StyleObject = {
158
155
  var nodesToReplace = [fontSizeNode, fontWeightNode, lineHeightNode, fontFamilyNode, fontStyleNode, letterSpacingNode].filter(_utils2.notUndefined);
159
156
  var fontFamilyTokenName = fontFamilyToAdd ? "font.family.brand.".concat(fontFamilyToAdd) : '';
160
157
  var fontWeightReplacementToken = shouldAddFontWeight ? (0, _utils2.findFontWeightTokenForValue)(fontWeightValue) : undefined;
161
- var fontWeightReplacement = fontWeightReplacementToken && (0, _utils2.getTokenProperty)('fontWeight', fontWeightReplacementToken.tokenName, shouldAddFallback ? fontWeightValue : undefined);
158
+ var fontWeightReplacement = fontWeightReplacementToken && (0, _utils2.getTokenProperty)('fontWeight', fontWeightReplacementToken.tokenName);
162
159
  var fontFamilyReplacement = fontFamilyToAdd && (fontFamilyToAdd === 'original' ? (0, _utils2.convertPropertyNodeToStringableNode)(
163
160
  // This will always exist if fontFamilyToAdd === 'original', TS can't figure that out.
164
- fontFamilyNode) : (0, _utils2.getTokenProperty)('fontFamily', fontFamilyTokenName, shouldAddFallback ? (0, _utils2.findFontFamilyValueForToken)(fontFamilyTokenName) : undefined));
161
+ fontFamilyNode) : (0, _utils2.getTokenProperty)('fontFamily', fontFamilyTokenName));
165
162
  var fontStyleReplacement = fontStyleToAdd && (0, _utils2.getLiteralProperty)('fontStyle', fontStyleToAdd);
166
163
  var fixerRefs = {
167
164
  matchingToken: matchingToken,
168
165
  nodesToReplace: nodesToReplace,
169
166
  tokensImportNode: tokensImportNode,
170
- themeImportNode: themeImportNode,
171
- shouldAddFallback: shouldAddFallback,
172
- shouldAddFallbackImport: shouldAddFallbackImport,
173
167
  fontWeightReplacement: fontWeightReplacement,
174
168
  fontFamilyReplacement: fontFamilyReplacement,
175
169
  fontStyleReplacement: fontStyleReplacement
@@ -231,40 +225,12 @@ var StyleObject = exports.StyleObject = {
231
225
  success: false
232
226
  };
233
227
  }
234
- var shouldAddFallback = Boolean(config.shouldEnforceFallbacks);
235
- // This exists purely because we're not inlining the fallback values
236
- // and instead referencing a `fontFallback` object that exists in @atlaskit/theme/typography.
237
- // This is a temporary measure until fallbacks are no longer required
238
- var shouldAddFallbackImport = shouldAddFallback && 'full';
239
- var themeImportDeclaration = _astNodes.Root.findImportsByModule((0, _contextCompat.getSourceCode)(context).ast.body, '@atlaskit/theme/typography');
240
- if (themeImportDeclaration.length && shouldAddFallback) {
241
- // Import exists, check if specifier exists
242
- shouldAddFallbackImport = 'specifier';
243
- var fallbackImport = themeImportDeclaration[0].specifiers.find(function (specifier) {
244
- // @atlaskit/theme/typography has no default export so we can safely narrow this type
245
- if (!(0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier')) {
246
- return false;
247
- }
248
- if ('name' in specifier.imported && specifier.imported.name === 'fontFallback') {
249
- return true;
250
- }
251
- return false;
252
- });
253
-
254
- // Exact import already exists, no need to add
255
- if (fallbackImport) {
256
- shouldAddFallbackImport = false;
257
- }
258
- }
259
228
  return {
260
229
  success: true,
261
230
  refs: {
262
231
  fontSizeNode: fontSizeNode,
263
232
  fontSizeRaw: fontSizeRaw,
264
- tokensImportNode: tokensImportDeclaration[0],
265
- themeImportNode: themeImportDeclaration[0],
266
- shouldAddFallback: shouldAddFallback,
267
- shouldAddFallbackImport: shouldAddFallbackImport
233
+ tokensImportNode: tokensImportDeclaration[0]
268
234
  }
269
235
  };
270
236
  },
@@ -273,25 +239,15 @@ var StyleObject = exports.StyleObject = {
273
239
  var matchingToken = refs.matchingToken,
274
240
  nodesToReplace = refs.nodesToReplace,
275
241
  tokensImportNode = refs.tokensImportNode,
276
- themeImportNode = refs.themeImportNode,
277
- shouldAddFallback = refs.shouldAddFallback,
278
- shouldAddFallbackImport = refs.shouldAddFallbackImport,
279
242
  fontWeightReplacement = refs.fontWeightReplacement,
280
243
  fontFamilyReplacement = refs.fontFamilyReplacement,
281
244
  fontStyleReplacement = refs.fontStyleReplacement;
282
245
  var fontSizeNode = nodesToReplace[0];
283
246
  var root = (0, _contextCompat.getSourceCode)(context).ast.body;
284
- var fallbackImport;
285
- if (shouldAddFallbackImport === 'full') {
286
- fallbackImport = (0, _utils2.insertFallbackImportFull)(root, fixer);
287
- } else if (shouldAddFallbackImport === 'specifier') {
288
- fallbackImport = (0, _utils2.insertFallbackImportSpecifier)(fixer, themeImportNode);
289
- }
290
- var fallbackName = (matchingToken.tokenName === 'font.body' ? 'font.body.medium' : matchingToken.tokenName).replace('font', 'fontFallback');
291
- return (!tokensImportNode ? [(0, _utils2.insertTokensImport)(root, fixer)] : []).concat(fallbackImport ? [fallbackImport] : [], nodesToReplace.map(function (node, index) {
247
+ return (!tokensImportNode ? [(0, _utils2.insertTokensImport)(root, fixer)] : []).concat(nodesToReplace.map(function (node, index) {
292
248
  // Replace first node with token, delete remaining nodes. Guaranteed to be fontSize
293
249
  if (index === 0) {
294
- return fixer.replaceText(node, "".concat((0, _utils2.getTokenProperty)('font', matchingToken.tokenName, shouldAddFallback ? fallbackName : undefined, true)));
250
+ return fixer.replaceText(node, "".concat((0, _utils2.getTokenProperty)('font', matchingToken.tokenName, undefined, true)));
295
251
  }
296
252
 
297
253
  // We don't replace fontWeight/fontFamily/fontStyle here in case it occurs before the font property.
@@ -6,14 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.convertPropertyNodeToStringableNode = convertPropertyNodeToStringableNode;
7
7
  exports.defaultFontWeight = void 0;
8
8
  exports.findFontFamilyTokenForValue = findFontFamilyTokenForValue;
9
- exports.findFontFamilyValueForToken = findFontFamilyValueForToken;
10
9
  exports.findFontWeightTokenForValue = findFontWeightTokenForValue;
11
10
  exports.findTypographyTokenForValues = findTypographyTokenForValues;
12
- exports.fontWeightTokens = exports.fontWeightMap = exports.fontFamilyTokens = void 0;
11
+ exports.fontWeightTokens = exports.fontWeightMap = void 0;
13
12
  exports.getLiteralProperty = getLiteralProperty;
14
13
  exports.getTokenProperty = getTokenProperty;
15
- exports.insertFallbackImportFull = insertFallbackImportFull;
16
- exports.insertFallbackImportSpecifier = insertFallbackImportSpecifier;
17
14
  exports.insertTokensImport = insertTokensImport;
18
15
  exports.isTypographyProperty = exports.isFontSizeSmall = exports.isFontSize = exports.isFontFamily = exports.isCodeFontFamily = void 0;
19
16
  exports.isValidPropertyNode = isValidPropertyNode;
@@ -130,16 +127,6 @@ var fontWeightMap = exports.fontWeightMap = {
130
127
  bold: '700'
131
128
  };
132
129
  var defaultFontWeight = exports.defaultFontWeight = fontWeightMap.regular;
133
- var fontFamilyTokens = exports.fontFamilyTokens = _tokensRaw.typography.filter(function (token) {
134
- return token.attributes.group === 'fontFamily';
135
- });
136
- function findFontFamilyValueForToken(tokenName) {
137
- var _fontFamilyTokens$fin;
138
- // Note this will only ever be undefined if the tokens get renamed, and should never happen.
139
- return ((_fontFamilyTokens$fin = fontFamilyTokens.find(function (token) {
140
- return token.cleanName === tokenName;
141
- })) === null || _fontFamilyTokens$fin === void 0 ? void 0 : _fontFamilyTokens$fin.value) || '';
142
- }
143
130
  function findFontFamilyTokenForValue(value) {
144
131
  if (/charlie[\s-]?display/i.test(value)) {
145
132
  return 'font.family.brand.heading';
@@ -211,13 +198,4 @@ function insertTokensImport(root, fixer) {
211
198
  module: '@atlaskit/tokens',
212
199
  specifiers: ['token']
213
200
  }, fixer);
214
- }
215
- function insertFallbackImportFull(root, fixer) {
216
- return _astNodes.Root.insertImport(root, {
217
- module: '@atlaskit/theme/typography',
218
- specifiers: ['fontFallback']
219
- }, fixer);
220
- }
221
- function insertFallbackImportSpecifier(fixer, themeImportNode) {
222
- return _astNodes.Import.insertNamedSpecifiers(themeImportNode, ['fontFallback'], fixer);
223
201
  }
@@ -8,9 +8,6 @@ export const ruleSchema = {
8
8
  failSilently: {
9
9
  type: 'boolean'
10
10
  },
11
- shouldEnforceFallbacks: {
12
- type: 'boolean'
13
- },
14
11
  enableUnsafeAutofix: {
15
12
  type: 'boolean'
16
13
  },
@@ -26,7 +23,6 @@ export const ruleSchema = {
26
23
  };
27
24
  const defaultConfig = {
28
25
  failSilently: false,
29
- shouldEnforceFallbacks: false,
30
26
  enableUnsafeAutofix: false,
31
27
  patterns: ['style-object', 'font-weight', 'font-family', 'untokenized-properties', 'banned-properties', 'restricted-capitalisation']
32
28
  };
@@ -5,7 +5,7 @@ import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
5
5
  import { Object as ASTObject, ObjectEntry, Root } from '../../../ast-nodes';
6
6
  import { getValueForPropertyNode, normaliseValue } from '../../ensure-design-token-usage/utils';
7
7
  import { isDecendantOfGlobalToken, isDecendantOfStyleBlock, isDecendantOfType } from '../../utils/is-node';
8
- import { convertPropertyNodeToStringableNode, defaultFontWeight, findFontFamilyValueForToken, findFontWeightTokenForValue, findTypographyTokenForValues, fontWeightMap, getLiteralProperty, getTokenProperty, insertFallbackImportFull, insertFallbackImportSpecifier, insertTokensImport, isValidPropertyNode, isValidTypographyToken, notUndefined } from '../utils';
8
+ import { convertPropertyNodeToStringableNode, defaultFontWeight, findFontWeightTokenForValue, findTypographyTokenForValues, fontWeightMap, getLiteralProperty, getTokenProperty, insertTokensImport, isValidPropertyNode, isValidTypographyToken, notUndefined } from '../utils';
9
9
  export const StyleObject = {
10
10
  lint(node, {
11
11
  context,
@@ -32,10 +32,7 @@ export const StyleObject = {
32
32
  const {
33
33
  fontSizeNode,
34
34
  fontSizeRaw,
35
- tokensImportNode,
36
- themeImportNode,
37
- shouldAddFallback,
38
- shouldAddFallbackImport
35
+ tokensImportNode
39
36
  } = refs;
40
37
  const fontSizeValue = normaliseValue('fontSize', fontSizeRaw);
41
38
 
@@ -152,18 +149,15 @@ export const StyleObject = {
152
149
  const nodesToReplace = [fontSizeNode, fontWeightNode, lineHeightNode, fontFamilyNode, fontStyleNode, letterSpacingNode].filter(notUndefined);
153
150
  const fontFamilyTokenName = fontFamilyToAdd ? `font.family.brand.${fontFamilyToAdd}` : '';
154
151
  const fontWeightReplacementToken = shouldAddFontWeight ? findFontWeightTokenForValue(fontWeightValue) : undefined;
155
- const fontWeightReplacement = fontWeightReplacementToken && getTokenProperty('fontWeight', fontWeightReplacementToken.tokenName, shouldAddFallback ? fontWeightValue : undefined);
152
+ const fontWeightReplacement = fontWeightReplacementToken && getTokenProperty('fontWeight', fontWeightReplacementToken.tokenName);
156
153
  const fontFamilyReplacement = fontFamilyToAdd && (fontFamilyToAdd === 'original' ? convertPropertyNodeToStringableNode(
157
154
  // This will always exist if fontFamilyToAdd === 'original', TS can't figure that out.
158
- fontFamilyNode) : getTokenProperty('fontFamily', fontFamilyTokenName, shouldAddFallback ? findFontFamilyValueForToken(fontFamilyTokenName) : undefined));
155
+ fontFamilyNode) : getTokenProperty('fontFamily', fontFamilyTokenName));
159
156
  const fontStyleReplacement = fontStyleToAdd && getLiteralProperty('fontStyle', fontStyleToAdd);
160
157
  const fixerRefs = {
161
158
  matchingToken,
162
159
  nodesToReplace,
163
160
  tokensImportNode,
164
- themeImportNode,
165
- shouldAddFallback,
166
- shouldAddFallbackImport,
167
161
  fontWeightReplacement,
168
162
  fontFamilyReplacement,
169
163
  fontStyleReplacement
@@ -227,40 +221,12 @@ export const StyleObject = {
227
221
  success: false
228
222
  };
229
223
  }
230
- const shouldAddFallback = Boolean(config.shouldEnforceFallbacks);
231
- // This exists purely because we're not inlining the fallback values
232
- // and instead referencing a `fontFallback` object that exists in @atlaskit/theme/typography.
233
- // This is a temporary measure until fallbacks are no longer required
234
- let shouldAddFallbackImport = shouldAddFallback && 'full';
235
- const themeImportDeclaration = Root.findImportsByModule(getSourceCode(context).ast.body, '@atlaskit/theme/typography');
236
- if (themeImportDeclaration.length && shouldAddFallback) {
237
- // Import exists, check if specifier exists
238
- shouldAddFallbackImport = 'specifier';
239
- const fallbackImport = themeImportDeclaration[0].specifiers.find(specifier => {
240
- // @atlaskit/theme/typography has no default export so we can safely narrow this type
241
- if (!isNodeOfType(specifier, 'ImportSpecifier')) {
242
- return false;
243
- }
244
- if ('name' in specifier.imported && specifier.imported.name === 'fontFallback') {
245
- return true;
246
- }
247
- return false;
248
- });
249
-
250
- // Exact import already exists, no need to add
251
- if (fallbackImport) {
252
- shouldAddFallbackImport = false;
253
- }
254
- }
255
224
  return {
256
225
  success: true,
257
226
  refs: {
258
227
  fontSizeNode,
259
228
  fontSizeRaw,
260
- tokensImportNode: tokensImportDeclaration[0],
261
- themeImportNode: themeImportDeclaration[0],
262
- shouldAddFallback,
263
- shouldAddFallbackImport
229
+ tokensImportNode: tokensImportDeclaration[0]
264
230
  }
265
231
  };
266
232
  },
@@ -270,26 +236,16 @@ export const StyleObject = {
270
236
  matchingToken,
271
237
  nodesToReplace,
272
238
  tokensImportNode,
273
- themeImportNode,
274
- shouldAddFallback,
275
- shouldAddFallbackImport,
276
239
  fontWeightReplacement,
277
240
  fontFamilyReplacement,
278
241
  fontStyleReplacement
279
242
  } = refs;
280
243
  const fontSizeNode = nodesToReplace[0];
281
244
  const root = getSourceCode(context).ast.body;
282
- let fallbackImport;
283
- if (shouldAddFallbackImport === 'full') {
284
- fallbackImport = insertFallbackImportFull(root, fixer);
285
- } else if (shouldAddFallbackImport === 'specifier') {
286
- fallbackImport = insertFallbackImportSpecifier(fixer, themeImportNode);
287
- }
288
- const fallbackName = (matchingToken.tokenName === 'font.body' ? 'font.body.medium' : matchingToken.tokenName).replace('font', 'fontFallback');
289
- return (!tokensImportNode ? [insertTokensImport(root, fixer)] : []).concat(fallbackImport ? [fallbackImport] : [], nodesToReplace.map((node, index) => {
245
+ return (!tokensImportNode ? [insertTokensImport(root, fixer)] : []).concat(nodesToReplace.map((node, index) => {
290
246
  // Replace first node with token, delete remaining nodes. Guaranteed to be fontSize
291
247
  if (index === 0) {
292
- return fixer.replaceText(node, `${getTokenProperty('font', matchingToken.tokenName, shouldAddFallback ? fallbackName : undefined, true)}`);
248
+ return fixer.replaceText(node, `${getTokenProperty('font', matchingToken.tokenName, undefined, true)}`);
293
249
  }
294
250
 
295
251
  // We don't replace fontWeight/fontFamily/fontStyle here in case it occurs before the font property.
@@ -1,7 +1,7 @@
1
1
  import { callExpression, identifier, isNodeOfType, literal, memberExpression, property } from 'eslint-codemod-utils';
2
2
  import { typographyPalette } from '@atlaskit/tokens/palettes-raw';
3
3
  import { typography as typographyTokens } from '@atlaskit/tokens/tokens-raw';
4
- import { Import, Root } from '../../ast-nodes';
4
+ import { Root } from '../../ast-nodes';
5
5
  export const typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
6
6
  export const isTypographyProperty = propertyName => {
7
7
  return typographyProperties.includes(propertyName);
@@ -73,12 +73,6 @@ export const fontWeightMap = {
73
73
  bold: '700'
74
74
  };
75
75
  export const defaultFontWeight = fontWeightMap.regular;
76
- export const fontFamilyTokens = typographyTokens.filter(token => token.attributes.group === 'fontFamily');
77
- export function findFontFamilyValueForToken(tokenName) {
78
- var _fontFamilyTokens$fin;
79
- // Note this will only ever be undefined if the tokens get renamed, and should never happen.
80
- return ((_fontFamilyTokens$fin = fontFamilyTokens.find(token => token.cleanName === tokenName)) === null || _fontFamilyTokens$fin === void 0 ? void 0 : _fontFamilyTokens$fin.value) || '';
81
- }
82
76
  export function findFontFamilyTokenForValue(value) {
83
77
  if (/charlie[\s-]?display/i.test(value)) {
84
78
  return 'font.family.brand.heading';
@@ -148,13 +142,4 @@ export function insertTokensImport(root, fixer) {
148
142
  module: '@atlaskit/tokens',
149
143
  specifiers: ['token']
150
144
  }, fixer);
151
- }
152
- export function insertFallbackImportFull(root, fixer) {
153
- return Root.insertImport(root, {
154
- module: '@atlaskit/theme/typography',
155
- specifiers: ['fontFallback']
156
- }, fixer);
157
- }
158
- export function insertFallbackImportSpecifier(fixer, themeImportNode) {
159
- return Import.insertNamedSpecifiers(themeImportNode, ['fontFallback'], fixer);
160
145
  }
@@ -8,9 +8,6 @@ export var ruleSchema = {
8
8
  failSilently: {
9
9
  type: 'boolean'
10
10
  },
11
- shouldEnforceFallbacks: {
12
- type: 'boolean'
13
- },
14
11
  enableUnsafeAutofix: {
15
12
  type: 'boolean'
16
13
  },
@@ -26,7 +23,6 @@ export var ruleSchema = {
26
23
  };
27
24
  var defaultConfig = {
28
25
  failSilently: false,
29
- shouldEnforceFallbacks: false,
30
26
  enableUnsafeAutofix: false,
31
27
  patterns: ['style-object', 'font-weight', 'font-family', 'untokenized-properties', 'banned-properties', 'restricted-capitalisation']
32
28
  };
@@ -8,7 +8,7 @@ import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
8
8
  import { Object as ASTObject, ObjectEntry, Root } from '../../../ast-nodes';
9
9
  import { getValueForPropertyNode, normaliseValue } from '../../ensure-design-token-usage/utils';
10
10
  import { isDecendantOfGlobalToken, isDecendantOfStyleBlock, isDecendantOfType } from '../../utils/is-node';
11
- import { convertPropertyNodeToStringableNode, defaultFontWeight, findFontFamilyValueForToken, findFontWeightTokenForValue, findTypographyTokenForValues, fontWeightMap, getLiteralProperty, getTokenProperty, insertFallbackImportFull, insertFallbackImportSpecifier, insertTokensImport, isValidPropertyNode, isValidTypographyToken, notUndefined } from '../utils';
11
+ import { convertPropertyNodeToStringableNode, defaultFontWeight, findFontWeightTokenForValue, findTypographyTokenForValues, fontWeightMap, getLiteralProperty, getTokenProperty, insertTokensImport, isValidPropertyNode, isValidTypographyToken, notUndefined } from '../utils';
12
12
  export var StyleObject = {
13
13
  lint: function lint(node, _ref) {
14
14
  var context = _ref.context,
@@ -32,10 +32,7 @@ export var StyleObject = {
32
32
  }
33
33
  var fontSizeNode = refs.fontSizeNode,
34
34
  fontSizeRaw = refs.fontSizeRaw,
35
- tokensImportNode = refs.tokensImportNode,
36
- themeImportNode = refs.themeImportNode,
37
- shouldAddFallback = refs.shouldAddFallback,
38
- shouldAddFallbackImport = refs.shouldAddFallbackImport;
35
+ tokensImportNode = refs.tokensImportNode;
39
36
  var fontSizeValue = normaliseValue('fontSize', fontSizeRaw);
40
37
 
41
38
  // -- Font weight --
@@ -153,18 +150,15 @@ export var StyleObject = {
153
150
  var nodesToReplace = [fontSizeNode, fontWeightNode, lineHeightNode, fontFamilyNode, fontStyleNode, letterSpacingNode].filter(notUndefined);
154
151
  var fontFamilyTokenName = fontFamilyToAdd ? "font.family.brand.".concat(fontFamilyToAdd) : '';
155
152
  var fontWeightReplacementToken = shouldAddFontWeight ? findFontWeightTokenForValue(fontWeightValue) : undefined;
156
- var fontWeightReplacement = fontWeightReplacementToken && getTokenProperty('fontWeight', fontWeightReplacementToken.tokenName, shouldAddFallback ? fontWeightValue : undefined);
153
+ var fontWeightReplacement = fontWeightReplacementToken && getTokenProperty('fontWeight', fontWeightReplacementToken.tokenName);
157
154
  var fontFamilyReplacement = fontFamilyToAdd && (fontFamilyToAdd === 'original' ? convertPropertyNodeToStringableNode(
158
155
  // This will always exist if fontFamilyToAdd === 'original', TS can't figure that out.
159
- fontFamilyNode) : getTokenProperty('fontFamily', fontFamilyTokenName, shouldAddFallback ? findFontFamilyValueForToken(fontFamilyTokenName) : undefined));
156
+ fontFamilyNode) : getTokenProperty('fontFamily', fontFamilyTokenName));
160
157
  var fontStyleReplacement = fontStyleToAdd && getLiteralProperty('fontStyle', fontStyleToAdd);
161
158
  var fixerRefs = {
162
159
  matchingToken: matchingToken,
163
160
  nodesToReplace: nodesToReplace,
164
161
  tokensImportNode: tokensImportNode,
165
- themeImportNode: themeImportNode,
166
- shouldAddFallback: shouldAddFallback,
167
- shouldAddFallbackImport: shouldAddFallbackImport,
168
162
  fontWeightReplacement: fontWeightReplacement,
169
163
  fontFamilyReplacement: fontFamilyReplacement,
170
164
  fontStyleReplacement: fontStyleReplacement
@@ -226,40 +220,12 @@ export var StyleObject = {
226
220
  success: false
227
221
  };
228
222
  }
229
- var shouldAddFallback = Boolean(config.shouldEnforceFallbacks);
230
- // This exists purely because we're not inlining the fallback values
231
- // and instead referencing a `fontFallback` object that exists in @atlaskit/theme/typography.
232
- // This is a temporary measure until fallbacks are no longer required
233
- var shouldAddFallbackImport = shouldAddFallback && 'full';
234
- var themeImportDeclaration = Root.findImportsByModule(getSourceCode(context).ast.body, '@atlaskit/theme/typography');
235
- if (themeImportDeclaration.length && shouldAddFallback) {
236
- // Import exists, check if specifier exists
237
- shouldAddFallbackImport = 'specifier';
238
- var fallbackImport = themeImportDeclaration[0].specifiers.find(function (specifier) {
239
- // @atlaskit/theme/typography has no default export so we can safely narrow this type
240
- if (!isNodeOfType(specifier, 'ImportSpecifier')) {
241
- return false;
242
- }
243
- if ('name' in specifier.imported && specifier.imported.name === 'fontFallback') {
244
- return true;
245
- }
246
- return false;
247
- });
248
-
249
- // Exact import already exists, no need to add
250
- if (fallbackImport) {
251
- shouldAddFallbackImport = false;
252
- }
253
- }
254
223
  return {
255
224
  success: true,
256
225
  refs: {
257
226
  fontSizeNode: fontSizeNode,
258
227
  fontSizeRaw: fontSizeRaw,
259
- tokensImportNode: tokensImportDeclaration[0],
260
- themeImportNode: themeImportDeclaration[0],
261
- shouldAddFallback: shouldAddFallback,
262
- shouldAddFallbackImport: shouldAddFallbackImport
228
+ tokensImportNode: tokensImportDeclaration[0]
263
229
  }
264
230
  };
265
231
  },
@@ -268,25 +234,15 @@ export var StyleObject = {
268
234
  var matchingToken = refs.matchingToken,
269
235
  nodesToReplace = refs.nodesToReplace,
270
236
  tokensImportNode = refs.tokensImportNode,
271
- themeImportNode = refs.themeImportNode,
272
- shouldAddFallback = refs.shouldAddFallback,
273
- shouldAddFallbackImport = refs.shouldAddFallbackImport,
274
237
  fontWeightReplacement = refs.fontWeightReplacement,
275
238
  fontFamilyReplacement = refs.fontFamilyReplacement,
276
239
  fontStyleReplacement = refs.fontStyleReplacement;
277
240
  var fontSizeNode = nodesToReplace[0];
278
241
  var root = getSourceCode(context).ast.body;
279
- var fallbackImport;
280
- if (shouldAddFallbackImport === 'full') {
281
- fallbackImport = insertFallbackImportFull(root, fixer);
282
- } else if (shouldAddFallbackImport === 'specifier') {
283
- fallbackImport = insertFallbackImportSpecifier(fixer, themeImportNode);
284
- }
285
- var fallbackName = (matchingToken.tokenName === 'font.body' ? 'font.body.medium' : matchingToken.tokenName).replace('font', 'fontFallback');
286
- return (!tokensImportNode ? [insertTokensImport(root, fixer)] : []).concat(fallbackImport ? [fallbackImport] : [], nodesToReplace.map(function (node, index) {
242
+ return (!tokensImportNode ? [insertTokensImport(root, fixer)] : []).concat(nodesToReplace.map(function (node, index) {
287
243
  // Replace first node with token, delete remaining nodes. Guaranteed to be fontSize
288
244
  if (index === 0) {
289
- return fixer.replaceText(node, "".concat(getTokenProperty('font', matchingToken.tokenName, shouldAddFallback ? fallbackName : undefined, true)));
245
+ return fixer.replaceText(node, "".concat(getTokenProperty('font', matchingToken.tokenName, undefined, true)));
290
246
  }
291
247
 
292
248
  // We don't replace fontWeight/fontFamily/fontStyle here in case it occurs before the font property.
@@ -1,7 +1,7 @@
1
1
  import { callExpression, identifier, isNodeOfType, literal, memberExpression, property } from 'eslint-codemod-utils';
2
2
  import { typographyPalette } from '@atlaskit/tokens/palettes-raw';
3
3
  import { typography as typographyTokens } from '@atlaskit/tokens/tokens-raw';
4
- import { Import, Root } from '../../ast-nodes';
4
+ import { Root } from '../../ast-nodes';
5
5
  export var typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
6
6
  export var isTypographyProperty = function isTypographyProperty(propertyName) {
7
7
  return typographyProperties.includes(propertyName);
@@ -108,16 +108,6 @@ export var fontWeightMap = {
108
108
  bold: '700'
109
109
  };
110
110
  export var defaultFontWeight = fontWeightMap.regular;
111
- export var fontFamilyTokens = typographyTokens.filter(function (token) {
112
- return token.attributes.group === 'fontFamily';
113
- });
114
- export function findFontFamilyValueForToken(tokenName) {
115
- var _fontFamilyTokens$fin;
116
- // Note this will only ever be undefined if the tokens get renamed, and should never happen.
117
- return ((_fontFamilyTokens$fin = fontFamilyTokens.find(function (token) {
118
- return token.cleanName === tokenName;
119
- })) === null || _fontFamilyTokens$fin === void 0 ? void 0 : _fontFamilyTokens$fin.value) || '';
120
- }
121
111
  export function findFontFamilyTokenForValue(value) {
122
112
  if (/charlie[\s-]?display/i.test(value)) {
123
113
  return 'font.family.brand.heading';
@@ -189,13 +179,4 @@ export function insertTokensImport(root, fixer) {
189
179
  module: '@atlaskit/tokens',
190
180
  specifiers: ['token']
191
181
  }, fixer);
192
- }
193
- export function insertFallbackImportFull(root, fixer) {
194
- return Root.insertImport(root, {
195
- module: '@atlaskit/theme/typography',
196
- specifiers: ['fontFallback']
197
- }, fixer);
198
- }
199
- export function insertFallbackImportSpecifier(fixer, themeImportNode) {
200
- return Import.insertNamedSpecifiers(themeImportNode, ['fontFallback'], fixer);
201
182
  }
@@ -2,7 +2,6 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
2
2
  type Pattern = 'style-object' | 'font-weight' | 'font-family' | 'untokenized-properties' | 'banned-properties' | 'restricted-capitalisation';
3
3
  export type RuleConfig = {
4
4
  failSilently: boolean;
5
- shouldEnforceFallbacks: boolean;
6
5
  enableUnsafeAutofix: boolean;
7
6
  patterns: Pattern[];
8
7
  };
@@ -10,9 +10,6 @@ interface Refs {
10
10
  fontSizeNode: Property;
11
11
  fontSizeRaw: string | number;
12
12
  tokensImportNode: ImportDeclaration | undefined;
13
- themeImportNode: ImportDeclaration | undefined;
14
- shouldAddFallback: boolean;
15
- shouldAddFallbackImport: 'full' | 'specifier' | false;
16
13
  }
17
14
  type Check = {
18
15
  success: boolean;
@@ -22,9 +19,6 @@ interface FixerRefs {
22
19
  matchingToken: TokenValueMap;
23
20
  nodesToReplace: Property[];
24
21
  tokensImportNode: ImportDeclaration | undefined;
25
- themeImportNode: ImportDeclaration | undefined;
26
- shouldAddFallback: boolean;
27
- shouldAddFallbackImport: Refs['shouldAddFallbackImport'];
28
22
  fontWeightReplacement: StringableASTNode<Property> | undefined;
29
23
  fontFamilyReplacement: StringableASTNode<Property> | undefined;
30
24
  fontStyleReplacement: StringableASTNode<Property> | undefined;
@@ -1,6 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { type CallExpression, type Directive, type EslintNode, type ImportDeclaration, type ModuleDeclaration, type Property, type Statement, type StringableASTNode } from 'eslint-codemod-utils';
3
- import { typography as typographyTokens } from '@atlaskit/tokens/tokens-raw';
2
+ import { type CallExpression, type Directive, type EslintNode, type ModuleDeclaration, type Property, type Statement, type StringableASTNode } from 'eslint-codemod-utils';
4
3
  export declare const typographyProperties: string[];
5
4
  export declare const isTypographyProperty: (propertyName: string) => boolean;
6
5
  export declare const isFontSize: (node: EslintNode) => node is CallExpression;
@@ -64,8 +63,6 @@ export type FontWeightMap = {
64
63
  bold: string;
65
64
  };
66
65
  export declare const defaultFontWeight: string;
67
- export declare const fontFamilyTokens: typeof typographyTokens;
68
- export declare function findFontFamilyValueForToken(tokenName: string): string;
69
66
  export declare function findFontFamilyTokenForValue(value: string): 'font.family.brand.heading' | 'font.family.brand.body' | 'font.family.body' | 'font.family.code' | undefined;
70
67
  export declare function notUndefined<V>(value: V | undefined): value is V;
71
68
  export declare function isValidPropertyNode(node: Property): boolean;
@@ -73,5 +70,3 @@ export declare function getTokenProperty(propertyName: string, tokenName: string
73
70
  export declare function getLiteralProperty(propertyName: string, propertyValue: string): StringableASTNode<Property>;
74
71
  export declare function convertPropertyNodeToStringableNode(node: Property): StringableASTNode<Property>;
75
72
  export declare function insertTokensImport(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
76
- export declare function insertFallbackImportFull(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
77
- export declare function insertFallbackImportSpecifier(fixer: Rule.RuleFixer, themeImportNode: ImportDeclaration): Rule.Fix | undefined;
@@ -2,7 +2,6 @@ import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
2
2
  type Pattern = 'style-object' | 'font-weight' | 'font-family' | 'untokenized-properties' | 'banned-properties' | 'restricted-capitalisation';
3
3
  export type RuleConfig = {
4
4
  failSilently: boolean;
5
- shouldEnforceFallbacks: boolean;
6
5
  enableUnsafeAutofix: boolean;
7
6
  patterns: Pattern[];
8
7
  };
@@ -10,9 +10,6 @@ interface Refs {
10
10
  fontSizeNode: Property;
11
11
  fontSizeRaw: string | number;
12
12
  tokensImportNode: ImportDeclaration | undefined;
13
- themeImportNode: ImportDeclaration | undefined;
14
- shouldAddFallback: boolean;
15
- shouldAddFallbackImport: 'full' | 'specifier' | false;
16
13
  }
17
14
  type Check = {
18
15
  success: boolean;
@@ -22,9 +19,6 @@ interface FixerRefs {
22
19
  matchingToken: TokenValueMap;
23
20
  nodesToReplace: Property[];
24
21
  tokensImportNode: ImportDeclaration | undefined;
25
- themeImportNode: ImportDeclaration | undefined;
26
- shouldAddFallback: boolean;
27
- shouldAddFallbackImport: Refs['shouldAddFallbackImport'];
28
22
  fontWeightReplacement: StringableASTNode<Property> | undefined;
29
23
  fontFamilyReplacement: StringableASTNode<Property> | undefined;
30
24
  fontStyleReplacement: StringableASTNode<Property> | undefined;
@@ -1,6 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { type CallExpression, type Directive, type EslintNode, type ImportDeclaration, type ModuleDeclaration, type Property, type Statement, type StringableASTNode } from 'eslint-codemod-utils';
3
- import { typography as typographyTokens } from '@atlaskit/tokens/tokens-raw';
2
+ import { type CallExpression, type Directive, type EslintNode, type ModuleDeclaration, type Property, type Statement, type StringableASTNode } from 'eslint-codemod-utils';
4
3
  export declare const typographyProperties: string[];
5
4
  export declare const isTypographyProperty: (propertyName: string) => boolean;
6
5
  export declare const isFontSize: (node: EslintNode) => node is CallExpression;
@@ -64,8 +63,6 @@ export type FontWeightMap = {
64
63
  bold: string;
65
64
  };
66
65
  export declare const defaultFontWeight: string;
67
- export declare const fontFamilyTokens: typeof typographyTokens;
68
- export declare function findFontFamilyValueForToken(tokenName: string): string;
69
66
  export declare function findFontFamilyTokenForValue(value: string): 'font.family.brand.heading' | 'font.family.brand.body' | 'font.family.body' | 'font.family.code' | undefined;
70
67
  export declare function notUndefined<V>(value: V | undefined): value is V;
71
68
  export declare function isValidPropertyNode(node: Property): boolean;
@@ -73,5 +70,3 @@ export declare function getTokenProperty(propertyName: string, tokenName: string
73
70
  export declare function getLiteralProperty(propertyName: string, propertyValue: string): StringableASTNode<Property>;
74
71
  export declare function convertPropertyNodeToStringableNode(node: Property): StringableASTNode<Property>;
75
72
  export declare function insertTokensImport(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
76
- export declare function insertFallbackImportFull(root: (Directive | Statement | ModuleDeclaration)[], fixer: Rule.RuleFixer): Rule.Fix;
77
- export declare function insertFallbackImportSpecifier(fixer: Rule.RuleFixer, themeImportNode: ImportDeclaration): Rule.Fix | undefined;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "13.43.1",
4
+ "version": "13.44.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -39,8 +39,8 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@atlaskit/eslint-utils": "^2.0.0",
42
- "@atlaskit/icon": "^33.1.0",
43
- "@atlaskit/icon-lab": "^6.2.0",
42
+ "@atlaskit/icon": "^34.0.0",
43
+ "@atlaskit/icon-lab": "^6.4.0",
44
44
  "@atlaskit/tokens": "^11.4.0",
45
45
  "@babel/runtime": "^7.0.0",
46
46
  "@typescript-eslint/utils": "^7.1.0",
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@af/formatting": "workspace:^",
58
58
  "@atlaskit/ds-lib": "^6.0.0",
59
- "@atlaskit/theme": "^22.0.0",
59
+ "@atlaskit/theme": "^23.0.0",
60
60
  "@atlassian/codegen": "^0.1.0",
61
61
  "@atlassian/eslint-utils": "^0.5.0",
62
62
  "@atlassian/ts-loader": "^0.1.0",