@atlaskit/eslint-plugin-design-system 8.33.0 → 8.34.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.
Files changed (79) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -0
  3. package/constellation/ensure-design-token-usage/usage.mdx +2 -2
  4. package/constellation/index/usage.mdx +1 -0
  5. package/constellation/use-tokens-typography/usage.mdx +42 -0
  6. package/dist/cjs/ast-nodes/index.js +7 -0
  7. package/dist/cjs/ast-nodes/object-entry.js +27 -0
  8. package/dist/cjs/ast-nodes/object.js +1 -1
  9. package/dist/cjs/presets/all.codegen.js +2 -1
  10. package/dist/cjs/rules/ensure-design-token-usage/index.js +5 -4
  11. package/dist/cjs/rules/ensure-design-token-usage/rule-meta.js +1 -1
  12. package/dist/cjs/rules/ensure-design-token-usage/spacing.js +5 -1
  13. package/dist/cjs/rules/ensure-design-token-usage/utils.js +52 -42
  14. package/dist/cjs/rules/index.codegen.js +3 -1
  15. package/dist/cjs/rules/use-tokens-typography/config/index.js +26 -0
  16. package/dist/cjs/rules/use-tokens-typography/error-boundary.js +24 -0
  17. package/dist/cjs/rules/use-tokens-typography/index.js +44 -0
  18. package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +212 -0
  19. package/dist/cjs/rules/use-tokens-typography/utils.js +146 -0
  20. package/dist/es2019/ast-nodes/index.js +1 -0
  21. package/dist/es2019/ast-nodes/object-entry.js +22 -0
  22. package/dist/es2019/ast-nodes/object.js +1 -1
  23. package/dist/es2019/presets/all.codegen.js +2 -1
  24. package/dist/es2019/rules/ensure-design-token-usage/index.js +6 -5
  25. package/dist/es2019/rules/ensure-design-token-usage/rule-meta.js +1 -1
  26. package/dist/es2019/rules/ensure-design-token-usage/spacing.js +5 -1
  27. package/dist/es2019/rules/ensure-design-token-usage/utils.js +42 -38
  28. package/dist/es2019/rules/index.codegen.js +3 -1
  29. package/dist/es2019/rules/use-tokens-typography/config/index.js +20 -0
  30. package/dist/es2019/rules/use-tokens-typography/error-boundary.js +19 -0
  31. package/dist/es2019/rules/use-tokens-typography/index.js +36 -0
  32. package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +209 -0
  33. package/dist/es2019/rules/use-tokens-typography/utils.js +99 -0
  34. package/dist/esm/ast-nodes/index.js +1 -0
  35. package/dist/esm/ast-nodes/object-entry.js +22 -0
  36. package/dist/esm/ast-nodes/object.js +1 -1
  37. package/dist/esm/presets/all.codegen.js +2 -1
  38. package/dist/esm/rules/ensure-design-token-usage/index.js +6 -5
  39. package/dist/esm/rules/ensure-design-token-usage/rule-meta.js +1 -1
  40. package/dist/esm/rules/ensure-design-token-usage/spacing.js +5 -1
  41. package/dist/esm/rules/ensure-design-token-usage/utils.js +46 -38
  42. package/dist/esm/rules/index.codegen.js +3 -1
  43. package/dist/esm/rules/use-tokens-typography/config/index.js +20 -0
  44. package/dist/esm/rules/use-tokens-typography/error-boundary.js +18 -0
  45. package/dist/esm/rules/use-tokens-typography/index.js +38 -0
  46. package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +206 -0
  47. package/dist/esm/rules/use-tokens-typography/utils.js +129 -0
  48. package/dist/types/ast-nodes/index.d.ts +1 -0
  49. package/dist/types/ast-nodes/object-entry.d.ts +6 -0
  50. package/dist/types/ast-nodes/object.d.ts +1 -1
  51. package/dist/types/index.codegen.d.ts +1 -0
  52. package/dist/types/presets/all.codegen.d.ts +2 -1
  53. package/dist/types/rules/ensure-design-token-usage/types.d.ts +1 -1
  54. package/dist/types/rules/ensure-design-token-usage/utils.d.ts +22 -22
  55. package/dist/types/rules/index.codegen.d.ts +1 -0
  56. package/dist/types/rules/use-tokens-typography/config/index.d.ts +6 -0
  57. package/dist/types/rules/use-tokens-typography/error-boundary.d.ts +11 -0
  58. package/dist/types/rules/use-tokens-typography/index.d.ts +3 -0
  59. package/dist/types/rules/use-tokens-typography/transformers/style-object.d.ts +31 -0
  60. package/dist/types/rules/use-tokens-typography/utils.d.ts +161 -0
  61. package/dist/types-ts4.5/ast-nodes/index.d.ts +1 -0
  62. package/dist/types-ts4.5/ast-nodes/object-entry.d.ts +6 -0
  63. package/dist/types-ts4.5/ast-nodes/object.d.ts +1 -1
  64. package/dist/types-ts4.5/index.codegen.d.ts +1 -0
  65. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  66. package/dist/types-ts4.5/rules/ensure-design-token-usage/types.d.ts +1 -1
  67. package/dist/types-ts4.5/rules/ensure-design-token-usage/utils.d.ts +22 -22
  68. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  69. package/dist/types-ts4.5/rules/use-tokens-typography/config/index.d.ts +6 -0
  70. package/dist/types-ts4.5/rules/use-tokens-typography/error-boundary.d.ts +11 -0
  71. package/dist/types-ts4.5/rules/use-tokens-typography/index.d.ts +3 -0
  72. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/style-object.d.ts +31 -0
  73. package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +161 -0
  74. package/package.json +1 -1
  75. package/dist/cjs/rules/ensure-design-token-usage/typography.js +0 -39
  76. package/dist/es2019/rules/ensure-design-token-usage/typography.js +0 -19
  77. package/dist/esm/rules/ensure-design-token-usage/typography.js +0 -33
  78. package/dist/types/rules/ensure-design-token-usage/typography.d.ts +0 -9
  79. package/dist/types-ts4.5/rules/ensure-design-token-usage/typography.d.ts +0 -9
