@atlaskit/eslint-plugin-design-system 8.33.0 → 8.36.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 +28 -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-primitives-text/usage.mdx +13 -3
- 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-primitives/transformers/compiled-styled/find-valid-jsx-usage-to-transform.js +24 -1
- package/dist/cjs/rules/use-primitives/transformers/compiled-styled/index.js +2 -1
- package/dist/cjs/rules/use-primitives-text/config/index.js +2 -1
- package/dist/cjs/rules/use-primitives-text/transformers/common.js +10 -1
- package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +6 -3
- package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +19 -4
- package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +6 -4
- package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +6 -3
- 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-primitives/transformers/compiled-styled/find-valid-jsx-usage-to-transform.js +17 -3
- package/dist/es2019/rules/use-primitives/transformers/compiled-styled/index.js +2 -1
- package/dist/es2019/rules/use-primitives-text/config/index.js +2 -1
- package/dist/es2019/rules/use-primitives-text/transformers/common.js +9 -2
- package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +7 -4
- package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +20 -5
- package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +7 -5
- package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +7 -4
- 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-primitives/transformers/compiled-styled/find-valid-jsx-usage-to-transform.js +23 -2
- package/dist/esm/rules/use-primitives/transformers/compiled-styled/index.js +2 -1
- package/dist/esm/rules/use-primitives-text/config/index.js +2 -1
- package/dist/esm/rules/use-primitives-text/transformers/common.js +9 -2
- package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +7 -4
- package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +20 -5
- package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +7 -5
- package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +7 -4
- 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-primitives/config/index.d.ts +1 -1
- package/dist/types/rules/use-primitives/transformers/compiled-styled/find-valid-jsx-usage-to-transform.d.ts +3 -1
- package/dist/types/rules/use-primitives/transformers/compiled-styled/index.d.ts +1 -1
- package/dist/types/rules/use-primitives/transformers/emotion-css/index.d.ts +1 -2
- package/dist/types/rules/use-primitives-text/config/index.d.ts +1 -0
- package/dist/types/rules/use-primitives-text/transformers/common.d.ts +6 -0
- package/dist/types/rules/use-primitives-text/transformers/emphasis-elements.d.ts +2 -10
- package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +4 -12
- package/dist/types/rules/use-primitives-text/transformers/span-elements.d.ts +2 -10
- package/dist/types/rules/use-primitives-text/transformers/strong-elements.d.ts +2 -10
- 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 +194 -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-primitives/config/index.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/find-valid-jsx-usage-to-transform.d.ts +3 -1
- package/dist/types-ts4.5/rules/use-primitives/transformers/compiled-styled/index.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-primitives/transformers/emotion-css/index.d.ts +1 -2
- package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/common.d.ts +6 -0
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/emphasis-elements.d.ts +2 -10
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +4 -12
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/span-elements.d.ts +2 -10
- package/dist/types-ts4.5/rules/use-primitives-text/transformers/strong-elements.d.ts +2 -10
- 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 +194 -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,16 +1,8 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
import {
|
|
4
|
-
interface MetaData {
|
|
5
|
-
context: Rule.RuleContext;
|
|
6
|
-
config: RuleConfig;
|
|
7
|
-
}
|
|
8
|
-
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
3
|
+
import { type MetaData } from './common';
|
|
9
4
|
export declare const StrongElements: {
|
|
10
5
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
6
|
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
-
_fix(node: JSXElement, { context }:
|
|
13
|
-
context: Rule.RuleContext;
|
|
14
|
-
}): FixFunction;
|
|
7
|
+
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
15
8
|
};
|
|
16
|
-
export {};
|
|
@@ -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,194 @@
|
|
|
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
|
+
deprecated: string;
|
|
135
|
+
description: 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
|
+
deprecated: string;
|
|
147
|
+
description: string;
|
|
148
|
+
responsiveSmallerVariant?: undefined;
|
|
149
|
+
};
|
|
150
|
+
value: {
|
|
151
|
+
fontWeight: string;
|
|
152
|
+
fontSize: string;
|
|
153
|
+
lineHeight: string;
|
|
154
|
+
fontFamily: string;
|
|
155
|
+
fontStyle: string;
|
|
156
|
+
letterSpacing: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
name: string;
|
|
160
|
+
path: string[];
|
|
161
|
+
cleanName: string;
|
|
162
|
+
} | {
|
|
163
|
+
attributes: {
|
|
164
|
+
group: string;
|
|
165
|
+
state: string;
|
|
166
|
+
introduced: string;
|
|
167
|
+
description: string;
|
|
168
|
+
deprecated: string;
|
|
169
|
+
responsiveSmallerVariant?: undefined;
|
|
170
|
+
};
|
|
171
|
+
value: string;
|
|
172
|
+
filePath: string;
|
|
173
|
+
isSource: boolean;
|
|
174
|
+
original: {
|
|
175
|
+
attributes: {
|
|
176
|
+
group: string;
|
|
177
|
+
state: string;
|
|
178
|
+
introduced: string;
|
|
179
|
+
description: string;
|
|
180
|
+
deprecated: string;
|
|
181
|
+
responsiveSmallerVariant?: undefined;
|
|
182
|
+
};
|
|
183
|
+
value: string;
|
|
184
|
+
};
|
|
185
|
+
name: string;
|
|
186
|
+
path: string[];
|
|
187
|
+
cleanName: string;
|
|
188
|
+
})[];
|
|
189
|
+
export declare function findFontFamilyValueForToken(tokenName: string): string;
|
|
190
|
+
export declare function notUndefined<V>(value: V | undefined): value is V;
|
|
191
|
+
export declare function isValidPropertyNode(node: Property): boolean;
|
|
192
|
+
export declare function getTokenProperty(propertyName: string, tokenName: string, tokenFallback: string): import("eslint-codemod-utils").StringableASTNode<Property>;
|
|
193
|
+
export declare function getLiteralProperty(propertyName: string, propertyValue: string): import("eslint-codemod-utils").StringableASTNode<Property>;
|
|
194
|
+
export declare function convertPropertyNodeToStringableNode(node: Property): import("eslint-codemod-utils").StringableASTNode<Property>;
|
|
@@ -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
|
|
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::
|
|
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,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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties' | 'dimension-properties';
|
|
1
|
+
type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties' | 'dimension-properties' | 'jsx-order-fix';
|
|
2
2
|
export interface RuleConfig {
|
|
3
3
|
patterns: Pattern[];
|
|
4
4
|
}
|
|
@@ -3,5 +3,7 @@ import { JSXOpeningElement } from 'eslint-codemod-utils';
|
|
|
3
3
|
/**
|
|
4
4
|
* Given a component name finds its JSX usages and performs some
|
|
5
5
|
* additional validations to ensure transformation can be done correctly
|
|
6
|
+
*
|
|
7
|
+
* anyOrder: if true, the order of the references doesn't matter (JSX or style declaration)
|
|
6
8
|
*/
|
|
7
|
-
export declare const findValidJsxUsageToTransform: (componentName: string, scope: Scope.Scope) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
|
|
9
|
+
export declare const findValidJsxUsageToTransform: (componentName: string, scope: Scope.Scope, anyOrder?: boolean) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
|
|
@@ -20,6 +20,6 @@ export declare const CompiledStyled: {
|
|
|
20
20
|
* All required validation steps have been taken care of before this
|
|
21
21
|
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
22
22
|
*/
|
|
23
|
-
_fix(refs: Refs, context: Rule.RuleContext):
|
|
23
|
+
_fix(refs: Refs, context: Rule.RuleContext): Rule.ReportFixer;
|
|
24
24
|
};
|
|
25
25
|
export {};
|
|
@@ -5,12 +5,11 @@ interface MetaData {
|
|
|
5
5
|
context: Rule.RuleContext;
|
|
6
6
|
config: RuleConfig;
|
|
7
7
|
}
|
|
8
|
-
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
9
8
|
export declare const EmotionCSS: {
|
|
10
9
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
10
|
_check(node: Rule.Node, { context, config }: MetaData): boolean;
|
|
12
11
|
_fix(node: JSXElement, { context }: {
|
|
13
12
|
context: Rule.RuleContext;
|
|
14
|
-
}):
|
|
13
|
+
}): Rule.ReportFixer;
|
|
15
14
|
};
|
|
16
15
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type Pattern = 'paragraph-elements' | 'span-elements' | 'strong-elements' | 'emphasis-elements';
|
|
2
2
|
export interface RuleConfig {
|
|
3
3
|
patterns: Pattern[];
|
|
4
|
+
inheritColor: boolean;
|
|
4
5
|
}
|
|
5
6
|
export declare const getConfig: (overrides: Partial<RuleConfig>) => Required<RuleConfig>;
|
|
6
7
|
export {};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
+
import { RuleConfig } from '../config';
|
|
4
|
+
export type MetaData = {
|
|
5
|
+
context: Rule.RuleContext;
|
|
6
|
+
config: RuleConfig;
|
|
7
|
+
};
|
|
3
8
|
export declare function updateTestIdAttributeFix(node: JSXElement, fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
9
|
+
export declare function addColorInheritAttributeFix(node: JSXElement, config: RuleConfig, fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
4
10
|
export declare const allowedAttrs: string[];
|
|
5
11
|
export declare function hasTextChildrenOnly(node: JSXElement): boolean;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
import {
|
|
4
|
-
interface MetaData {
|
|
5
|
-
context: Rule.RuleContext;
|
|
6
|
-
config: RuleConfig;
|
|
7
|
-
}
|
|
8
|
-
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
3
|
+
import { type MetaData } from './common';
|
|
9
4
|
export declare const EmphasisElements: {
|
|
10
5
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
6
|
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
-
_fix(node: JSXElement, { context }:
|
|
13
|
-
context: Rule.RuleContext;
|
|
14
|
-
}): FixFunction;
|
|
7
|
+
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
15
8
|
};
|
|
16
|
-
export {};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
import {
|
|
4
|
-
type MetaData = {
|
|
5
|
-
context: Rule.RuleContext;
|
|
6
|
-
config: RuleConfig;
|
|
7
|
-
};
|
|
3
|
+
import { type MetaData } from './common';
|
|
8
4
|
type CheckResult = {
|
|
9
5
|
success: boolean;
|
|
10
6
|
refs: {
|
|
11
7
|
siblings: JSXElement['children'];
|
|
12
8
|
};
|
|
13
9
|
};
|
|
14
|
-
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
15
10
|
export declare const ParagraphElements: {
|
|
16
11
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
17
12
|
_check(node: JSXElement & {
|
|
@@ -19,14 +14,11 @@ export declare const ParagraphElements: {
|
|
|
19
14
|
}, { context, config }: MetaData): CheckResult;
|
|
20
15
|
_fixSingle(node: JSXElement & {
|
|
21
16
|
parent: Rule.Node;
|
|
22
|
-
}, { context }:
|
|
23
|
-
context: Rule.RuleContext;
|
|
24
|
-
}): FixFunction;
|
|
17
|
+
}, { context, config }: MetaData): Rule.ReportFixer;
|
|
25
18
|
_fixMultiple(node: JSXElement & {
|
|
26
19
|
parent: Rule.Node;
|
|
27
|
-
}, { context, refs }: {
|
|
28
|
-
context: Rule.RuleContext;
|
|
20
|
+
}, { context, config, refs }: MetaData & {
|
|
29
21
|
refs: CheckResult['refs'];
|
|
30
|
-
}):
|
|
22
|
+
}): Rule.ReportFixer;
|
|
31
23
|
};
|
|
32
24
|
export {};
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
import {
|
|
4
|
-
interface MetaData {
|
|
5
|
-
context: Rule.RuleContext;
|
|
6
|
-
config: RuleConfig;
|
|
7
|
-
}
|
|
8
|
-
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
3
|
+
import { type MetaData } from './common';
|
|
9
4
|
export declare const SpanElements: {
|
|
10
5
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
6
|
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
-
_fix(node: JSXElement, { context }:
|
|
13
|
-
context: Rule.RuleContext;
|
|
14
|
-
}): FixFunction;
|
|
7
|
+
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
15
8
|
};
|
|
16
|
-
export {};
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
import {
|
|
4
|
-
interface MetaData {
|
|
5
|
-
context: Rule.RuleContext;
|
|
6
|
-
config: RuleConfig;
|
|
7
|
-
}
|
|
8
|
-
type FixFunction = (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
3
|
+
import { type MetaData } from './common';
|
|
9
4
|
export declare const StrongElements: {
|
|
10
5
|
lint(node: Rule.Node, { context, config }: MetaData): void;
|
|
11
6
|
_check(node: JSXElement, { context, config }: MetaData): boolean;
|
|
12
|
-
_fix(node: JSXElement, { context }:
|
|
13
|
-
context: Rule.RuleContext;
|
|
14
|
-
}): FixFunction;
|
|
7
|
+
_fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
|
|
15
8
|
};
|
|
16
|
-
export {};
|
|
@@ -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;
|