@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
@@ -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 = [
5
5
  string,
@@ -19,8 +19,8 @@ export declare const isSpacingProperty: (propertyName: string) => boolean;
19
19
  * For input `-${gridSize / 2}px ${token(...)} 18px -> [`-${gridSize / 2}px`, `${token(...)}`, `18px`]
20
20
  */
21
21
  export declare const splitShorthandValues: (str: string) => string[];
22
- export declare const getValueFromShorthand: (str: unknown) => any[];
23
- export declare const getValue: (node: EslintNode, context: Rule.RuleContext) => string | number | any[] | null | undefined;
22
+ export declare const getValueFromShorthand: (str: unknown) => (string | number)[];
23
+ export declare const getValue: (node: EslintNode, context: Rule.RuleContext) => string | number | (string | number)[] | null | undefined;
24
24
  export declare const getRawExpression: (node: EslintNode, context: Rule.RuleContext) => string | null;
25
25
  /**
26
26
  * @example
@@ -46,34 +46,33 @@ export declare const isAuto: (value: string | number | boolean | RegExp | null |
46
46
  export declare const convertHyphenatedNameToCamelCase: (prop: string) => string;
47
47
  /**
48
48
  * @param node
49
- * @returns The furthest parent node that is on the same line as the input node
49
+ * @returns The furthest parent node that is on the same line as the input node.
50
50
  */
51
51
  export declare const findParentNodeForLine: (node: Rule.Node) => Rule.Node;
52
52
  /**
53
- * Returns an array of domains that are relevant to the provided property based on the rule options
53
+ * Returns an array of domains that are relevant to the provided property based on the rule options.
54
54
  * @param propertyName camelCase CSS property
55
- * @param targetOptions Array containing the types of properties that should be included in the rule
55
+ * @param targetOptions Array containing the types of properties that should be included in the rule.
56
56
  * @example
57
57
  * ```
58
58
  * propertyName: padding, targetOptions: ['spacing'] -> returns ['spacing']
59
- * propertyName: fontWeight, targetOptions: ['spacing', 'typography'] -> returns ['typography']
60
- * propertyName: backgroundColor, targetOptions: ['spacing', 'typography'] -> returns []
59
+ * propertyName: backgroundColor, targetOptions: ['spacing'] -> returns []
61
60
  * propertyName: backgroundColor, targetOptions: ['color', 'spacing'] -> returns ['color']
62
61
  * ```
63
62
  */
64
63
  export declare function getDomainsForProperty(propertyName: string, targetOptions: Domains): Domains;
65
64
  /**
66
65
  * Function that removes JS comments from a string of code,
67
- * sometimes makers will have single or multiline comments in their tagged template literals styles, this can mess with our parsing logic
66
+ * sometimes makers will have single or multiline comments in their tagged template literals styles, this can mess with our parsing logic.
68
67
  */
69
68
  export declare function cleanComments(str: string): string;
70
69
  /**
71
70
  * Returns an array of tuples representing a processed css within `TaggedTemplateExpression` node.
72
- * each element of the array is a tuple `[string, string]`,
71
+ * Each element of the array is a tuple `[string, string]`,
73
72
  * where the first element is the processed css line with computed values
74
- * and the second element of the tuple is the original css line from source
75
- * @param node TaggedTemplateExpression node
76
- * @param context Rule.RuleContext
73
+ * and the second element of the tuple is the original css line from source.
74
+ * @param node TaggedTemplateExpression node.
75
+ * @param context Rule.RuleContext.
77
76
  * @example
78
77
  * ```
79
78
  * `[['padding: 8', 'padding: ${gridSize()}'], ['margin: 6', 'margin: 6px' ]]`
@@ -94,13 +93,13 @@ export declare function getTokenNodeForValue(propertyName: string, value: string
94
93
  export declare function getFontSizeValueInScope(cssProperties: ProcessedCSSLines): number | undefined;
95
94
  /**
96
95
  * Attempts to remove all non-essential words & characters from a style block.
97
- * Including selectors and queries
96
+ * Including selectors and queries.
98
97
  * @param styleString string of css properties
99
98
  */
100
99
  export declare function splitCssProperties(styleString: string): string[];
101
100
  /**
102
- * returns whether the current string is a token value
103
- * @param originalVaue string representing a css property value e.g 1em, 12px
101
+ * Returns whether the current string is a token value.
102
+ * @param originalVaue string representing a css property value e.g 1em, 12px.
104
103
  */
105
104
  export declare function isTokenValueString(originalValue: string): boolean;
106
105
  export declare function includesTokenString(originalValue: string): boolean;
@@ -109,17 +108,18 @@ export declare function includesTokenString(originalValue: string): boolean;
109
108
  *
110
109
  * -> for pixels this '8px'
111
110
  * -> for weights '400'
112
- * -> for family 'Arial'
111
+ * -> for family 'Arial'.
113
112
  *
114
113
  * @internal
115
114
  */
116
- export declare function normaliseValue(propertyName: string, value: string): string;
115
+ export declare function normaliseValue(propertyName: string, value: string | number): string;
117
116
  export declare function findTokenNameByPropertyValue(propertyName: string, value: string): string | undefined;
118
117
  /**
119
118
  * Returns a stringifiable node with the token expression corresponding to its matching token.
120
- * if no token found for the pair the function returns undefined
121
- * @param propertyName string camelCased css property
122
- * @param value the computed value e.g '8px' -> '8'
119
+ * If no token found for the pair the function returns undefined.
120
+ * @param propertyName string camelCased css property.
121
+ * @param value The computed value e.g '8px' -> '8'.
123
122
  */
124
123
  export declare function getTokenReplacement(propertyName: string, value: string): import("eslint-codemod-utils").StringableASTNode<import("estree").SimpleCallExpression> | undefined;
125
- export declare function getFontSizeFromNode(parentNode: ObjectExpression & Rule.NodeParentExtension, context: Rule.RuleContext): any;
124
+ export declare function getPropertyNodeFromParent(property: string, parentNode: ObjectExpression & Rule.NodeParentExtension): Property | SpreadElement | undefined;
125
+ export declare function getValueForPropertyNode(propertyNode: Property | SpreadElement, context: Rule.RuleContext): string | number | null | undefined;
@@ -36,6 +36,7 @@ declare const _default: {
36
36
  'use-href-in-link-item': import("eslint").Rule.RuleModule;
37
37
  'use-primitives': import("eslint").Rule.RuleModule;
38
38
  'use-primitives-text': import("eslint").Rule.RuleModule;
39
+ 'use-tokens-typography': import("eslint").Rule.RuleModule;
39
40
  'use-visually-hidden': import("eslint").Rule.RuleModule;
40
41
  };
41
42
  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>;
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": "8.33.0",
4
+ "version": "8.34.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"
@@ -1,39 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.typographyValueToToken = exports.isTypographyProperty = exports.isFontSizeSmall = exports.isFontSize = exports.isFontFamily = exports.isCodeFontFamily = void 0;
7
- var _eslintCodemodUtils = require("eslint-codemod-utils");
8
- var _tokensRaw = require("@atlaskit/tokens/tokens-raw");
9
- var typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
10
- var isTypographyProperty = exports.isTypographyProperty = function isTypographyProperty(propertyName) {
11
- return typographyProperties.includes(propertyName);
12
- };
13
- var isFontSize = exports.isFontSize = function isFontSize(node) {
14
- return (0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') && (node.callee.name === 'fontSize' || node.callee.name === 'getFontSize');
15
- };
16
- var isFontSizeSmall = exports.isFontSizeSmall = function isFontSizeSmall(node) {
17
- return (0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') && node.callee.name === 'fontSizeSmall';
18
- };
19
- var isFontFamily = exports.isFontFamily = function isFontFamily(node) {
20
- return (0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') && (node.callee.name === 'fontFamily' || node.callee.name === 'getFontFamily');
21
- };
22
- var isCodeFontFamily = exports.isCodeFontFamily = function isCodeFontFamily(node) {
23
- return (0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') && (node.callee.name === 'codeFontFamily' || node.callee.name === 'getCodeFontFamily');
24
- };
25
- var typographyValueToToken = exports.typographyValueToToken = Object.fromEntries(_tokensRaw.typographyAdg3
26
- // we're filtering here to remove the `font` tokens.
27
- .filter(function (t) {
28
- return t.attributes.group !== 'typography';
29
- }).map(function (currentToken) {
30
- // Group tokens by property name (e.g. fontSize, fontFamily, lineHeight)
31
- // This allows us to look up values specific to a property
32
- // (so as not to mix tokens with overlapping values e.g. font size and line height both have tokens for 16px)
33
- var tokenGroup = currentToken.attributes.group;
34
- return [tokenGroup, Object.fromEntries(_tokensRaw.typographyAdg3.map(function (token) {
35
- return token.attributes.group === tokenGroup ? [token.value.replaceAll("\"", "'"), token.name] : [];
36
- }).filter(function (token) {
37
- return token.length;
38
- }))];
39
- }));
@@ -1,19 +0,0 @@
1
- import { isNodeOfType } from 'eslint-codemod-utils';
2
- import { typographyAdg3 as typographyTokens } from '@atlaskit/tokens/tokens-raw';
3
- const typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
4
- export const isTypographyProperty = propertyName => {
5
- return typographyProperties.includes(propertyName);
6
- };
7
- export const isFontSize = node => isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'fontSize' || node.callee.name === 'getFontSize');
8
- export const isFontSizeSmall = node => isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && node.callee.name === 'fontSizeSmall';
9
- export const isFontFamily = node => isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'fontFamily' || node.callee.name === 'getFontFamily');
10
- export const isCodeFontFamily = node => isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'codeFontFamily' || node.callee.name === 'getCodeFontFamily');
11
- export const typographyValueToToken = Object.fromEntries(typographyTokens
12
- // we're filtering here to remove the `font` tokens.
13
- .filter(t => t.attributes.group !== 'typography').map(currentToken => {
14
- // Group tokens by property name (e.g. fontSize, fontFamily, lineHeight)
15
- // This allows us to look up values specific to a property
16
- // (so as not to mix tokens with overlapping values e.g. font size and line height both have tokens for 16px)
17
- const tokenGroup = currentToken.attributes.group;
18
- return [tokenGroup, Object.fromEntries(typographyTokens.map(token => token.attributes.group === tokenGroup ? [token.value.replaceAll(`"`, `'`), token.name] : []).filter(token => token.length))];
19
- }));
@@ -1,33 +0,0 @@
1
- import { isNodeOfType } from 'eslint-codemod-utils';
2
- import { typographyAdg3 as typographyTokens } from '@atlaskit/tokens/tokens-raw';
3
- var typographyProperties = ['fontSize', 'fontWeight', 'fontFamily', 'lineHeight'];
4
- export var isTypographyProperty = function isTypographyProperty(propertyName) {
5
- return typographyProperties.includes(propertyName);
6
- };
7
- export var isFontSize = function isFontSize(node) {
8
- return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'fontSize' || node.callee.name === 'getFontSize');
9
- };
10
- export var isFontSizeSmall = function isFontSizeSmall(node) {
11
- return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && node.callee.name === 'fontSizeSmall';
12
- };
13
- export var isFontFamily = function isFontFamily(node) {
14
- return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'fontFamily' || node.callee.name === 'getFontFamily');
15
- };
16
- export var isCodeFontFamily = function isCodeFontFamily(node) {
17
- return isNodeOfType(node, 'CallExpression') && isNodeOfType(node.callee, 'Identifier') && (node.callee.name === 'codeFontFamily' || node.callee.name === 'getCodeFontFamily');
18
- };
19
- export var typographyValueToToken = Object.fromEntries(typographyTokens
20
- // we're filtering here to remove the `font` tokens.
21
- .filter(function (t) {
22
- return t.attributes.group !== 'typography';
23
- }).map(function (currentToken) {
24
- // Group tokens by property name (e.g. fontSize, fontFamily, lineHeight)
25
- // This allows us to look up values specific to a property
26
- // (so as not to mix tokens with overlapping values e.g. font size and line height both have tokens for 16px)
27
- var tokenGroup = currentToken.attributes.group;
28
- return [tokenGroup, Object.fromEntries(typographyTokens.map(function (token) {
29
- return token.attributes.group === tokenGroup ? [token.value.replaceAll("\"", "'"), token.name] : [];
30
- }).filter(function (token) {
31
- return token.length;
32
- }))];
33
- }));
@@ -1,9 +0,0 @@
1
- import { CallExpression, EslintNode } from 'eslint-codemod-utils';
2
- export declare const isTypographyProperty: (propertyName: string) => boolean;
3
- export declare const isFontSize: (node: EslintNode) => node is CallExpression;
4
- export declare const isFontSizeSmall: (node: EslintNode) => node is CallExpression;
5
- export declare const isFontFamily: (node: EslintNode) => node is CallExpression;
6
- export declare const isCodeFontFamily: (node: EslintNode) => node is CallExpression;
7
- export declare const typographyValueToToken: {
8
- [k: string]: any;
9
- };
@@ -1,9 +0,0 @@
1
- import { CallExpression, EslintNode } from 'eslint-codemod-utils';
2
- export declare const isTypographyProperty: (propertyName: string) => boolean;
3
- export declare const isFontSize: (node: EslintNode) => node is CallExpression;
4
- export declare const isFontSizeSmall: (node: EslintNode) => node is CallExpression;
5
- export declare const isFontFamily: (node: EslintNode) => node is CallExpression;
6
- export declare const isCodeFontFamily: (node: EslintNode) => node is CallExpression;
7
- export declare const typographyValueToToken: {
8
- [k: string]: any;
9
- };