@@ -0,0 +1,129 @@
1
+ import { callExpression, identifier, isNodeOfType, literal, property } from 'eslint-codemod-utils';
2
+ import { typographyPalette } from '@atlaskit/tokens/palettes-raw';
3
+ import { typographyAdg3 as typographyTokens } from '@atlaskit/tokens/tokens-raw';
4
+ export var typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
5
+ export var isTypographyProperty = function isTypographyProperty(propertyName) {
6
+ return typographyProperties.includes(propertyName);
7
+ };
8
+ export var isFontSize = function isFontSize(node) {
9
+ return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'fontSize' || node.callee.name === 'getFontSize');
10
+ };
11
+ export var isFontSizeSmall = function isFontSizeSmall(node) {
12
+ return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && node.callee.name === 'fontSizeSmall';
13
+ };
14
+ export var isFontFamily = function isFontFamily(node) {
15
+ return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'fontFamily' || node.callee.name === 'getFontFamily');
16
+ };
17
+ export var isCodeFontFamily = function isCodeFontFamily(node) {
18
+ return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'codeFontFamily' || node.callee.name === 'getCodeFontFamily');
19
+ };
20
+ export var typographyValueToToken = typographyTokens
21
+ // we're filtering here to remove the `font` tokens.
22
+ .filter(function (t) {
23
+ return t.attributes.group === 'typography';
24
+ }).filter(function (t) {
25
+ return t.cleanName.includes('font.heading') || t.cleanName.includes('font.body');
26
+ }).map(function (currentToken) {
27
+ var _typographyPalette$fi, _typographyPalette$fi2, _typographyPalette$fi3;
28
+ var individualValues = {
29
+ fontSize: (_typographyPalette$fi = typographyPalette.find(function (baseToken) {
30
+ return baseToken.path.slice(-1)[0] ===
31
+ // @ts-expect-error token.original.value can be a string, due to the typographyTokens export including deprecated tokens
32
+ currentToken.original.value.fontSize;
33
+ })) === null || _typographyPalette$fi === void 0 ? void 0 : _typographyPalette$fi.value,
34
+ fontWeight: (_typographyPalette$fi2 = typographyPalette.find(function (baseToken) {
35
+ return baseToken.path.slice(-1)[0] ===
36
+ // @ts-expect-error token.original.value can be a string, due to the typographyTokens export including deprecated tokens
37
+ currentToken.original.value.fontWeight;
38
+ })) === null || _typographyPalette$fi2 === void 0 ? void 0 : _typographyPalette$fi2.value,
39
+ lineHeight: (_typographyPalette$fi3 = typographyPalette.find(function (baseToken) {
40
+ return baseToken.path.slice(-1)[0] ===
41
+ // @ts-expect-error token.original.value can be a string, due to the typographyTokens export including deprecated tokens
42
+ currentToken.original.value.lineHeight;
43
+ })) === null || _typographyPalette$fi3 === void 0 ? void 0 : _typographyPalette$fi3.value
44
+ };
45
+ return {
46
+ tokenName: currentToken.cleanName,
47
+ tokenValue: currentToken.value,
48
+ values: individualValues
49
+ };
50
+ });
51
+ export function findTypographyTokenForValues(fontSize, lineHeight) {
52
+ var matchingTokens = typographyValueToToken.filter(function (token) {
53
+ return token.values.fontSize === fontSize;
54
+ })
55
+ // If lineHeight == 1, we don't match to a token
56
+ .filter(function () {
57
+ return lineHeight === '1' ? false : true;
58
+ });
59
+ return matchingTokens;
60
+ }
61
+ export var fontWeightTokens = typographyTokens.filter(function (token) {
62
+ return token.attributes.group === 'fontWeight';
63
+ }).map(function (token) {
64
+ return {
65
+ tokenName: token.cleanName,
66
+ tokenValue: token.value,
67
+ values: {}
68
+ };
69
+ });
70
+ export function findFontWeightTokenForValue(fontWeight) {
71
+ return fontWeightTokens.find(function (token) {
72
+ return token.tokenValue === fontWeight;
73
+ });
74
+ }
75
+ export var fontWeightMap = {
76
+ regular: '400',
77
+ medium: '500',
78
+ semibold: '600',
79
+ bold: '700'
80
+ };
81
+ export var defaultFontWeight = fontWeightMap.regular;
82
+ export var fontFamilyTokens = typographyTokens.filter(function (token) {
83
+ return token.attributes.group === 'fontFamily';
84
+ });
85
+ export function findFontFamilyValueForToken(tokenName) {
86
+ var _fontFamilyTokens$fin;
87
+ // Note this will only ever be undefined if the tokens get renamed, and should never happen.
88
+ return ((_fontFamilyTokens$fin = fontFamilyTokens.find(function (token) {
89
+ return token.cleanName === tokenName;
90
+ })) === null || _fontFamilyTokens$fin === void 0 ? void 0 : _fontFamilyTokens$fin.value) || '';
91
+ }
92
+ export function notUndefined(value) {
93
+ return value !== undefined;
94
+ }
95
+ export function isValidPropertyNode(node) {
96
+ if (!isNodeOfType(node.key, 'Identifier') && !isNodeOfType(node.key, 'Literal')) {
97
+ return false;
98
+ }
99
+ return true;
100
+ }
101
+ function getTokenNode(tokenName, tokenValue) {
102
+ return callExpression({
103
+ callee: identifier({
104
+ name: 'token'
105
+ }),
106
+ arguments: [literal({
107
+ value: "'".concat(tokenName, "'")
108
+ }), literal(tokenValue)],
109
+ optional: false
110
+ });
111
+ }
112
+ export function getTokenProperty(propertyName, tokenName, tokenFallback) {
113
+ return property({
114
+ key: identifier(propertyName),
115
+ value: getTokenNode(tokenName, tokenFallback)
116
+ });
117
+ }
118
+ export function getLiteralProperty(propertyName, propertyValue) {
119
+ return property({
120
+ key: identifier(propertyName),
121
+ value: literal(propertyValue)
122
+ });
123
+ }
124
+ export function convertPropertyNodeToStringableNode(node) {
125
+ return property({
126
+ key: node.key,
127
+ value: node.value
128
+ });
129
+ }
@@ -3,4 +3,5 @@ export { Import } from './import';
3
3
  export { JSXAttribute } from './jsx-attribute';
