@atlaskit/eslint-plugin-design-system 8.34.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 +22 -0
- package/constellation/use-primitives-text/usage.mdx +13 -3
- 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/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/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/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/utils.d.ts +33 -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/utils.d.ts +33 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var defaults = {
|
|
2
|
-
patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements']
|
|
2
|
+
patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements'],
|
|
3
|
+
inheritColor: false
|
|
3
4
|
};
|
|
4
5
|
export var getConfig = function getConfig(overrides) {
|
|
5
6
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
2
|
import * as ast from '../../../ast-nodes';
|
|
3
|
-
|
|
4
3
|
// Rename data-testid prop to testId if present
|
|
5
4
|
export function updateTestIdAttributeFix(node, fixer) {
|
|
6
5
|
var testIdAttr = ast.JSXElement.getAttributeByName(node, 'data-testid');
|
|
@@ -8,10 +7,18 @@ export function updateTestIdAttributeFix(node, fixer) {
|
|
|
8
7
|
return ast.JSXAttribute.updateName(testIdAttr, 'testId', fixer);
|
|
9
8
|
}
|
|
10
9
|
}
|
|
10
|
+
|
|
11
|
+
// Add color="inherit" prop depending on config
|
|
12
|
+
export function addColorInheritAttributeFix(node, config, fixer) {
|
|
13
|
+
if (!config.inheritColor) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return ast.JSXElement.addAttribute(node, 'color', 'inherit', fixer);
|
|
17
|
+
}
|
|
11
18
|
export var allowedAttrs = ['id', 'data-testid', 'key'];
|
|
12
19
|
|
|
13
20
|
// Only allow elements with strings as children
|
|
14
|
-
// The use of
|
|
21
|
+
// The use of `<FormattedMessage ... />` component and `{formatMessage(...)}` are allowed as these are used for i18n
|
|
15
22
|
export function hasTextChildrenOnly(node) {
|
|
16
23
|
var _node$children;
|
|
17
24
|
return (_node$children = node.children) === null || _node$children === void 0 ? void 0 : _node$children.every(function (child) {
|
|
@@ -4,7 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
4
4
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
5
|
import * as ast from '../../../ast-nodes';
|
|
6
6
|
import { upsertImportDeclaration } from '../../use-primitives/transformers/emotion-css/upsert-import-declaration';
|
|
7
|
-
import { allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
7
|
+
import { addColorInheritAttributeFix, allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
8
8
|
export var EmphasisElements = {
|
|
9
9
|
lint: function lint(node, _ref) {
|
|
10
10
|
var context = _ref.context,
|
|
@@ -26,7 +26,8 @@ export var EmphasisElements = {
|
|
|
26
26
|
suggest: [{
|
|
27
27
|
desc: "Convert to Text",
|
|
28
28
|
fix: EmphasisElements._fix(node, {
|
|
29
|
-
context: context
|
|
29
|
+
context: context,
|
|
30
|
+
config: config
|
|
30
31
|
})
|
|
31
32
|
}]
|
|
32
33
|
});
|
|
@@ -55,7 +56,8 @@ export var EmphasisElements = {
|
|
|
55
56
|
return true;
|
|
56
57
|
},
|
|
57
58
|
_fix: function _fix(node, _ref3) {
|
|
58
|
-
var context = _ref3.context
|
|
59
|
+
var context = _ref3.context,
|
|
60
|
+
config = _ref3.config;
|
|
59
61
|
return function (fixer) {
|
|
60
62
|
var importFix = upsertImportDeclaration({
|
|
61
63
|
module: '@atlaskit/primitives',
|
|
@@ -63,8 +65,9 @@ export var EmphasisElements = {
|
|
|
63
65
|
}, context, fixer);
|
|
64
66
|
var elementNameFixes = ast.JSXElement.updateName(node, 'Text', fixer);
|
|
65
67
|
var asAttributeFix = ast.JSXElement.addAttribute(node, 'as', 'em', fixer);
|
|
68
|
+
var colorAttributeFix = addColorInheritAttributeFix(node, config, fixer);
|
|
66
69
|
var testAttributeFix = updateTestIdAttributeFix(node, fixer);
|
|
67
|
-
return [importFix].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
70
|
+
return [importFix].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, colorAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
68
71
|
return Boolean(fix);
|
|
69
72
|
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
70
73
|
};
|
|
@@ -4,7 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
4
4
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
5
|
import * as ast from '../../../ast-nodes';
|
|
6
6
|
import { upsertImportDeclaration } from '../../use-primitives/transformers/emotion-css/upsert-import-declaration';
|
|
7
|
-
import { allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
7
|
+
import { addColorInheritAttributeFix, allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
8
8
|
export var ParagraphElements = {
|
|
9
9
|
lint: function lint(node, _ref) {
|
|
10
10
|
var context = _ref.context,
|
|
@@ -43,6 +43,7 @@ export var ParagraphElements = {
|
|
|
43
43
|
desc: 'Convert to Text and Stack',
|
|
44
44
|
fix: ParagraphElements._fixMultiple(node, {
|
|
45
45
|
context: context,
|
|
46
|
+
config: config,
|
|
46
47
|
refs: refs
|
|
47
48
|
})
|
|
48
49
|
}]
|
|
@@ -54,7 +55,8 @@ export var ParagraphElements = {
|
|
|
54
55
|
suggest: [{
|
|
55
56
|
desc: 'Convert to Text',
|
|
56
57
|
fix: ParagraphElements._fixSingle(node, {
|
|
57
|
-
context: context
|
|
58
|
+
context: context,
|
|
59
|
+
config: config
|
|
58
60
|
})
|
|
59
61
|
}]
|
|
60
62
|
});
|
|
@@ -120,6 +122,13 @@ export var ParagraphElements = {
|
|
|
120
122
|
}
|
|
121
123
|
};
|
|
122
124
|
}
|
|
125
|
+
} else if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
|
|
126
|
+
return {
|
|
127
|
+
success: false,
|
|
128
|
+
refs: {
|
|
129
|
+
siblings: siblings
|
|
130
|
+
}
|
|
131
|
+
};
|
|
123
132
|
}
|
|
124
133
|
var importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
|
|
125
134
|
|
|
@@ -140,21 +149,25 @@ export var ParagraphElements = {
|
|
|
140
149
|
};
|
|
141
150
|
},
|
|
142
151
|
_fixSingle: function _fixSingle(node, _ref3) {
|
|
143
|
-
var context = _ref3.context
|
|
152
|
+
var context = _ref3.context,
|
|
153
|
+
config = _ref3.config;
|
|
144
154
|
return function (fixer) {
|
|
145
155
|
var importFix = upsertImportDeclaration({
|
|
146
156
|
module: '@atlaskit/primitives',
|
|
147
157
|
specifiers: ['Text']
|
|
148
158
|
}, context, fixer);
|
|
149
159
|
var elementNameFixes = ast.JSXElement.updateName(node, 'Text', fixer);
|
|
160
|
+
var asAttributeFix = ast.JSXElement.addAttribute(node, 'as', 'p', fixer);
|
|
161
|
+
var colorAttributeFix = addColorInheritAttributeFix(node, config, fixer);
|
|
150
162
|
var testAttributeFix = updateTestIdAttributeFix(node, fixer);
|
|
151
|
-
return [importFix].concat(_toConsumableArray(elementNameFixes), [testAttributeFix]).filter(function (fix) {
|
|
163
|
+
return [importFix].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, colorAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
152
164
|
return Boolean(fix);
|
|
153
165
|
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
154
166
|
};
|
|
155
167
|
},
|
|
156
168
|
_fixMultiple: function _fixMultiple(node, _ref4) {
|
|
157
169
|
var context = _ref4.context,
|
|
170
|
+
config = _ref4.config,
|
|
158
171
|
refs = _ref4.refs;
|
|
159
172
|
return function (fixer) {
|
|
160
173
|
if (!isNodeOfType(node.parent, 'JSXElement') || !node.parent.closingElement) {
|
|
@@ -169,8 +182,10 @@ export var ParagraphElements = {
|
|
|
169
182
|
var siblingFixes = refs.siblings.map(function (sibling) {
|
|
170
183
|
if (isNodeOfType(sibling, 'JSXElement')) {
|
|
171
184
|
var elementNameFixes = ast.JSXElement.updateName(sibling, 'Text', fixer);
|
|
185
|
+
var asAttributeFix = ast.JSXElement.addAttribute(sibling, 'as', 'p', fixer);
|
|
186
|
+
var colorAttributeFix = addColorInheritAttributeFix(sibling, config, fixer);
|
|
172
187
|
var testAttributeFix = updateTestIdAttributeFix(sibling, fixer);
|
|
173
|
-
return [].concat(_toConsumableArray(elementNameFixes), [testAttributeFix]);
|
|
188
|
+
return [].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, colorAttributeFix, testAttributeFix]);
|
|
174
189
|
}
|
|
175
190
|
return undefined;
|
|
176
191
|
}).flat();
|
|
@@ -4,7 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
4
4
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
5
|
import * as ast from '../../../ast-nodes';
|
|
6
6
|
import { upsertImportDeclaration } from '../../use-primitives/transformers/emotion-css/upsert-import-declaration';
|
|
7
|
-
import { allowedAttrs, hasTextChildrenOnly, updateTestIdAttributeFix } from './common';
|
|
7
|
+
import { addColorInheritAttributeFix, allowedAttrs, hasTextChildrenOnly, updateTestIdAttributeFix } from './common';
|
|
8
8
|
export var SpanElements = {
|
|
9
9
|
lint: function lint(node, _ref) {
|
|
10
10
|
var context = _ref.context,
|
|
@@ -26,7 +26,8 @@ export var SpanElements = {
|
|
|
26
26
|
suggest: [{
|
|
27
27
|
desc: "Convert to Text",
|
|
28
28
|
fix: SpanElements._fix(node, {
|
|
29
|
-
context: context
|
|
29
|
+
context: context,
|
|
30
|
+
config: config
|
|
30
31
|
})
|
|
31
32
|
}]
|
|
32
33
|
});
|
|
@@ -60,16 +61,17 @@ export var SpanElements = {
|
|
|
60
61
|
return true;
|
|
61
62
|
},
|
|
62
63
|
_fix: function _fix(node, _ref3) {
|
|
63
|
-
var context = _ref3.context
|
|
64
|
+
var context = _ref3.context,
|
|
65
|
+
config = _ref3.config;
|
|
64
66
|
return function (fixer) {
|
|
65
67
|
var importFix = upsertImportDeclaration({
|
|
66
68
|
module: '@atlaskit/primitives',
|
|
67
69
|
specifiers: ['Text']
|
|
68
70
|
}, context, fixer);
|
|
69
71
|
var elementNameFixes = ast.JSXElement.updateName(node, 'Text', fixer);
|
|
70
|
-
var
|
|
72
|
+
var colorAttributeFix = addColorInheritAttributeFix(node, config, fixer);
|
|
71
73
|
var testAttributeFix = updateTestIdAttributeFix(node, fixer);
|
|
72
|
-
return [importFix].concat(_toConsumableArray(elementNameFixes), [
|
|
74
|
+
return [importFix].concat(_toConsumableArray(elementNameFixes), [colorAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
73
75
|
return Boolean(fix);
|
|
74
76
|
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
75
77
|
};
|
|
@@ -4,7 +4,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
4
4
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
5
5
|
import * as ast from '../../../ast-nodes';
|
|
6
6
|
import { upsertImportDeclaration } from '../../use-primitives/transformers/emotion-css/upsert-import-declaration';
|
|
7
|
-
import { allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
7
|
+
import { addColorInheritAttributeFix, allowedAttrs, updateTestIdAttributeFix } from './common';
|
|
8
8
|
export var StrongElements = {
|
|
9
9
|
lint: function lint(node, _ref) {
|
|
10
10
|
var context = _ref.context,
|
|
@@ -26,7 +26,8 @@ export var StrongElements = {
|
|
|
26
26
|
suggest: [{
|
|
27
27
|
desc: "Convert to Text",
|
|
28
28
|
fix: StrongElements._fix(node, {
|
|
29
|
-
context: context
|
|
29
|
+
context: context,
|
|
30
|
+
config: config
|
|
30
31
|
})
|
|
31
32
|
}]
|
|
32
33
|
});
|
|
@@ -55,7 +56,8 @@ export var StrongElements = {
|
|
|
55
56
|
return true;
|
|
56
57
|
},
|
|
57
58
|
_fix: function _fix(node, _ref3) {
|
|
58
|
-
var context = _ref3.context
|
|
59
|
+
var context = _ref3.context,
|
|
60
|
+
config = _ref3.config;
|
|
59
61
|
return function (fixer) {
|
|
60
62
|
var importFix = upsertImportDeclaration({
|
|
61
63
|
module: '@atlaskit/primitives',
|
|
@@ -63,8 +65,9 @@ export var StrongElements = {
|
|
|
63
65
|
}, context, fixer);
|
|
64
66
|
var elementNameFixes = ast.JSXElement.updateName(node, 'Text', fixer);
|
|
65
67
|
var asAttributeFix = ast.JSXElement.addAttribute(node, 'as', 'strong', fixer);
|
|
68
|
+
var colorAttributeFix = addColorInheritAttributeFix(node, config, fixer);
|
|
66
69
|
var testAttributeFix = updateTestIdAttributeFix(node, fixer);
|
|
67
|
-
return [importFix].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
70
|
+
return [importFix].concat(_toConsumableArray(elementNameFixes), [asAttributeFix, colorAttributeFix, testAttributeFix]).filter(function (fix) {
|
|
68
71
|
return Boolean(fix);
|
|
69
72
|
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
70
73
|
};
|
|
@@ -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 {};
|
|
@@ -126,6 +126,39 @@ export declare const fontFamilyTokens: ({
|
|
|
126
126
|
name: string;
|
|
127
127
|
path: string[];
|
|
128
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;
|
|
129
162
|
} | {
|
|
130
163
|
attributes: {
|
|
131
164
|
group: string;
|
|
@@ -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 {};
|
|
@@ -126,6 +126,39 @@ export declare const fontFamilyTokens: ({
|
|
|
126
126
|
name: string;
|
|
127
127
|
path: string[];
|
|
128
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;
|
|
129
162
|
} | {
|
|
130
163
|
attributes: {
|
|
131
164
|
group: string;
|
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.36.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|