@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.
- package/CHANGELOG.md +6 -0
- package/README.md +1 -0
- package/constellation/ensure-design-token-usage/usage.mdx +2 -2
- package/constellation/index/usage.mdx +1 -0
- package/constellation/use-tokens-typography/usage.mdx +42 -0
- package/dist/cjs/ast-nodes/index.js +7 -0
- package/dist/cjs/ast-nodes/object-entry.js +27 -0
- package/dist/cjs/ast-nodes/object.js +1 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/rules/ensure-design-token-usage/index.js +5 -4
- package/dist/cjs/rules/ensure-design-token-usage/rule-meta.js +1 -1
- package/dist/cjs/rules/ensure-design-token-usage/spacing.js +5 -1
- package/dist/cjs/rules/ensure-design-token-usage/utils.js +52 -42
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/use-tokens-typography/config/index.js +26 -0
- package/dist/cjs/rules/use-tokens-typography/error-boundary.js +24 -0
- package/dist/cjs/rules/use-tokens-typography/index.js +44 -0
- package/dist/cjs/rules/use-tokens-typography/transformers/style-object.js +212 -0
- package/dist/cjs/rules/use-tokens-typography/utils.js +146 -0
- package/dist/es2019/ast-nodes/index.js +1 -0
- package/dist/es2019/ast-nodes/object-entry.js +22 -0
- package/dist/es2019/ast-nodes/object.js +1 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/rules/ensure-design-token-usage/index.js +6 -5
- package/dist/es2019/rules/ensure-design-token-usage/rule-meta.js +1 -1
- package/dist/es2019/rules/ensure-design-token-usage/spacing.js +5 -1
- package/dist/es2019/rules/ensure-design-token-usage/utils.js +42 -38
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/use-tokens-typography/config/index.js +20 -0
- package/dist/es2019/rules/use-tokens-typography/error-boundary.js +19 -0
- package/dist/es2019/rules/use-tokens-typography/index.js +36 -0
- package/dist/es2019/rules/use-tokens-typography/transformers/style-object.js +209 -0
- package/dist/es2019/rules/use-tokens-typography/utils.js +99 -0
- package/dist/esm/ast-nodes/index.js +1 -0
- package/dist/esm/ast-nodes/object-entry.js +22 -0
- package/dist/esm/ast-nodes/object.js +1 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/rules/ensure-design-token-usage/index.js +6 -5
- package/dist/esm/rules/ensure-design-token-usage/rule-meta.js +1 -1
- package/dist/esm/rules/ensure-design-token-usage/spacing.js +5 -1
- package/dist/esm/rules/ensure-design-token-usage/utils.js +46 -38
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/use-tokens-typography/config/index.js +20 -0
- package/dist/esm/rules/use-tokens-typography/error-boundary.js +18 -0
- package/dist/esm/rules/use-tokens-typography/index.js +38 -0
- package/dist/esm/rules/use-tokens-typography/transformers/style-object.js +206 -0
- package/dist/esm/rules/use-tokens-typography/utils.js +129 -0
- package/dist/types/ast-nodes/index.d.ts +1 -0
- package/dist/types/ast-nodes/object-entry.d.ts +6 -0
- package/dist/types/ast-nodes/object.d.ts +1 -1
- package/dist/types/index.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/rules/ensure-design-token-usage/types.d.ts +1 -1
- package/dist/types/rules/ensure-design-token-usage/utils.d.ts +22 -22
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/use-tokens-typography/config/index.d.ts +6 -0
- package/dist/types/rules/use-tokens-typography/error-boundary.d.ts +11 -0
- package/dist/types/rules/use-tokens-typography/index.d.ts +3 -0
- package/dist/types/rules/use-tokens-typography/transformers/style-object.d.ts +31 -0
- package/dist/types/rules/use-tokens-typography/utils.d.ts +161 -0
- package/dist/types-ts4.5/ast-nodes/index.d.ts +1 -0
- package/dist/types-ts4.5/ast-nodes/object-entry.d.ts +6 -0
- package/dist/types-ts4.5/ast-nodes/object.d.ts +1 -1
- package/dist/types-ts4.5/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/ensure-design-token-usage/types.d.ts +1 -1
- package/dist/types-ts4.5/rules/ensure-design-token-usage/utils.d.ts +22 -22
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/config/index.d.ts +6 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/error-boundary.d.ts +11 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/style-object.d.ts +31 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +161 -0
- package/package.json +1 -1
- package/dist/cjs/rules/ensure-design-token-usage/typography.js +0 -39
- package/dist/es2019/rules/ensure-design-token-usage/typography.js +0 -19
- package/dist/esm/rules/ensure-design-token-usage/typography.js +0 -33
- package/dist/types/rules/ensure-design-token-usage/typography.d.ts +0 -9
- 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) =>
|
|
23
|
-
export declare const getValue: (node: EslintNode, context: Rule.RuleContext) => string | number |
|
|
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:
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
121
|
-
* @param propertyName string camelCased css property
|
|
122
|
-
* @param value
|
|
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
|
|
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,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,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.
|
|
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
|
-
};
|