4
4
  export { JSXElement } from './jsx-element';
5
5
  export { Object } from './object';
6
+ export { ObjectEntry } from './object-entry';
6
7
  export { Root } from './root';
@@ -0,0 +1,6 @@
1
+ import type { Rule } from 'eslint';
2
+ import type { Property, SpreadElement } from 'eslint-codemod-utils';
3
+ declare const ObjectEntry: {
4
+ deleteEntry(node: Property | SpreadElement, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix;
5
+ };
6
+ export { ObjectEntry };
@@ -14,7 +14,7 @@ declare const ASTObjectExpression: {
14
14
  */
15
15
  isFlat(node: ObjectExpression): boolean;
16
16
  /**
17
- * Returns a key-value pair like: `padding: '8px'` from: `{ padding: '8px' }`.
17
+ * Returns the first Property node from an Object that matches the provided name.
18
18
  */
19
19
  getEntryByPropertyName(node: ObjectExpression, name: string): Property | undefined;
20
20
  deleteEntry(node: ObjectExpression, name: string, fixer: Rule.RuleFixer): Rule.Fix[];
@@ -32,6 +32,7 @@ export declare const configs: {
32
32
  '@atlaskit/design-system/use-href-in-link-item': string;
33
33
  '@atlaskit/design-system/use-primitives': string;
34
34
  '@atlaskit/design-system/use-primitives-text': string;
35
+ '@atlaskit/design-system/use-tokens-typography': string;
35
36
  '@atlaskit/design-system/use-visually-hidden': string;
36
37
  };
37
38
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::bcb633b9d5c2def00d43b11139433c5c>>
3
+ * @codegen <<SignedSource::d90c2cf5e100daf98915f9467f2e5663>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -35,6 +35,7 @@ declare const _default: {
35
35
  '@atlaskit/design-system/use-href-in-link-item': string;
36
36
  '@atlaskit/design-system/use-primitives': string;
37
37
  '@atlaskit/design-system/use-primitives-text': string;
38
+ '@atlaskit/design-system/use-tokens-typography': string;
38
39
  '@atlaskit/design-system/use-visually-hidden': string;
39
40
  };
40
41
  };
@@ -1,4 +1,4 @@
1
- export type Domains = ('color' | 'spacing' | 'typography' | 'shape')[];
1
+ export type Domains = ('color' | 'spacing' | 'shape')[];
2
2
  export type RuleConfig = {
3
3
  domains: Domains;
4
4
  applyImport?: boolean;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { EslintNode, ObjectExpression, TaggedTemplateExpression } from 'eslint-codemod-utils';
2
+ import { EslintNode, ObjectExpression, Property, SpreadElement, TaggedTemplateExpression } from 'eslint-codemod-utils';
3
3
  import { Domains } from './types';
4
4
  export type ProcessedCSSLines = [string, string][];
5
5
  export declare function insertTokensImport(fixer: Rule.RuleFixer): Rule.Fix;
@@ -16,8 +16,8 @@ export declare const isSpacingProperty: (propertyName: string) => boolean;
16
16
  * For input `-${gridSize / 2}px ${token(...)} 18px -> [`-${gridSize / 2}px`, `${token(...)}`, `18px`]
17
17
  */
18
18
  export declare const splitShorthandValues: (str: string) => string[];
19
- export declare const getValueFromShorthand: (str: unknown) => any[];
20
- export declare const getValue: (node: EslintNode, context: Rule.RuleContext) => string | number | any[] | null | undefined;
19
+ export declare const getValueFromShorthand: (str: unknown) => (string | number)[];
20
+ export declare const getValue: (node: EslintNode, context: Rule.RuleContext) => string | number | (string | number)[] | null | undefined;
21
21
  export declare const getRawExpression: (node: EslintNode, context: Rule.RuleContext) => string | null;
22
22
  /**
23
23
  * @example
@@ -43,34 +43,33 @@ export declare const isAuto: (value: string | number | boolean | RegExp | null |
43
43
  export declare const convertHyphenatedNameToCamelCase: (prop: string) => string;
44
44
  /**
45
45
  * @param node
46
- * @returns The furthest parent node that is on the same line as the input node
46
+ * @returns The furthest parent node that is on the same line as the input node.
47
47
  */
48
48
  export declare const findParentNodeForLine: (node: Rule.Node) => Rule.Node;
49
49
  /**
50
- * Returns an array of domains that are relevant to the provided property based on the rule options
50
+ * Returns an array of domains that are relevant to the provided property based on the rule options.
51
51
  * @param propertyName camelCase CSS property
52
- * @param targetOptions Array containing the types of properties that should be included in the rule
52
+ * @param targetOptions Array containing the types of properties that should be included in the rule.
53
53
  * @example
54
54
  * ```
55
55
  * propertyName: padding, targetOptions: ['spacing'] -> returns ['spacing']
56
- * propertyName: fontWeight, targetOptions: ['spacing', 'typography'] -> returns ['typography']
57
- * propertyName: backgroundColor, targetOptions: ['spacing', 'typography'] -> returns []
56
+ * propertyName: backgroundColor, targetOptions: ['spacing'] -> returns []
58
57
  * propertyName: backgroundColor, targetOptions: ['color', 'spacing'] -> returns ['color']
59
58
  * ```
60
59
  */
61
60
  export declare function getDomainsForProperty(propertyName: string, targetOptions: Domains): Domains;
62
61
  /**
63
62
  * Function that removes JS comments from a string of code,
64
- * sometimes makers will have single or multiline comments in their tagged template literals styles, this can mess with our parsing logic
63
+ * sometimes makers will have single or multiline comments in their tagged template literals styles, this can mess with our parsing logic.
65
64
  */
66
65
  export declare function cleanComments(str: string): string;
67
66
  /**
68
67
  * Returns an array of tuples representing a processed css within `TaggedTemplateExpression` node.
69
- * each element of the array is a tuple `[string, string]`,
68
+ * Each element of the array is a tuple `[string, string]`,
70
69
  * where the first element is the processed css line with computed values
71
- * and the second element of the tuple is the original css line from source
72
- * @param node TaggedTemplateExpression node
73
- * @param context Rule.RuleContext
70
+ * and the second element of the tuple is the original css line from source.
71
+ * @param node TaggedTemplateExpression node.
72
+ * @param context Rule.RuleContext.
74
73
  * @example
75
74
  * ```
76
75
  * `[['padding: 8', 'padding: ${gridSize()}'], ['margin: 6', 'margin: 6px' ]]`
@@ -91,13 +90,13 @@ export declare function getTokenNodeForValue(propertyName: string, value: string
91
90
  export declare function getFontSizeValueInScope(cssProperties: ProcessedCSSLines): number | undefined;
92
91
  /**
93
92
  * Attempts to remove all non-essential words & characters from a style block.
94
- * Including selectors and queries
93
+ * Including selectors and queries.
95
94
  * @param styleString string of css properties
96
95
  */
97
96
  export declare function splitCssProperties(styleString: string): string[];
98
97
  /**
99
- * returns whether the current string is a token value
100
- * @param originalVaue string representing a css property value e.g 1em, 12px
98
+ * Returns whether the current string is a token value.
99
+ * @param originalVaue string representing a css property value e.g 1em, 12px.
101
100
  */
102
101
  export declare function isTokenValueString(originalValue: string): boolean;
103
102
  export declare function includesTokenString(originalValue: string): boolean;
@@ -106,17 +105,18 @@ export declare function includesTokenString(originalValue: string): boolean;
106
105
  *
107
106
  * -> for pixels this '8px'
108
107
  * -> for weights '400'
109
- * -> for family 'Arial'
108
+ * -> for family 'Arial'.
110
109
  *
111
110
  * @internal
112
111
  */
113
- export declare function normaliseValue(propertyName: string, value: string): string;
112
+ export declare function normaliseValue(propertyName: string, value: string | number): string;
114
113
  export declare function findTokenNameByPropertyValue(propertyName: string, value: string): string | undefined;
115
114
  /**
116
115
  * Returns a stringifiable node with the token expression corresponding to its matching token.
117
- * if no token found for the pair the function returns undefined
118
- * @param propertyName string camelCased css property
119
- * @param value the computed value e.g '8px' -> '8'
116
+ * If no token found for the pair the function returns undefined.
117
+ * @param propertyName string camelCased css property.
118
+ * @param value The computed value e.g '8px' -> '8'.
120
119
  */
121
120
  export declare function getTokenReplacement(propertyName: string, value: string): import("eslint-codemod-utils").StringableASTNode<import("estree").SimpleCallExpression> | undefined;
122
- export declare function getFontSizeFromNode(parentNode: ObjectExpression & Rule.NodeParentExtension, context: Rule.RuleContext): any;
121
+ export declare function getPropertyNodeFromParent(property: string, parentNode: ObjectExpression & Rule.NodeParentExtension): Property | SpreadElement | undefined;
122
+ export declare function getValueForPropertyNode(propertyNode: Property | SpreadElement, context: Rule.RuleContext): string | number | null | undefined;
@@ -32,6 +32,7 @@ declare const _default: {
32
32
  'use-href-in-link-item': import("eslint").Rule.RuleModule;
33
33
  'use-primitives': import("eslint").Rule.RuleModule;
34
34
  'use-primitives-text': import("eslint").Rule.RuleModule;
35
+ 'use-tokens-typography': import("eslint").Rule.RuleModule;
35
36
  'use-visually-hidden': import("eslint").Rule.RuleModule;
36
37
  };
37
38
  export default _default;
@@ -0,0 +1,6 @@
1
+ import { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
2
+ export type RuleConfig = {
3
+ failSilently?: boolean;
4
+ };
5
+ export declare const ruleSchema: JSONSchema4;
6
+ export declare const getConfig: (overrides: RuleConfig) => RuleConfig;
@@ -0,0 +1,11 @@
1
+ import { RuleConfig } from './config';
2
+ /**
3
+ * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
4
+ * (and probably the IntelliJ one too), which causes linting to fail in a file.
5
+ *
6
+ * It also breaks CI, which was the reason this error boundary was added. It's a final
7
+ * catch all.
8
+ */
9
+ export declare const errorBoundary: (func: () => void, { config }: {
10
+ config: RuleConfig;
11
+ }) => void;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,31 @@
1
+ import type { Rule } from 'eslint';
2
+ import { ImportDeclaration, ObjectExpression, Property, StringableASTNode } from 'eslint-codemod-utils';
3
+ import { TokenValueMap } from '../utils';
4
+ interface MetaData {
5
+ context: Rule.RuleContext;
6
+ }
7
+ interface Refs {
8
+ fontSizeNode: Property;
9
+ fontSizeRaw: string | number;
10
+ tokensImportNode: ImportDeclaration | undefined;
11
+ }
12
+ type Check = {
13
+ success: boolean;
14
+ refs?: Refs;
15
+ };
16
+ interface FixerRefs {
17
+ matchingToken: TokenValueMap;
18
+ nodesToReplace: Property[];
19
+ tokensImportNode: ImportDeclaration | undefined;
20
+ fontWeightReplacement: StringableASTNode<Property> | undefined;
21
+ fontFamilyReplacement: StringableASTNode<Property> | undefined;
22
+ fontStyleReplacement: StringableASTNode<Property> | undefined;
23
+ }
24
+ export declare const StyleObject: {
25
+ lint(node: Rule.Node, { context }: MetaData): {
26
+ success: boolean;
27
+ } | undefined;
28
+ _check(node: ObjectExpression & Rule.NodeParentExtension, { context }: MetaData): Check;
29
+ _fix(refs: FixerRefs, context: Rule.RuleContext): (fixer: Rule.RuleFixer) => Rule.Fix[];
30
+ };
31
+ export {};
@@ -0,0 +1,161 @@
1
+ import { CallExpression, EslintNode, Property } from 'eslint-codemod-utils';
2
+ export declare const typographyProperties: string[];
3
+ export declare const isTypographyProperty: (propertyName: string) => boolean;
4
+ export declare const isFontSize: (node: EslintNode) => node is CallExpression;
5
+ export declare const isFontSizeSmall: (node: EslintNode) => node is CallExpression;
6
+ export declare const isFontFamily: (node: EslintNode) => node is CallExpression;
7
+ export declare const isCodeFontFamily: (node: EslintNode) => node is CallExpression;
8
+ export type TokenValueMap = {
9
+ tokenName: string;
10
+ tokenValue: string;
11
+ values: {
12
+ fontSize?: string;
13
+ fontWeight?: string;
14
+ lineHeight?: string;
15
+ };
16
+ };
17
+ export declare const typographyValueToToken: TokenValueMap[];
18
+ export declare function findTypographyTokenForValues(fontSize: string, lineHeight?: string): TokenValueMap[];
19
+ export declare const fontWeightTokens: {
20
+ tokenName: string;
21
+ tokenValue: string;
22
+ values: {};
23
+ }[];
24
+ export declare function findFontWeightTokenForValue(fontWeight: string): {
25
+ tokenName: string;
26
+ tokenValue: string;
27
+ values: {};
28
+ } | undefined;
29
+ export declare const fontWeightMap: FontWeightMap;
30
+ export type FontWeightMap = {
31
+ regular: string;
32
+ medium: string;
33
+ semibold: string;
34
+ bold: string;
35
+ };
36
+ export declare const defaultFontWeight: string;
37
+ export declare const fontFamilyTokens: ({
38
+ attributes: {
39
+ group: string;
40
+ state: string;
41
+ introduced: string;
42
+ description: string;
43
+ responsiveSmallerVariant?: undefined;
44
+ deprecated?: undefined;
45
+ };
46
+ value: string;
47
+ filePath: string;
48
+ isSource: boolean;
49
+ original: {
50
+ attributes: {
51
+ group: string;
52
+ state: string;
53
+ introduced: string;
54
+ description: string;
55
+ responsiveSmallerVariant?: undefined;
56
+ deprecated?: undefined;
57
+ };
58
+ value: string;
59
+ };
60
+ name: string;
61
+ path: string[];
62
+ cleanName: string;
63
+ } | {
64
+ attributes: {
65
+ group: string;
66
+ state: string;
67
+ introduced: string;
68
+ description: string;
69
+ responsiveSmallerVariant: string;
70
+ deprecated?: undefined;
71
+ };
72
+ value: string;
73
+ filePath: string;
74
+ isSource: boolean;
75
+ original: {
76
+ attributes: {
77
+ group: string;
78
+ state: string;
79
+ introduced: string;
80
+ description: string;
81
+ responsiveSmallerVariant: string;
82
+ deprecated?: undefined;
83
+ };
84
+ value: {
85
+ fontWeight: string;
86
+ fontSize: string;
87
+ lineHeight: string;
88
+ fontFamily: string;
89
+ fontStyle: string;
90
+ letterSpacing: string;
91
+ };
92
+ };
93
+ name: string;
94
+ path: string[];
95
+ cleanName: string;
96
+ } | {
97
+ attributes: {
98
+ group: string;
99
+ state: string;
100
+ introduced: string;
101
+ description: string;
102
+ responsiveSmallerVariant?: undefined;
103
+ deprecated?: undefined;
104
+ };
105
+ value: string;
106
+ filePath: string;
107
+ isSource: boolean;
108
+ original: {
109
+ attributes: {
110
+ group: string;
111
+ state: string;
112
+ introduced: string;
113
+ description: string;
114
+ responsiveSmallerVariant?: undefined;
115
+ deprecated?: undefined;
116
+ };
117
+ value: {
118
+ fontWeight: string;
119
+ fontSize: string;
120
+ lineHeight: string;
121
+ fontFamily: string;
122
+ fontStyle: string;
123
+ letterSpacing: string;
124
+ };
125
+ };
126
+ name: string;
127
+ path: string[];
128
+ cleanName: string;
129
+ } | {
130
+ attributes: {
131
+ group: string;
132
+ state: string;
133
+ introduced: string;
134
+ description: string;
135
+ deprecated: string;
136
+ responsiveSmallerVariant?: undefined;
137
+ };
138
+ value: string;
139
+ filePath: string;
140
+ isSource: boolean;
141
+ original: {
142
+ attributes: {
143
+ group: string;
144
+ state: string;
145
+ introduced: string;
146
+ description: string;
147
+ deprecated: string;
148
+ responsiveSmallerVariant?: undefined;
149
+ };
150
+ value: string;
151
+ };
152
+ name: string;
153
+ path: string[];
154
+ cleanName: string;
155
+ })[];
156
+ export declare function findFontFamilyValueForToken(tokenName: string): string;
157
+ export declare function notUndefined<V>(value: V | undefined): value is V;
158
+ export declare function isValidPropertyNode(node: Property): boolean;
159
+ export declare function getTokenProperty(propertyName: string, tokenName: string, tokenFallback: string): import("eslint-codemod-utils").StringableASTNode<Property>;
160
+ export declare function getLiteralProperty(propertyName: string, propertyValue: string): import("eslint-codemod-utils").StringableASTNode<Property>;
161
+ export declare function convertPropertyNodeToStringableNode(node: Property): import("eslint-codemod-utils").StringableASTNode<Property>;
@@ -3,4 +3,5 @@ export { Import } from './import';
3
3
  export { JSXAttribute } from './jsx-attribute';
4
4
  export { JSXElement } from './jsx-element';
5
5
  export { Object } from './object';
6
+ export { ObjectEntry } from './object-entry';
6
7
  export { Root } from './root';
@@ -0,0 +1,6 @@
1
+ import type { Rule } from 'eslint';
2
+ import type { Property, SpreadElement } from 'eslint-codemod-utils';
3
+ declare const ObjectEntry: {
4
+ deleteEntry(node: Property | SpreadElement, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix;
5
+ };
6
+ export { ObjectEntry };
@@ -14,7 +14,7 @@ declare const ASTObjectExpression: {
14
14
  */
15
15
  isFlat(node: ObjectExpression): boolean;
16
16
  /**
17
- * Returns a key-value pair like: `padding: '8px'` from: `{ padding: '8px' }`.
17
+ * Returns the first Property node from an Object that matches the provided name.
18
18
  */
19
19
  getEntryByPropertyName(node: ObjectExpression, name: string): Property | undefined;
20
20
  deleteEntry(node: ObjectExpression, name: string, fixer: Rule.RuleFixer): Rule.Fix[];
@@ -32,6 +32,7 @@ export declare const configs: {
32
32
  '@atlaskit/design-system/use-href-in-link-item': string;
33
33
  '@atlaskit/design-system/use-primitives': string;
34
34
  '@atlaskit/design-system/use-primitives-text': string;
35
+ '@atlaskit/design-system/use-tokens-typography': string;
35
36
  '@atlaskit/design-system/use-visually-hidden': string;
36
37
  };
37
38
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::bcb633b9d5c2def00d43b11139433c5c>>
3
+ * @codegen <<SignedSource::d90c2cf5e100daf98915f9467f2e5663>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -35,6 +35,7 @@ declare const _default: {
35
35
  '@atlaskit/design-system/use-href-in-link-item': string;
36
36
  '@atlaskit/design-system/use-primitives': string;
37
37
  '@atlaskit/design-system/use-primitives-text': string;
38
+ '@atlaskit/design-system/use-tokens-typography': string;
38
39
  '@atlaskit/design-system/use-visually-hidden': string;
39
40
  };
40
41
  };
@@ -1,4 +1,4 @@
1
- export type Domains = ('color' | 'spacing' | 'typography' | 'shape')[];
1
+ export type Domains = ('color' | 'spacing' | 'shape')[];
2
2
  export type RuleConfig = {
3
3
  domains: Domains;
4
4
  applyImport?: boolean;