@atlaskit/eslint-plugin-design-system 13.41.1 → 13.41.3
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 +18 -0
- package/README.md +1 -1
- package/dist/cjs/rules/ensure-design-token-usage/utils.js +2 -0
- package/dist/cjs/rules/no-icon-spacing-prop/helpers.js +24 -20
- package/dist/cjs/rules/no-icon-spacing-prop/index.js +13 -13
- package/dist/es2019/rules/ensure-design-token-usage/utils.js +1 -0
- package/dist/es2019/rules/no-icon-spacing-prop/helpers.js +22 -18
- package/dist/es2019/rules/no-icon-spacing-prop/index.js +14 -14
- package/dist/esm/rules/ensure-design-token-usage/utils.js +1 -0
- package/dist/esm/rules/no-icon-spacing-prop/helpers.js +22 -18
- package/dist/esm/rules/no-icon-spacing-prop/index.js +14 -14
- package/dist/types/rules/ensure-design-token-usage/rule-meta.d.ts +17 -17
- package/dist/types/rules/ensure-design-token-usage/utils.d.ts +3 -3
- package/dist/types/rules/no-icon-spacing-prop/helpers.d.ts +7 -7
- package/dist/types/rules/use-should-render-to-parent/index.d.ts +2 -2
- package/dist/types/rules/use-visually-hidden/constants.d.ts +1 -1
- package/dist/types-ts4.5/rules/ensure-design-token-usage/rule-meta.d.ts +17 -17
- package/dist/types-ts4.5/rules/ensure-design-token-usage/utils.d.ts +3 -3
- package/dist/types-ts4.5/rules/no-icon-spacing-prop/helpers.d.ts +7 -7
- package/dist/types-ts4.5/rules/use-should-render-to-parent/index.d.ts +2 -2
- package/dist/types-ts4.5/rules/use-visually-hidden/constants.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.41.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`f1ef2305b8862`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f1ef2305b8862) -
|
|
8
|
+
Remove legacy icon glyphs and oldName prop support from metadata core.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 13.41.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`5e06fddfce409`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5e06fddfce409) -
|
|
16
|
+
Rename codemod to `next-icon-spacing-to-flex-primitive` (now discoverable via
|
|
17
|
+
`npx @atlaskit/codemod-cli`) and update `no-icon-spacing-prop` ESLint rule to generate `Flex`
|
|
18
|
+
wrapper instead of `Box`.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 13.41.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
|
82
82
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-select/README.md">no-html-select</a> | Discourage direct usage of HTML select elements in favor of the Atlassian Design System select component. | Yes | | Yes |
|
|
83
83
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-text-input/README.md">no-html-text-input</a> | Discourage direct usage of HTML text input elements in favor of the Atlassian Design System textfield component. | Yes | | Yes |
|
|
84
84
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-html-textarea/README.md">no-html-textarea</a> | Discourage direct usage of HTML textarea elements in favor of the Atlassian Design System textarea component. | Yes | | Yes |
|
|
85
|
-
| <a href="./packages/design-system/eslint-plugin/src/rules/no-icon-spacing-prop/README.md">no-icon-spacing-prop</a> | Disallows usage of the deprecated spacing prop on new icons. Use
|
|
85
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-icon-spacing-prop/README.md">no-icon-spacing-prop</a> | Disallows usage of the deprecated spacing prop on new icons. Use Flex with cssMap for spacing instead. | Yes | | Yes |
|
|
86
86
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-invalid-css-map/README.md">no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
|
|
87
87
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-keyframes-tagged-template-expression/README.md">no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
88
88
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-legacy-icons/README.md">no-legacy-icons</a> | Enforces no legacy icons are used. | | Yes | Yes |
|
|
@@ -33,6 +33,8 @@ var _tokensRaw = require("@atlaskit/tokens/tokens-raw");
|
|
|
33
33
|
var _findInParent = require("../utils/find-in-parent");
|
|
34
34
|
var _isColor = require("../utils/is-color");
|
|
35
35
|
var _shape = require("./shape");
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
37
|
+
|
|
36
38
|
var properties = ['padding', 'paddingBlock', 'paddingInline', 'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd', 'marginLeft', 'marginTop', 'marginRight', 'marginBottom', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd', 'margin', 'gap', 'rowGap', 'gridRowGap', 'columnGap', 'gridColumnGap', 'top', 'left', 'right', 'bottom', 'inlineStart', 'inlineEnd', 'blockStart', 'blockEnd', 'outline-offset'];
|
|
37
39
|
var spacingValueToToken = Object.fromEntries(_tokensRaw.spacing.map(function (token) {
|
|
38
40
|
return [token.value, token.cleanName];
|
|
@@ -5,15 +5,15 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.TOKEN_IMPORT_MODULE = exports.SPACING_TO_PADDING = exports.
|
|
8
|
+
exports.TOKEN_IMPORT_MODULE = exports.SPACING_TO_PADDING = exports.FLEX_IMPORT_MODULE_NON_COMPILED = exports.FLEX_IMPORT_MODULE = exports.CSS_IMPORT_MODULE = exports.CSSMAP_VARIABLE_NAME = void 0;
|
|
9
9
|
exports.getCssMapKey = getCssMapKey;
|
|
10
10
|
exports.getIconSize = getIconSize;
|
|
11
11
|
exports.getSpacingAttribute = getSpacingAttribute;
|
|
12
12
|
exports.getStaticAttributeValue = getStaticAttributeValue;
|
|
13
13
|
exports.hasSpreadProps = hasSpreadProps;
|
|
14
|
-
exports.upsertBoxImport = upsertBoxImport;
|
|
15
14
|
exports.upsertCssMapImport = upsertCssMapImport;
|
|
16
15
|
exports.upsertCssMapVariable = upsertCssMapVariable;
|
|
16
|
+
exports.upsertFlexImport = upsertFlexImport;
|
|
17
17
|
exports.upsertTokenImport = upsertTokenImport;
|
|
18
18
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
19
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
@@ -21,8 +21,8 @@ var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
|
21
21
|
var ast = _interopRequireWildcard(require("../../ast-nodes"));
|
|
22
22
|
var _import = require("../../ast-nodes/import");
|
|
23
23
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
24
|
-
var
|
|
25
|
-
var
|
|
24
|
+
var FLEX_IMPORT_MODULE = exports.FLEX_IMPORT_MODULE = '@atlaskit/primitives/compiled';
|
|
25
|
+
var FLEX_IMPORT_MODULE_NON_COMPILED = exports.FLEX_IMPORT_MODULE_NON_COMPILED = '@atlaskit/primitives';
|
|
26
26
|
var TOKEN_IMPORT_MODULE = exports.TOKEN_IMPORT_MODULE = '@atlaskit/tokens';
|
|
27
27
|
var CSS_IMPORT_MODULE = exports.CSS_IMPORT_MODULE = '@atlaskit/css';
|
|
28
28
|
var CSSMAP_VARIABLE_NAME = exports.CSSMAP_VARIABLE_NAME = 'iconSpacingStyles';
|
|
@@ -98,22 +98,22 @@ function hasSpreadProps(node) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
|
-
* Upserts `
|
|
102
|
-
* 1. Already imported from `/compiled` → add
|
|
103
|
-
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add
|
|
104
|
-
* 3. No import → insert new `import {
|
|
101
|
+
* Upserts `Flex` from `@atlaskit/primitives/compiled`, handling:
|
|
102
|
+
* 1. Already imported from `/compiled` → add Flex if missing
|
|
103
|
+
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add Flex
|
|
104
|
+
* 3. No import → insert new `import { Flex } from '@atlaskit/primitives/compiled'`
|
|
105
105
|
*/
|
|
106
|
-
function
|
|
106
|
+
function upsertFlexImport(context, fixer) {
|
|
107
107
|
var root = (0, _contextCompat.getSourceCode)(context).ast.body;
|
|
108
108
|
var findExactImports = function findExactImports(module) {
|
|
109
109
|
return root.filter(function (node) {
|
|
110
110
|
return node.type === 'ImportDeclaration' && node.source.value === module;
|
|
111
111
|
});
|
|
112
112
|
};
|
|
113
|
-
var compiledImports = findExactImports(
|
|
113
|
+
var compiledImports = findExactImports(FLEX_IMPORT_MODULE);
|
|
114
114
|
if (compiledImports.length > 0) {
|
|
115
115
|
var decl = compiledImports[0];
|
|
116
|
-
if (_import.Import.containsNamedSpecifier(decl, '
|
|
116
|
+
if (_import.Import.containsNamedSpecifier(decl, 'Flex')) {
|
|
117
117
|
return undefined;
|
|
118
118
|
}
|
|
119
119
|
var specifiers = decl.specifiers.filter(function (s) {
|
|
@@ -121,10 +121,10 @@ function upsertBoxImport(context, fixer) {
|
|
|
121
121
|
}).map(function (s) {
|
|
122
122
|
return s.local.name;
|
|
123
123
|
});
|
|
124
|
-
specifiers.push('
|
|
125
|
-
return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(
|
|
124
|
+
specifiers.push('Flex');
|
|
125
|
+
return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(FLEX_IMPORT_MODULE, "';"));
|
|
126
126
|
}
|
|
127
|
-
var nonCompiledImports = findExactImports(
|
|
127
|
+
var nonCompiledImports = findExactImports(FLEX_IMPORT_MODULE_NON_COMPILED);
|
|
128
128
|
if (nonCompiledImports.length > 0) {
|
|
129
129
|
var _decl = nonCompiledImports[0];
|
|
130
130
|
var _specifiers = _decl.specifiers.filter(function (s) {
|
|
@@ -132,12 +132,14 @@ function upsertBoxImport(context, fixer) {
|
|
|
132
132
|
}).map(function (s) {
|
|
133
133
|
return s.local.name;
|
|
134
134
|
});
|
|
135
|
-
if (!_specifiers.includes('
|
|
136
|
-
|
|
135
|
+
if (!_specifiers.includes('Flex')) {
|
|
136
|
+
_specifiers.push('Flex');
|
|
137
|
+
}
|
|
138
|
+
return fixer.replaceText(_decl, "import { ".concat(_specifiers.join(', '), " } from '").concat(FLEX_IMPORT_MODULE, "';"));
|
|
137
139
|
}
|
|
138
140
|
return ast.Root.upsertNamedImportDeclaration({
|
|
139
|
-
module:
|
|
140
|
-
specifiers: ['
|
|
141
|
+
module: FLEX_IMPORT_MODULE,
|
|
142
|
+
specifiers: ['Flex']
|
|
141
143
|
}, context, fixer);
|
|
142
144
|
}
|
|
143
145
|
|
|
@@ -163,7 +165,9 @@ function upsertCssMapImport(context, fixer) {
|
|
|
163
165
|
}).map(function (s) {
|
|
164
166
|
return s.local.name;
|
|
165
167
|
});
|
|
166
|
-
if (!hasCssMap)
|
|
168
|
+
if (!hasCssMap) {
|
|
169
|
+
specifiers.push('cssMap');
|
|
170
|
+
}
|
|
167
171
|
return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(CSS_IMPORT_MODULE, "';"));
|
|
168
172
|
}
|
|
169
173
|
return ast.Root.upsertNamedImportDeclaration({
|
|
@@ -213,7 +217,7 @@ function upsertCssMapVariable(context, fixer, paddingToken) {
|
|
|
213
217
|
var sourceCode = (0, _contextCompat.getSourceCode)(context);
|
|
214
218
|
var body = sourceCode.ast.body;
|
|
215
219
|
var key = getCssMapKey(paddingToken);
|
|
216
|
-
var keyValuePair = " ".concat(key, ": {
|
|
220
|
+
var keyValuePair = " ".concat(key, ": { paddingBlock: token('").concat(paddingToken, "'), paddingInline: token('").concat(paddingToken, "') }");
|
|
217
221
|
|
|
218
222
|
// Check if iconSpacingStyles cssMap variable already exists
|
|
219
223
|
var existingVar = body.find(function (node) {
|
|
@@ -14,19 +14,19 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
14
14
|
hasSuggestions: true,
|
|
15
15
|
type: 'suggestion',
|
|
16
16
|
docs: {
|
|
17
|
-
description: 'Disallows usage of the deprecated spacing prop on new icons. Use
|
|
17
|
+
description: 'Disallows usage of the deprecated spacing prop on new icons. Use Flex with cssMap for spacing instead.',
|
|
18
18
|
recommended: true,
|
|
19
19
|
severity: 'warn'
|
|
20
20
|
},
|
|
21
21
|
messages: {
|
|
22
|
-
noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<
|
|
23
|
-
noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<
|
|
22
|
+
noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<Flex xcss={iconSpacingStyles.spaceXXX}>` using `cssMap` from `@atlaskit/css` instead.",
|
|
23
|
+
noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<Flex xcss={...}>` using `cssMap` from `@atlaskit/css`.",
|
|
24
24
|
suggestRemoveSpacing: 'Remove the `spacing` prop.',
|
|
25
|
-
|
|
25
|
+
suggestWrapInFlex: 'Wrap in `<Flex xcss={{{cssMapVarName}}.{{cssMapKey}}}>` and remove the `spacing` prop.'
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
create: function create(context) {
|
|
29
|
-
var isNewIcon = (0, _isFromImportSource.createIsFromImportSourceFor)(/^@(atlaskit\/icon|atlaskit\/icon-lab
|
|
29
|
+
var isNewIcon = (0, _isFromImportSource.createIsFromImportSourceFor)(/^@(atlaskit\/icon|atlaskit\/icon-lab)\/core\//);
|
|
30
30
|
return (0, _errorBoundary.errorBoundary)({
|
|
31
31
|
JSXElement: function JSXElement(node) {
|
|
32
32
|
var _SPACING_TO_PADDING$s;
|
|
@@ -89,7 +89,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
89
89
|
iconName: iconName
|
|
90
90
|
},
|
|
91
91
|
suggest: [{
|
|
92
|
-
messageId: '
|
|
92
|
+
messageId: 'suggestWrapInFlex',
|
|
93
93
|
data: {
|
|
94
94
|
cssMapVarName: _helpers.CSSMAP_VARIABLE_NAME,
|
|
95
95
|
cssMapKey: cssMapKey
|
|
@@ -100,9 +100,9 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
100
100
|
// 1. Remove spacing prop
|
|
101
101
|
fixes.push(fixer.remove(spacingAttr));
|
|
102
102
|
|
|
103
|
-
// 2. Wrap in
|
|
104
|
-
fixes.push(fixer.insertTextBefore(node, "<
|
|
105
|
-
fixes.push(fixer.insertTextAfter(node, "</
|
|
103
|
+
// 2. Wrap in Flex with cssMap reference
|
|
104
|
+
fixes.push(fixer.insertTextBefore(node, "<Flex xcss={".concat(_helpers.CSSMAP_VARIABLE_NAME, ".").concat(cssMapKey, "}>")));
|
|
105
|
+
fixes.push(fixer.insertTextAfter(node, "</Flex>"));
|
|
106
106
|
|
|
107
107
|
// 3. Insert/update cssMap variable after last import
|
|
108
108
|
var cssMapFix = (0, _helpers.upsertCssMapVariable)(context, fixer, paddingToken);
|
|
@@ -116,10 +116,10 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
116
116
|
fixes.push(cssFix);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
// 5. Add
|
|
120
|
-
var
|
|
121
|
-
if (
|
|
122
|
-
fixes.push(
|
|
119
|
+
// 5. Add Flex to @atlaskit/primitives/compiled
|
|
120
|
+
var flexFix = (0, _helpers.upsertFlexImport)(context, fixer);
|
|
121
|
+
if (flexFix) {
|
|
122
|
+
fixes.push(flexFix);
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// 6. Add token from @atlaskit/tokens
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
1
2
|
import { callExpression, identifier, insertAtStartOfFile, insertImportDeclaration, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
2
3
|
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
3
4
|
import { spacing as spacingScale } from '@atlaskit/tokens/tokens-raw';
|
|
@@ -2,8 +2,8 @@ import { isNodeOfType } from 'eslint-codemod-utils';
|
|
|
2
2
|
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
3
3
|
import * as ast from '../../ast-nodes';
|
|
4
4
|
import { Import } from '../../ast-nodes/import';
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
5
|
+
export const FLEX_IMPORT_MODULE = '@atlaskit/primitives/compiled';
|
|
6
|
+
export const FLEX_IMPORT_MODULE_NON_COMPILED = '@atlaskit/primitives';
|
|
7
7
|
export const TOKEN_IMPORT_MODULE = '@atlaskit/tokens';
|
|
8
8
|
export const CSS_IMPORT_MODULE = '@atlaskit/css';
|
|
9
9
|
export const CSSMAP_VARIABLE_NAME = 'iconSpacingStyles';
|
|
@@ -73,34 +73,36 @@ export function hasSpreadProps(node) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* Upserts `
|
|
77
|
-
* 1. Already imported from `/compiled` → add
|
|
78
|
-
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add
|
|
79
|
-
* 3. No import → insert new `import {
|
|
76
|
+
* Upserts `Flex` from `@atlaskit/primitives/compiled`, handling:
|
|
77
|
+
* 1. Already imported from `/compiled` → add Flex if missing
|
|
78
|
+
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add Flex
|
|
79
|
+
* 3. No import → insert new `import { Flex } from '@atlaskit/primitives/compiled'`
|
|
80
80
|
*/
|
|
81
|
-
export function
|
|
81
|
+
export function upsertFlexImport(context, fixer) {
|
|
82
82
|
const root = getSourceCode(context).ast.body;
|
|
83
83
|
const findExactImports = module => root.filter(node => node.type === 'ImportDeclaration' && node.source.value === module);
|
|
84
|
-
const compiledImports = findExactImports(
|
|
84
|
+
const compiledImports = findExactImports(FLEX_IMPORT_MODULE);
|
|
85
85
|
if (compiledImports.length > 0) {
|
|
86
86
|
const decl = compiledImports[0];
|
|
87
|
-
if (Import.containsNamedSpecifier(decl, '
|
|
87
|
+
if (Import.containsNamedSpecifier(decl, 'Flex')) {
|
|
88
88
|
return undefined;
|
|
89
89
|
}
|
|
90
90
|
const specifiers = decl.specifiers.filter(s => s.type === 'ImportSpecifier').map(s => s.local.name);
|
|
91
|
-
specifiers.push('
|
|
92
|
-
return fixer.replaceText(decl, `import { ${specifiers.join(', ')} } from '${
|
|
91
|
+
specifiers.push('Flex');
|
|
92
|
+
return fixer.replaceText(decl, `import { ${specifiers.join(', ')} } from '${FLEX_IMPORT_MODULE}';`);
|
|
93
93
|
}
|
|
94
|
-
const nonCompiledImports = findExactImports(
|
|
94
|
+
const nonCompiledImports = findExactImports(FLEX_IMPORT_MODULE_NON_COMPILED);
|
|
95
95
|
if (nonCompiledImports.length > 0) {
|
|
96
96
|
const decl = nonCompiledImports[0];
|
|
97
97
|
const specifiers = decl.specifiers.filter(s => s.type === 'ImportSpecifier').map(s => s.local.name);
|
|
98
|
-
if (!specifiers.includes('
|
|
99
|
-
|
|
98
|
+
if (!specifiers.includes('Flex')) {
|
|
99
|
+
specifiers.push('Flex');
|
|
100
|
+
}
|
|
101
|
+
return fixer.replaceText(decl, `import { ${specifiers.join(', ')} } from '${FLEX_IMPORT_MODULE}';`);
|
|
100
102
|
}
|
|
101
103
|
return ast.Root.upsertNamedImportDeclaration({
|
|
102
|
-
module:
|
|
103
|
-
specifiers: ['
|
|
104
|
+
module: FLEX_IMPORT_MODULE,
|
|
105
|
+
specifiers: ['Flex']
|
|
104
106
|
}, context, fixer);
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -120,7 +122,9 @@ export function upsertCssMapImport(context, fixer) {
|
|
|
120
122
|
return undefined;
|
|
121
123
|
}
|
|
122
124
|
const specifiers = decl.specifiers.filter(s => s.type === 'ImportSpecifier').map(s => s.local.name);
|
|
123
|
-
if (!hasCssMap)
|
|
125
|
+
if (!hasCssMap) {
|
|
126
|
+
specifiers.push('cssMap');
|
|
127
|
+
}
|
|
124
128
|
return fixer.replaceText(decl, `import { ${specifiers.join(', ')} } from '${CSS_IMPORT_MODULE}';`);
|
|
125
129
|
}
|
|
126
130
|
return ast.Root.upsertNamedImportDeclaration({
|
|
@@ -164,7 +168,7 @@ export function upsertCssMapVariable(context, fixer, paddingToken) {
|
|
|
164
168
|
const sourceCode = getSourceCode(context);
|
|
165
169
|
const body = sourceCode.ast.body;
|
|
166
170
|
const key = getCssMapKey(paddingToken);
|
|
167
|
-
const keyValuePair = ` ${key}: {
|
|
171
|
+
const keyValuePair = ` ${key}: { paddingBlock: token('${paddingToken}'), paddingInline: token('${paddingToken}') }`;
|
|
168
172
|
|
|
169
173
|
// Check if iconSpacingStyles cssMap variable already exists
|
|
170
174
|
const existingVar = body.find(node => {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { createIsFromImportSourceFor } from '../no-custom-icons/checks/is-from-import-source';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
3
|
import { errorBoundary } from '../utils/error-boundary';
|
|
4
|
-
import { CSSMAP_VARIABLE_NAME, getCssMapKey, getIconSize, getSpacingAttribute, getStaticAttributeValue, hasSpreadProps, SPACING_TO_PADDING,
|
|
4
|
+
import { CSSMAP_VARIABLE_NAME, getCssMapKey, getIconSize, getSpacingAttribute, getStaticAttributeValue, hasSpreadProps, SPACING_TO_PADDING, upsertCssMapImport, upsertCssMapVariable, upsertFlexImport, upsertTokenImport } from './helpers';
|
|
5
5
|
const rule = createLintRule({
|
|
6
6
|
meta: {
|
|
7
7
|
name: 'no-icon-spacing-prop',
|
|
8
8
|
hasSuggestions: true,
|
|
9
9
|
type: 'suggestion',
|
|
10
10
|
docs: {
|
|
11
|
-
description: 'Disallows usage of the deprecated spacing prop on new icons. Use
|
|
11
|
+
description: 'Disallows usage of the deprecated spacing prop on new icons. Use Flex with cssMap for spacing instead.',
|
|
12
12
|
recommended: true,
|
|
13
13
|
severity: 'warn'
|
|
14
14
|
},
|
|
15
15
|
messages: {
|
|
16
|
-
noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<
|
|
17
|
-
noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<
|
|
16
|
+
noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<Flex xcss={iconSpacingStyles.spaceXXX}>` using `cssMap` from `@atlaskit/css` instead.",
|
|
17
|
+
noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<Flex xcss={...}>` using `cssMap` from `@atlaskit/css`.",
|
|
18
18
|
suggestRemoveSpacing: 'Remove the `spacing` prop.',
|
|
19
|
-
|
|
19
|
+
suggestWrapInFlex: 'Wrap in `<Flex xcss={{{cssMapVarName}}.{{cssMapKey}}}>` and remove the `spacing` prop.'
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
create(context) {
|
|
23
|
-
const isNewIcon = createIsFromImportSourceFor(/^@(atlaskit\/icon|atlaskit\/icon-lab
|
|
23
|
+
const isNewIcon = createIsFromImportSourceFor(/^@(atlaskit\/icon|atlaskit\/icon-lab)\/core\//);
|
|
24
24
|
return errorBoundary({
|
|
25
25
|
JSXElement(node) {
|
|
26
26
|
var _SPACING_TO_PADDING$s;
|
|
@@ -83,7 +83,7 @@ const rule = createLintRule({
|
|
|
83
83
|
iconName
|
|
84
84
|
},
|
|
85
85
|
suggest: [{
|
|
86
|
-
messageId: '
|
|
86
|
+
messageId: 'suggestWrapInFlex',
|
|
87
87
|
data: {
|
|
88
88
|
cssMapVarName: CSSMAP_VARIABLE_NAME,
|
|
89
89
|
cssMapKey
|
|
@@ -94,9 +94,9 @@ const rule = createLintRule({
|
|
|
94
94
|
// 1. Remove spacing prop
|
|
95
95
|
fixes.push(fixer.remove(spacingAttr));
|
|
96
96
|
|
|
97
|
-
// 2. Wrap in
|
|
98
|
-
fixes.push(fixer.insertTextBefore(node, `<
|
|
99
|
-
fixes.push(fixer.insertTextAfter(node, `</
|
|
97
|
+
// 2. Wrap in Flex with cssMap reference
|
|
98
|
+
fixes.push(fixer.insertTextBefore(node, `<Flex xcss={${CSSMAP_VARIABLE_NAME}.${cssMapKey}}>`));
|
|
99
|
+
fixes.push(fixer.insertTextAfter(node, `</Flex>`));
|
|
100
100
|
|
|
101
101
|
// 3. Insert/update cssMap variable after last import
|
|
102
102
|
const cssMapFix = upsertCssMapVariable(context, fixer, paddingToken);
|
|
@@ -110,10 +110,10 @@ const rule = createLintRule({
|
|
|
110
110
|
fixes.push(cssFix);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
// 5. Add
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
fixes.push(
|
|
113
|
+
// 5. Add Flex to @atlaskit/primitives/compiled
|
|
114
|
+
const flexFix = upsertFlexImport(context, fixer);
|
|
115
|
+
if (flexFix) {
|
|
116
|
+
fixes.push(flexFix);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// 6. Add token from @atlaskit/tokens
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
2
3
|
import { callExpression, identifier, insertAtStartOfFile, insertImportDeclaration, isNodeOfType, literal } from 'eslint-codemod-utils';
|
|
3
4
|
import { getScope, getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
5
|
import { spacing as spacingScale } from '@atlaskit/tokens/tokens-raw';
|
|
@@ -3,8 +3,8 @@ import { isNodeOfType } from 'eslint-codemod-utils';
|
|
|
3
3
|
import { getSourceCode } from '@atlaskit/eslint-utils/context-compat';
|
|
4
4
|
import * as ast from '../../ast-nodes';
|
|
5
5
|
import { Import } from '../../ast-nodes/import';
|
|
6
|
-
export var
|
|
7
|
-
export var
|
|
6
|
+
export var FLEX_IMPORT_MODULE = '@atlaskit/primitives/compiled';
|
|
7
|
+
export var FLEX_IMPORT_MODULE_NON_COMPILED = '@atlaskit/primitives';
|
|
8
8
|
export var TOKEN_IMPORT_MODULE = '@atlaskit/tokens';
|
|
9
9
|
export var CSS_IMPORT_MODULE = '@atlaskit/css';
|
|
10
10
|
export var CSSMAP_VARIABLE_NAME = 'iconSpacingStyles';
|
|
@@ -80,22 +80,22 @@ export function hasSpreadProps(node) {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
|
-
* Upserts `
|
|
84
|
-
* 1. Already imported from `/compiled` → add
|
|
85
|
-
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add
|
|
86
|
-
* 3. No import → insert new `import {
|
|
83
|
+
* Upserts `Flex` from `@atlaskit/primitives/compiled`, handling:
|
|
84
|
+
* 1. Already imported from `/compiled` → add Flex if missing
|
|
85
|
+
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add Flex
|
|
86
|
+
* 3. No import → insert new `import { Flex } from '@atlaskit/primitives/compiled'`
|
|
87
87
|
*/
|
|
88
|
-
export function
|
|
88
|
+
export function upsertFlexImport(context, fixer) {
|
|
89
89
|
var root = getSourceCode(context).ast.body;
|
|
90
90
|
var findExactImports = function findExactImports(module) {
|
|
91
91
|
return root.filter(function (node) {
|
|
92
92
|
return node.type === 'ImportDeclaration' && node.source.value === module;
|
|
93
93
|
});
|
|
94
94
|
};
|
|
95
|
-
var compiledImports = findExactImports(
|
|
95
|
+
var compiledImports = findExactImports(FLEX_IMPORT_MODULE);
|
|
96
96
|
if (compiledImports.length > 0) {
|
|
97
97
|
var decl = compiledImports[0];
|
|
98
|
-
if (Import.containsNamedSpecifier(decl, '
|
|
98
|
+
if (Import.containsNamedSpecifier(decl, 'Flex')) {
|
|
99
99
|
return undefined;
|
|
100
100
|
}
|
|
101
101
|
var specifiers = decl.specifiers.filter(function (s) {
|
|
@@ -103,10 +103,10 @@ export function upsertBoxImport(context, fixer) {
|
|
|
103
103
|
}).map(function (s) {
|
|
104
104
|
return s.local.name;
|
|
105
105
|
});
|
|
106
|
-
specifiers.push('
|
|
107
|
-
return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(
|
|
106
|
+
specifiers.push('Flex');
|
|
107
|
+
return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(FLEX_IMPORT_MODULE, "';"));
|
|
108
108
|
}
|
|
109
|
-
var nonCompiledImports = findExactImports(
|
|
109
|
+
var nonCompiledImports = findExactImports(FLEX_IMPORT_MODULE_NON_COMPILED);
|
|
110
110
|
if (nonCompiledImports.length > 0) {
|
|
111
111
|
var _decl = nonCompiledImports[0];
|
|
112
112
|
var _specifiers = _decl.specifiers.filter(function (s) {
|
|
@@ -114,12 +114,14 @@ export function upsertBoxImport(context, fixer) {
|
|
|
114
114
|
}).map(function (s) {
|
|
115
115
|
return s.local.name;
|
|
116
116
|
});
|
|
117
|
-
if (!_specifiers.includes('
|
|
118
|
-
|
|
117
|
+
if (!_specifiers.includes('Flex')) {
|
|
118
|
+
_specifiers.push('Flex');
|
|
119
|
+
}
|
|
120
|
+
return fixer.replaceText(_decl, "import { ".concat(_specifiers.join(', '), " } from '").concat(FLEX_IMPORT_MODULE, "';"));
|
|
119
121
|
}
|
|
120
122
|
return ast.Root.upsertNamedImportDeclaration({
|
|
121
|
-
module:
|
|
122
|
-
specifiers: ['
|
|
123
|
+
module: FLEX_IMPORT_MODULE,
|
|
124
|
+
specifiers: ['Flex']
|
|
123
125
|
}, context, fixer);
|
|
124
126
|
}
|
|
125
127
|
|
|
@@ -145,7 +147,9 @@ export function upsertCssMapImport(context, fixer) {
|
|
|
145
147
|
}).map(function (s) {
|
|
146
148
|
return s.local.name;
|
|
147
149
|
});
|
|
148
|
-
if (!hasCssMap)
|
|
150
|
+
if (!hasCssMap) {
|
|
151
|
+
specifiers.push('cssMap');
|
|
152
|
+
}
|
|
149
153
|
return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(CSS_IMPORT_MODULE, "';"));
|
|
150
154
|
}
|
|
151
155
|
return ast.Root.upsertNamedImportDeclaration({
|
|
@@ -195,7 +199,7 @@ export function upsertCssMapVariable(context, fixer, paddingToken) {
|
|
|
195
199
|
var sourceCode = getSourceCode(context);
|
|
196
200
|
var body = sourceCode.ast.body;
|
|
197
201
|
var key = getCssMapKey(paddingToken);
|
|
198
|
-
var keyValuePair = " ".concat(key, ": {
|
|
202
|
+
var keyValuePair = " ".concat(key, ": { paddingBlock: token('").concat(paddingToken, "'), paddingInline: token('").concat(paddingToken, "') }");
|
|
199
203
|
|
|
200
204
|
// Check if iconSpacingStyles cssMap variable already exists
|
|
201
205
|
var existingVar = body.find(function (node) {
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { createIsFromImportSourceFor } from '../no-custom-icons/checks/is-from-import-source';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
3
|
import { errorBoundary } from '../utils/error-boundary';
|
|
4
|
-
import { CSSMAP_VARIABLE_NAME, getCssMapKey, getIconSize, getSpacingAttribute, getStaticAttributeValue, hasSpreadProps, SPACING_TO_PADDING,
|
|
4
|
+
import { CSSMAP_VARIABLE_NAME, getCssMapKey, getIconSize, getSpacingAttribute, getStaticAttributeValue, hasSpreadProps, SPACING_TO_PADDING, upsertCssMapImport, upsertCssMapVariable, upsertFlexImport, upsertTokenImport } from './helpers';
|
|
5
5
|
var rule = createLintRule({
|
|
6
6
|
meta: {
|
|
7
7
|
name: 'no-icon-spacing-prop',
|
|
8
8
|
hasSuggestions: true,
|
|
9
9
|
type: 'suggestion',
|
|
10
10
|
docs: {
|
|
11
|
-
description: 'Disallows usage of the deprecated spacing prop on new icons. Use
|
|
11
|
+
description: 'Disallows usage of the deprecated spacing prop on new icons. Use Flex with cssMap for spacing instead.',
|
|
12
12
|
recommended: true,
|
|
13
13
|
severity: 'warn'
|
|
14
14
|
},
|
|
15
15
|
messages: {
|
|
16
|
-
noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<
|
|
17
|
-
noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<
|
|
16
|
+
noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<Flex xcss={iconSpacingStyles.spaceXXX}>` using `cssMap` from `@atlaskit/css` instead.",
|
|
17
|
+
noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<Flex xcss={...}>` using `cssMap` from `@atlaskit/css`.",
|
|
18
18
|
suggestRemoveSpacing: 'Remove the `spacing` prop.',
|
|
19
|
-
|
|
19
|
+
suggestWrapInFlex: 'Wrap in `<Flex xcss={{{cssMapVarName}}.{{cssMapKey}}}>` and remove the `spacing` prop.'
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
create: function create(context) {
|
|
23
|
-
var isNewIcon = createIsFromImportSourceFor(/^@(atlaskit\/icon|atlaskit\/icon-lab
|
|
23
|
+
var isNewIcon = createIsFromImportSourceFor(/^@(atlaskit\/icon|atlaskit\/icon-lab)\/core\//);
|
|
24
24
|
return errorBoundary({
|
|
25
25
|
JSXElement: function JSXElement(node) {
|
|
26
26
|
var _SPACING_TO_PADDING$s;
|
|
@@ -83,7 +83,7 @@ var rule = createLintRule({
|
|
|
83
83
|
iconName: iconName
|
|
84
84
|
},
|
|
85
85
|
suggest: [{
|
|
86
|
-
messageId: '
|
|
86
|
+
messageId: 'suggestWrapInFlex',
|
|
87
87
|
data: {
|
|
88
88
|
cssMapVarName: CSSMAP_VARIABLE_NAME,
|
|
89
89
|
cssMapKey: cssMapKey
|
|
@@ -94,9 +94,9 @@ var rule = createLintRule({
|
|
|
94
94
|
// 1. Remove spacing prop
|
|
95
95
|
fixes.push(fixer.remove(spacingAttr));
|
|
96
96
|
|
|
97
|
-
// 2. Wrap in
|
|
98
|
-
fixes.push(fixer.insertTextBefore(node, "<
|
|
99
|
-
fixes.push(fixer.insertTextAfter(node, "</
|
|
97
|
+
// 2. Wrap in Flex with cssMap reference
|
|
98
|
+
fixes.push(fixer.insertTextBefore(node, "<Flex xcss={".concat(CSSMAP_VARIABLE_NAME, ".").concat(cssMapKey, "}>")));
|
|
99
|
+
fixes.push(fixer.insertTextAfter(node, "</Flex>"));
|
|
100
100
|
|
|
101
101
|
// 3. Insert/update cssMap variable after last import
|
|
102
102
|
var cssMapFix = upsertCssMapVariable(context, fixer, paddingToken);
|
|
@@ -110,10 +110,10 @@ var rule = createLintRule({
|
|
|
110
110
|
fixes.push(cssFix);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
// 5. Add
|
|
114
|
-
var
|
|
115
|
-
if (
|
|
116
|
-
fixes.push(
|
|
113
|
+
// 5. Add Flex to @atlaskit/primitives/compiled
|
|
114
|
+
var flexFix = upsertFlexImport(context, fixer);
|
|
115
|
+
if (flexFix) {
|
|
116
|
+
fixes.push(flexFix);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
// 6. Add token from @atlaskit/tokens
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { type Domains } from './types';
|
|
2
2
|
declare const ruleMeta: {
|
|
3
|
-
readonly name:
|
|
3
|
+
readonly name: 'ensure-design-token-usage';
|
|
4
4
|
readonly hasSuggestions: true;
|
|
5
5
|
readonly schema: {
|
|
6
|
-
readonly type:
|
|
6
|
+
readonly type: 'array';
|
|
7
7
|
readonly items: {
|
|
8
|
-
readonly type:
|
|
8
|
+
readonly type: 'object';
|
|
9
9
|
readonly properties: {
|
|
10
10
|
readonly applyImport: {
|
|
11
|
-
readonly type:
|
|
11
|
+
readonly type: 'boolean';
|
|
12
12
|
};
|
|
13
13
|
readonly shouldEnforceFallbacks: {
|
|
14
|
-
readonly type:
|
|
14
|
+
readonly type: 'boolean';
|
|
15
15
|
};
|
|
16
16
|
readonly domains: {
|
|
17
|
-
readonly type:
|
|
17
|
+
readonly type: 'array';
|
|
18
18
|
readonly items: {
|
|
19
19
|
readonly enum: Domains;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
readonly exceptions: {
|
|
23
|
-
readonly type:
|
|
23
|
+
readonly type: 'array';
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
readonly type:
|
|
29
|
-
readonly fixable:
|
|
28
|
+
readonly type: 'problem';
|
|
29
|
+
readonly fixable: 'code';
|
|
30
30
|
readonly docs: {
|
|
31
|
-
readonly description:
|
|
31
|
+
readonly description: 'Enforces usage of design tokens rather than hard-coded values.';
|
|
32
32
|
readonly recommended: true;
|
|
33
|
-
readonly severity:
|
|
33
|
+
readonly severity: 'error';
|
|
34
34
|
};
|
|
35
35
|
readonly messages: {
|
|
36
|
-
readonly noRawRadiusValues:
|
|
37
|
-
readonly noRawSpacingValues:
|
|
38
|
-
readonly autofixesPossible:
|
|
39
|
-
readonly noCalcUsage:
|
|
40
|
-
readonly hardCodedColor:
|
|
41
|
-
readonly legacyElevation:
|
|
36
|
+
readonly noRawRadiusValues: 'The use of shape tokens is preferred over the direct application of border properties.\n\n@meta <<{{payload}}>>';
|
|
37
|
+
readonly noRawSpacingValues: 'The use of spacing primitives or tokens is preferred over the direct application of spacing properties.\n\n@meta <<{{payload}}>>';
|
|
38
|
+
readonly autofixesPossible: 'Automated corrections available for spacing values. Apply autofix to replace values with appropriate tokens';
|
|
39
|
+
readonly noCalcUsage: 'The use of space tokens is preferred over using the CSS calc function. If using a value that is not aligned to the spacing scale, consider aligning to the scale and using tokens instead.';
|
|
40
|
+
readonly hardCodedColor: 'Colors can be sourced from the global theme using the token function.';
|
|
41
|
+
readonly legacyElevation: 'Elevations can be sourced from the global theme using the token function made of both a background and shadow. Use "card" for card elevations, and "overlay" for anything else that should appear elevated.';
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
export default ruleMeta;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
import { type EslintNode, type ObjectExpression, type Property, type SpreadElement, type TaggedTemplateExpression } from 'eslint-codemod-utils';
|
|
2
|
+
import { type EslintNode, type ObjectExpression, type Property, SimpleCallExpression, type SpreadElement, StringableASTNode, type TaggedTemplateExpression } from 'eslint-codemod-utils';
|
|
3
3
|
import { type Domains } from './types';
|
|
4
4
|
export type ProcessedCSSLines = [string, string][];
|
|
5
5
|
export declare function insertTokensImport(fixer: Rule.RuleFixer): Rule.Fix;
|
|
@@ -86,7 +86,7 @@ export declare function processCssNode(node: TaggedTemplateExpression & Rule.Nod
|
|
|
86
86
|
* propertyName: fontWeight, value: 400 => token('font.weight.regular', '400')
|
|
87
87
|
* ```
|
|
88
88
|
*/
|
|
89
|
-
export declare function getTokenNodeForValue(propertyName: string, value: string):
|
|
89
|
+
export declare function getTokenNodeForValue(propertyName: string, value: string): StringableASTNode<SimpleCallExpression>;
|
|
90
90
|
export declare function getFontSizeValueInScope(cssProperties: ProcessedCSSLines): number | undefined;
|
|
91
91
|
/**
|
|
92
92
|
* Attempts to remove all non-essential words & characters from a style block.
|
|
@@ -117,6 +117,6 @@ export declare function findTokenNameByPropertyValue(propertyName: string, value
|
|
|
117
117
|
* @param propertyName string camelCased css property.
|
|
118
118
|
* @param value The computed value e.g '8px' -> '8'.
|
|
119
119
|
*/
|
|
120
|
-
export declare function getTokenReplacement(propertyName: string, value: string):
|
|
120
|
+
export declare function getTokenReplacement(propertyName: string, value: string): StringableASTNode<SimpleCallExpression> | undefined;
|
|
121
121
|
export declare function getPropertyNodeFromParent(property: string, parentNode: ObjectExpression & Rule.NodeParentExtension): Property | SpreadElement | undefined;
|
|
122
122
|
export declare function getValueForPropertyNode(propertyNode: Property | SpreadElement, context: Rule.RuleContext): string | number | null | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type JSXAttribute, type JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const FLEX_IMPORT_MODULE = "@atlaskit/primitives/compiled";
|
|
4
|
+
export declare const FLEX_IMPORT_MODULE_NON_COMPILED = "@atlaskit/primitives";
|
|
5
5
|
export declare const TOKEN_IMPORT_MODULE = "@atlaskit/tokens";
|
|
6
6
|
export declare const CSS_IMPORT_MODULE = "@atlaskit/css";
|
|
7
7
|
export declare const CSSMAP_VARIABLE_NAME = "iconSpacingStyles";
|
|
@@ -32,12 +32,12 @@ export declare function getIconSize(node: JSXElement): string | undefined;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function hasSpreadProps(node: JSXElement): boolean;
|
|
34
34
|
/**
|
|
35
|
-
* Upserts `
|
|
36
|
-
* 1. Already imported from `/compiled` → add
|
|
37
|
-
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add
|
|
38
|
-
* 3. No import → insert new `import {
|
|
35
|
+
* Upserts `Flex` from `@atlaskit/primitives/compiled`, handling:
|
|
36
|
+
* 1. Already imported from `/compiled` → add Flex if missing
|
|
37
|
+
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add Flex
|
|
38
|
+
* 3. No import → insert new `import { Flex } from '@atlaskit/primitives/compiled'`
|
|
39
39
|
*/
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function upsertFlexImport(context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
41
41
|
/**
|
|
42
42
|
* Upserts `cssMap` from `@atlaskit/css`, handling:
|
|
43
43
|
* 1. Already imported → no-op
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
export declare const RULE_NAME = "use-should-render-to-parent";
|
|
3
|
-
export declare const addProp
|
|
4
|
-
export declare const setPropToTrue
|
|
3
|
+
export declare const addProp: 'Add `shouldRenderToParent` prop.';
|
|
4
|
+
export declare const setPropToTrue: 'Set `shouldRenderToParent` prop to `true`.';
|
|
5
5
|
declare const rule: Rule.RuleModule;
|
|
6
6
|
export default rule;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const IMPORT_NAME = "AKVisuallyHidden";
|
|
2
2
|
export declare const VISUALLY_HIDDEN_SOURCE = "@atlaskit/visually-hidden";
|
|
3
|
-
export declare const VISUALLY_HIDDEN_IMPORT
|
|
3
|
+
export declare const VISUALLY_HIDDEN_IMPORT: "import AKVisuallyHidden from '@atlaskit/visually-hidden';\n";
|
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
import { type Domains } from './types';
|
|
2
2
|
declare const ruleMeta: {
|
|
3
|
-
readonly name:
|
|
3
|
+
readonly name: 'ensure-design-token-usage';
|
|
4
4
|
readonly hasSuggestions: true;
|
|
5
5
|
readonly schema: {
|
|
6
|
-
readonly type:
|
|
6
|
+
readonly type: 'array';
|
|
7
7
|
readonly items: {
|
|
8
|
-
readonly type:
|
|
8
|
+
readonly type: 'object';
|
|
9
9
|
readonly properties: {
|
|
10
10
|
readonly applyImport: {
|
|
11
|
-
readonly type:
|
|
11
|
+
readonly type: 'boolean';
|
|
12
12
|
};
|
|
13
13
|
readonly shouldEnforceFallbacks: {
|
|
14
|
-
readonly type:
|
|
14
|
+
readonly type: 'boolean';
|
|
15
15
|
};
|
|
16
16
|
readonly domains: {
|
|
17
|
-
readonly type:
|
|
17
|
+
readonly type: 'array';
|
|
18
18
|
readonly items: {
|
|
19
19
|
readonly enum: Domains;
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
22
|
readonly exceptions: {
|
|
23
|
-
readonly type:
|
|
23
|
+
readonly type: 'array';
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
-
readonly type:
|
|
29
|
-
readonly fixable:
|
|
28
|
+
readonly type: 'problem';
|
|
29
|
+
readonly fixable: 'code';
|
|
30
30
|
readonly docs: {
|
|
31
|
-
readonly description:
|
|
31
|
+
readonly description: 'Enforces usage of design tokens rather than hard-coded values.';
|
|
32
32
|
readonly recommended: true;
|
|
33
|
-
readonly severity:
|
|
33
|
+
readonly severity: 'error';
|
|
34
34
|
};
|
|
35
35
|
readonly messages: {
|
|
36
|
-
readonly noRawRadiusValues:
|
|
37
|
-
readonly noRawSpacingValues:
|
|
38
|
-
readonly autofixesPossible:
|
|
39
|
-
readonly noCalcUsage:
|
|
40
|
-
readonly hardCodedColor:
|
|
41
|
-
readonly legacyElevation:
|
|
36
|
+
readonly noRawRadiusValues: 'The use of shape tokens is preferred over the direct application of border properties.\n\n@meta <<{{payload}}>>';
|
|
37
|
+
readonly noRawSpacingValues: 'The use of spacing primitives or tokens is preferred over the direct application of spacing properties.\n\n@meta <<{{payload}}>>';
|
|
38
|
+
readonly autofixesPossible: 'Automated corrections available for spacing values. Apply autofix to replace values with appropriate tokens';
|
|
39
|
+
readonly noCalcUsage: 'The use of space tokens is preferred over using the CSS calc function. If using a value that is not aligned to the spacing scale, consider aligning to the scale and using tokens instead.';
|
|
40
|
+
readonly hardCodedColor: 'Colors can be sourced from the global theme using the token function.';
|
|
41
|
+
readonly legacyElevation: 'Elevations can be sourced from the global theme using the token function made of both a background and shadow. Use "card" for card elevations, and "overlay" for anything else that should appear elevated.';
|
|
42
42
|
};
|
|
43
43
|
};
|
|
44
44
|
export default ruleMeta;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
|
-
import { type EslintNode, type ObjectExpression, type Property, type SpreadElement, type TaggedTemplateExpression } from 'eslint-codemod-utils';
|
|
2
|
+
import { type EslintNode, type ObjectExpression, type Property, SimpleCallExpression, type SpreadElement, StringableASTNode, type TaggedTemplateExpression } from 'eslint-codemod-utils';
|
|
3
3
|
import { type Domains } from './types';
|
|
4
4
|
export type ProcessedCSSLines = [
|
|
5
5
|
string,
|
|
@@ -89,7 +89,7 @@ export declare function processCssNode(node: TaggedTemplateExpression & Rule.Nod
|
|
|
89
89
|
* propertyName: fontWeight, value: 400 => token('font.weight.regular', '400')
|
|
90
90
|
* ```
|
|
91
91
|
*/
|
|
92
|
-
export declare function getTokenNodeForValue(propertyName: string, value: string):
|
|
92
|
+
export declare function getTokenNodeForValue(propertyName: string, value: string): StringableASTNode<SimpleCallExpression>;
|
|
93
93
|
export declare function getFontSizeValueInScope(cssProperties: ProcessedCSSLines): number | undefined;
|
|
94
94
|
/**
|
|
95
95
|
* Attempts to remove all non-essential words & characters from a style block.
|
|
@@ -120,6 +120,6 @@ export declare function findTokenNameByPropertyValue(propertyName: string, value
|
|
|
120
120
|
* @param propertyName string camelCased css property.
|
|
121
121
|
* @param value The computed value e.g '8px' -> '8'.
|
|
122
122
|
*/
|
|
123
|
-
export declare function getTokenReplacement(propertyName: string, value: string):
|
|
123
|
+
export declare function getTokenReplacement(propertyName: string, value: string): StringableASTNode<SimpleCallExpression> | undefined;
|
|
124
124
|
export declare function getPropertyNodeFromParent(property: string, parentNode: ObjectExpression & Rule.NodeParentExtension): Property | SpreadElement | undefined;
|
|
125
125
|
export declare function getValueForPropertyNode(propertyNode: Property | SpreadElement, context: Rule.RuleContext): string | number | null | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { type JSXAttribute, type JSXElement } from 'eslint-codemod-utils';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
3
|
+
export declare const FLEX_IMPORT_MODULE = "@atlaskit/primitives/compiled";
|
|
4
|
+
export declare const FLEX_IMPORT_MODULE_NON_COMPILED = "@atlaskit/primitives";
|
|
5
5
|
export declare const TOKEN_IMPORT_MODULE = "@atlaskit/tokens";
|
|
6
6
|
export declare const CSS_IMPORT_MODULE = "@atlaskit/css";
|
|
7
7
|
export declare const CSSMAP_VARIABLE_NAME = "iconSpacingStyles";
|
|
@@ -32,12 +32,12 @@ export declare function getIconSize(node: JSXElement): string | undefined;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function hasSpreadProps(node: JSXElement): boolean;
|
|
34
34
|
/**
|
|
35
|
-
* Upserts `
|
|
36
|
-
* 1. Already imported from `/compiled` → add
|
|
37
|
-
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add
|
|
38
|
-
* 3. No import → insert new `import {
|
|
35
|
+
* Upserts `Flex` from `@atlaskit/primitives/compiled`, handling:
|
|
36
|
+
* 1. Already imported from `/compiled` → add Flex if missing
|
|
37
|
+
* 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add Flex
|
|
38
|
+
* 3. No import → insert new `import { Flex } from '@atlaskit/primitives/compiled'`
|
|
39
39
|
*/
|
|
40
|
-
export declare function
|
|
40
|
+
export declare function upsertFlexImport(context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix | undefined;
|
|
41
41
|
/**
|
|
42
42
|
* Upserts `cssMap` from `@atlaskit/css`, handling:
|
|
43
43
|
* 1. Already imported → no-op
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
export declare const RULE_NAME = "use-should-render-to-parent";
|
|
3
|
-
export declare const addProp
|
|
4
|
-
export declare const setPropToTrue
|
|
3
|
+
export declare const addProp: 'Add `shouldRenderToParent` prop.';
|
|
4
|
+
export declare const setPropToTrue: 'Set `shouldRenderToParent` prop to `true`.';
|
|
5
5
|
declare const rule: Rule.RuleModule;
|
|
6
6
|
export default rule;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const IMPORT_NAME = "AKVisuallyHidden";
|
|
2
2
|
export declare const VISUALLY_HIDDEN_SOURCE = "@atlaskit/visually-hidden";
|
|
3
|
-
export declare const VISUALLY_HIDDEN_IMPORT
|
|
3
|
+
export declare const VISUALLY_HIDDEN_IMPORT: "import AKVisuallyHidden from '@atlaskit/visually-hidden';\n";
|
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": "13.41.
|
|
4
|
+
"version": "13.41.3",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@atlaskit/eslint-utils": "^2.0.0",
|
|
42
|
-
"@atlaskit/icon": "^
|
|
43
|
-
"@atlaskit/icon-lab": "^
|
|
42
|
+
"@atlaskit/icon": "^33.0.0",
|
|
43
|
+
"@atlaskit/icon-lab": "^6.0.0",
|
|
44
44
|
"@atlaskit/tokens": "^11.1.0",
|
|
45
45
|
"@babel/runtime": "^7.0.0",
|
|
46
46
|
"@typescript-eslint/utils": "^7.1.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@af/formatting": "workspace:^",
|
|
58
|
-
"@atlaskit/ds-lib": "^
|
|
58
|
+
"@atlaskit/ds-lib": "^6.0.0",
|
|
59
59
|
"@atlaskit/theme": "^22.0.0",
|
|
60
60
|
"@atlassian/codegen": "^0.1.0",
|
|
61
61
|
"@atlassian/eslint-utils": "^0.5.0",
|