@atlaskit/eslint-plugin-design-system 8.37.2 → 8.38.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 +12 -0
- package/README.md +1 -0
- package/constellation/index/usage.mdx +1 -0
- package/constellation/use-tokens-space/usage.mdx +30 -0
- package/dist/cjs/ast-nodes/object-entry.js +35 -0
- package/dist/cjs/ast-nodes/object.js +12 -0
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/use-primitives/utils/validate-styles.js +11 -2
- package/dist/cjs/rules/use-tokens-space/index.js +54 -0
- package/dist/cjs/rules/use-tokens-space/transformers/index.js +12 -0
- package/dist/cjs/rules/use-tokens-space/transformers/style-property/index.js +130 -0
- package/dist/cjs/rules/use-tokens-space/transformers/style-property/style-map.js +80 -0
- package/dist/cjs/rules/use-tokens-space/transformers/style-property/supported.js +14 -0
- package/dist/cjs/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js +37 -0
- package/dist/cjs/rules/use-tokens-space/utils/index.js +12 -0
- package/dist/cjs/rules/use-tokens-space/utils/is-string-or-number.js +9 -0
- package/dist/es2019/ast-nodes/object-entry.js +37 -3
- package/dist/es2019/ast-nodes/object.js +12 -0
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/use-primitives/utils/validate-styles.js +11 -2
- package/dist/es2019/rules/use-tokens-space/index.js +38 -0
- package/dist/es2019/rules/use-tokens-space/transformers/index.js +1 -0
- package/dist/es2019/rules/use-tokens-space/transformers/style-property/index.js +121 -0
- package/dist/es2019/rules/use-tokens-space/transformers/style-property/style-map.js +152 -0
- package/dist/es2019/rules/use-tokens-space/transformers/style-property/supported.js +8 -0
- package/dist/es2019/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js +30 -0
- package/dist/es2019/rules/use-tokens-space/utils/index.js +1 -0
- package/dist/es2019/rules/use-tokens-space/utils/is-string-or-number.js +3 -0
- package/dist/esm/ast-nodes/object-entry.js +37 -3
- package/dist/esm/ast-nodes/object.js +12 -0
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/use-primitives/utils/validate-styles.js +11 -2
- package/dist/esm/rules/use-tokens-space/index.js +48 -0
- package/dist/esm/rules/use-tokens-space/transformers/index.js +1 -0
- package/dist/esm/rules/use-tokens-space/transformers/style-property/index.js +120 -0
- package/dist/esm/rules/use-tokens-space/transformers/style-property/style-map.js +73 -0
- package/dist/esm/rules/use-tokens-space/transformers/style-property/supported.js +8 -0
- package/dist/esm/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js +29 -0
- package/dist/esm/rules/use-tokens-space/utils/index.js +1 -0
- package/dist/esm/rules/use-tokens-space/utils/is-string-or-number.js +3 -0
- package/dist/types/ast-nodes/object-entry.d.ts +12 -2
- package/dist/types/ast-nodes/object.d.ts +1 -0
- package/dist/types/index.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +5 -4
- package/dist/types/rules/use-tokens-space/index.d.ts +3 -0
- package/dist/types/rules/use-tokens-space/transformers/index.d.ts +1 -0
- package/dist/types/rules/use-tokens-space/transformers/style-property/index.d.ts +26 -0
- package/dist/types/rules/use-tokens-space/transformers/style-property/style-map.d.ts +7 -0
- package/dist/types/rules/use-tokens-space/transformers/style-property/supported.d.ts +6 -0
- package/dist/types/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.d.ts +14 -0
- package/dist/types/rules/use-tokens-space/utils/index.d.ts +1 -0
- package/dist/types/rules/use-tokens-space/utils/is-string-or-number.d.ts +1 -0
- package/dist/types/rules/use-visually-hidden/constants.d.ts +1 -1
- package/dist/types/rules/utils/create-rule.d.ts +1 -1
- package/dist/types-ts4.5/ast-nodes/object-entry.d.ts +12 -2
- package/dist/types-ts4.5/ast-nodes/object.d.ts +1 -0
- 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/index.codegen.d.ts +5 -4
- package/dist/types-ts4.5/rules/use-tokens-space/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-tokens-space/transformers/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-tokens-space/transformers/style-property/index.d.ts +26 -0
- package/dist/types-ts4.5/rules/use-tokens-space/transformers/style-property/style-map.d.ts +7 -0
- package/dist/types-ts4.5/rules/use-tokens-space/transformers/style-property/supported.d.ts +6 -0
- package/dist/types-ts4.5/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.d.ts +14 -0
- package/dist/types-ts4.5/rules/use-tokens-space/utils/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-tokens-space/utils/is-string-or-number.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-visually-hidden/constants.d.ts +1 -1
- package/dist/types-ts4.5/rules/utils/create-rule.d.ts +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* eslint-disable @repo/internal/react/require-jsdoc */
|
|
2
|
+
|
|
3
|
+
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
|
+
import * as ast from '../../../../ast-nodes';
|
|
5
|
+
import { isStringOrNumber } from '../../utils';
|
|
6
|
+
import { styleMap } from './style-map';
|
|
7
|
+
import supported from './supported';
|
|
8
|
+
import { upsertImportDeclaration } from './upsert-import-declaration';
|
|
9
|
+
var messageId = 'noRawSpacingValues';
|
|
10
|
+
export var StyleProperty = {
|
|
11
|
+
lint: function lint(node, _ref) {
|
|
12
|
+
var context = _ref.context;
|
|
13
|
+
// Check whether all criteria needed to make a transformation are met
|
|
14
|
+
var _StyleProperty$_check = StyleProperty._check(node),
|
|
15
|
+
success = _StyleProperty$_check.success,
|
|
16
|
+
ref = _StyleProperty$_check.ref;
|
|
17
|
+
if (!success) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
context.report({
|
|
21
|
+
node: ref.node.value,
|
|
22
|
+
messageId: messageId,
|
|
23
|
+
fix: ref.token ? StyleProperty._fix(ref, context) : undefined
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
_check: function _check(node) {
|
|
27
|
+
if (!isNodeOfType(node, 'Property')) {
|
|
28
|
+
return {
|
|
29
|
+
success: false,
|
|
30
|
+
ref: undefined
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Currently, we support values like:
|
|
36
|
+
* ```
|
|
37
|
+
* {
|
|
38
|
+
* padding: '8px', // value.type is Literal
|
|
39
|
+
* margin: -8, // value.type is UnaryExpression
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
if (!(isNodeOfType(node.value, 'Literal') || isNodeOfType(node.value, 'UnaryExpression'))) {
|
|
44
|
+
return {
|
|
45
|
+
success: false,
|
|
46
|
+
ref: undefined
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var _ast$ObjectEntry$getP = ast.ObjectEntry.getProperty(node),
|
|
50
|
+
property = _ast$ObjectEntry$getP.value;
|
|
51
|
+
|
|
52
|
+
// Bail if the property is not `padding`, `margin`, etc
|
|
53
|
+
if (!property || !styleMap[property]) {
|
|
54
|
+
return {
|
|
55
|
+
success: false,
|
|
56
|
+
ref: undefined
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
var value = ast.ObjectEntry.getValue(node);
|
|
60
|
+
|
|
61
|
+
// This is mainly useful as a type guard, so the checks after don't have to have duplicate checks for other types.
|
|
62
|
+
if (!isStringOrNumber(value)) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
ref: undefined
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ignore CSS vars. See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/74844/overview?commentId=6741571
|
|
70
|
+
if (value.toString().startsWith('var(')) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
ref: undefined
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// There are valid values to ignore, such as `margin: auto`
|
|
78
|
+
if (supported.values.ignore.includes(value)) {
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
ref: undefined
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Don't report on stuff like `padding: '8px 16px'`.
|
|
86
|
+
// We may iterate to handle values like this in future.
|
|
87
|
+
if (value.toString().includes(' ')) {
|
|
88
|
+
return {
|
|
89
|
+
success: false,
|
|
90
|
+
ref: undefined
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
var ref = {
|
|
94
|
+
node: node,
|
|
95
|
+
token: styleMap[property][value],
|
|
96
|
+
fallback: value
|
|
97
|
+
};
|
|
98
|
+
return {
|
|
99
|
+
success: true,
|
|
100
|
+
ref: ref
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* All required validation steps have been taken care of before this
|
|
105
|
+
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
106
|
+
*/
|
|
107
|
+
_fix: function _fix(ref, context) {
|
|
108
|
+
return function (fixer) {
|
|
109
|
+
var importFix = upsertImportDeclaration({
|
|
110
|
+
module: '@atlaskit/tokens',
|
|
111
|
+
specifiers: ['token']
|
|
112
|
+
}, context, fixer);
|
|
113
|
+
var tokenCall = ref.fallback ? "token('".concat(ref.token, "', '").concat(ref.fallback, "')") : "token('".concat(ref.token, "')");
|
|
114
|
+
var tokenFix = fixer.replaceText(ref.node.value, tokenCall);
|
|
115
|
+
return [importFix, tokenFix].filter(function (fix) {
|
|
116
|
+
return Boolean(fix);
|
|
117
|
+
}); // Some of the transformers can return arrays with undefined, so filter them out
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
var _tokenMap;
|
|
3
|
+
// TODO: https://product-fabric.atlassian.net/browse/DSP-16054
|
|
4
|
+
var tokenMap = (_tokenMap = {
|
|
5
|
+
'-2px': 'space.negative.025',
|
|
6
|
+
'-4px': 'space.negative.050',
|
|
7
|
+
'-6px': 'space.negative.075',
|
|
8
|
+
'-8px': 'space.negative.100',
|
|
9
|
+
'-12px': 'space.negative.150',
|
|
10
|
+
'-16px': 'space.negative.200',
|
|
11
|
+
'-20px': 'space.negative.250',
|
|
12
|
+
'-24px': 'space.negative.300',
|
|
13
|
+
'-32px': 'space.negative.400'
|
|
14
|
+
}, _defineProperty(_tokenMap, -2, 'space.negative.025'), _defineProperty(_tokenMap, -4, 'space.negative.050'), _defineProperty(_tokenMap, -6, 'space.negative.075'), _defineProperty(_tokenMap, -8, 'space.negative.100'), _defineProperty(_tokenMap, -12, 'space.negative.150'), _defineProperty(_tokenMap, -16, 'space.negative.200'), _defineProperty(_tokenMap, -20, 'space.negative.250'), _defineProperty(_tokenMap, -24, 'space.negative.300'), _defineProperty(_tokenMap, -32, 'space.negative.400'), _defineProperty(_tokenMap, '2px', 'space.025'), _defineProperty(_tokenMap, '4px', 'space.050'), _defineProperty(_tokenMap, '6px', 'space.075'), _defineProperty(_tokenMap, '8px', 'space.100'), _defineProperty(_tokenMap, '12px', 'space.150'), _defineProperty(_tokenMap, '16px', 'space.200'), _defineProperty(_tokenMap, '20px', 'space.250'), _defineProperty(_tokenMap, '24px', 'space.300'), _defineProperty(_tokenMap, '32px', 'space.400'), _defineProperty(_tokenMap, '40px', 'space.500'), _defineProperty(_tokenMap, '48px', 'space.600'), _defineProperty(_tokenMap, '64px', 'space.800'), _defineProperty(_tokenMap, '80px', 'space.1000'), _defineProperty(_tokenMap, 2, 'space.025'), _defineProperty(_tokenMap, 4, 'space.050'), _defineProperty(_tokenMap, 6, 'space.075'), _defineProperty(_tokenMap, 8, 'space.100'), _defineProperty(_tokenMap, 12, 'space.150'), _defineProperty(_tokenMap, 16, 'space.200'), _defineProperty(_tokenMap, 20, 'space.250'), _defineProperty(_tokenMap, 24, 'space.300'), _defineProperty(_tokenMap, 32, 'space.400'), _defineProperty(_tokenMap, 40, 'space.500'), _defineProperty(_tokenMap, 48, 'space.600'), _defineProperty(_tokenMap, 64, 'space.800'), _defineProperty(_tokenMap, 80, 'space.1000'), _defineProperty(_tokenMap, '-0.125rem', 'space.negative.025'), _defineProperty(_tokenMap, '-0.25rem', 'space.negative.050'), _defineProperty(_tokenMap, '-0.375rem', 'space.negative.075'), _defineProperty(_tokenMap, '-0.5rem', 'space.negative.100'), _defineProperty(_tokenMap, '-0.75rem', 'space.negative.150'), _defineProperty(_tokenMap, '-1rem', 'space.negative.200'), _defineProperty(_tokenMap, '-1.25rem', 'space.negative.250'), _defineProperty(_tokenMap, '-1.5rem', 'space.negative.300'), _defineProperty(_tokenMap, '-2rem', 'space.negative.400'), _defineProperty(_tokenMap, '0.125rem', 'space.025'), _defineProperty(_tokenMap, '0.25rem', 'space.050'), _defineProperty(_tokenMap, '0.375rem', 'space.075'), _defineProperty(_tokenMap, '0.5rem', 'space.100'), _defineProperty(_tokenMap, '0.75rem', 'space.150'), _defineProperty(_tokenMap, '1rem', 'space.200'), _defineProperty(_tokenMap, '1.25rem', 'space.250'), _defineProperty(_tokenMap, '1.5rem', 'space.300'), _defineProperty(_tokenMap, '2rem', 'space.400'), _defineProperty(_tokenMap, '2.5rem', 'space.500'), _defineProperty(_tokenMap, '3rem', 'space.600'), _defineProperty(_tokenMap, '4rem', 'space.800'), _defineProperty(_tokenMap, '5rem', 'space.1000'), _defineProperty(_tokenMap, '-0.125em', 'space.negative.025'), _defineProperty(_tokenMap, '-0.25em', 'space.negative.050'), _defineProperty(_tokenMap, '-0.375em', 'space.negative.075'), _defineProperty(_tokenMap, '-0.5em', 'space.negative.100'), _defineProperty(_tokenMap, '-0.75em', 'space.negative.150'), _defineProperty(_tokenMap, '-1em', 'space.negative.200'), _defineProperty(_tokenMap, '-1.25em', 'space.negative.250'), _defineProperty(_tokenMap, '-1.5em', 'space.negative.300'), _defineProperty(_tokenMap, '-2em', 'space.negative.400'), _defineProperty(_tokenMap, '0.125em', 'space.025'), _defineProperty(_tokenMap, '0.25em', 'space.050'), _defineProperty(_tokenMap, '0.375em', 'space.075'), _defineProperty(_tokenMap, '0.5em', 'space.100'), _defineProperty(_tokenMap, '0.75em', 'space.150'), _defineProperty(_tokenMap, '1em', 'space.200'), _defineProperty(_tokenMap, '1.25em', 'space.250'), _defineProperty(_tokenMap, '1.5em', 'space.300'), _defineProperty(_tokenMap, '2em', 'space.400'), _defineProperty(_tokenMap, '2.5em', 'space.500'), _defineProperty(_tokenMap, '3em', 'space.600'), _defineProperty(_tokenMap, '4em', 'space.800'), _defineProperty(_tokenMap, '5em', 'space.1000'), _tokenMap);
|
|
15
|
+
export var styleMap = {
|
|
16
|
+
'column-gap': tokenMap,
|
|
17
|
+
columnGap: tokenMap,
|
|
18
|
+
gap: tokenMap,
|
|
19
|
+
'grid-column-gap': tokenMap,
|
|
20
|
+
'grid-row-gap': tokenMap,
|
|
21
|
+
gridColumnGap: tokenMap,
|
|
22
|
+
gridRowGap: tokenMap,
|
|
23
|
+
'margin-block-end': tokenMap,
|
|
24
|
+
'margin-block-start': tokenMap,
|
|
25
|
+
'margin-block': tokenMap,
|
|
26
|
+
'margin-bottom': tokenMap,
|
|
27
|
+
'margin-inline-end': tokenMap,
|
|
28
|
+
'margin-inline-start': tokenMap,
|
|
29
|
+
'margin-inline': tokenMap,
|
|
30
|
+
'margin-left': tokenMap,
|
|
31
|
+
'margin-right': tokenMap,
|
|
32
|
+
'margin-top': tokenMap,
|
|
33
|
+
'outline-offset': tokenMap,
|
|
34
|
+
outlineOffset: tokenMap,
|
|
35
|
+
'padding-block-end': tokenMap,
|
|
36
|
+
'padding-block-start': tokenMap,
|
|
37
|
+
'padding-block': tokenMap,
|
|
38
|
+
'padding-bottom': tokenMap,
|
|
39
|
+
'padding-inline-end': tokenMap,
|
|
40
|
+
'padding-inline-start': tokenMap,
|
|
41
|
+
'padding-inline': tokenMap,
|
|
42
|
+
'padding-left': tokenMap,
|
|
43
|
+
'padding-right': tokenMap,
|
|
44
|
+
'padding-top': tokenMap,
|
|
45
|
+
'row-gap': tokenMap,
|
|
46
|
+
rowGap: tokenMap,
|
|
47
|
+
margin: tokenMap,
|
|
48
|
+
marginBlock: tokenMap,
|
|
49
|
+
marginBlockEnd: tokenMap,
|
|
50
|
+
marginBlockStart: tokenMap,
|
|
51
|
+
marginBottom: tokenMap,
|
|
52
|
+
marginInline: tokenMap,
|
|
53
|
+
marginInlineEnd: tokenMap,
|
|
54
|
+
marginInlineStart: tokenMap,
|
|
55
|
+
marginLeft: tokenMap,
|
|
56
|
+
marginRight: tokenMap,
|
|
57
|
+
marginTop: tokenMap,
|
|
58
|
+
padding: tokenMap,
|
|
59
|
+
paddingBlock: tokenMap,
|
|
60
|
+
paddingBlockEnd: tokenMap,
|
|
61
|
+
paddingBlockStart: tokenMap,
|
|
62
|
+
paddingBottom: tokenMap,
|
|
63
|
+
paddingInline: tokenMap,
|
|
64
|
+
paddingInlineEnd: tokenMap,
|
|
65
|
+
paddingInlineStart: tokenMap,
|
|
66
|
+
paddingLeft: tokenMap,
|
|
67
|
+
paddingRight: tokenMap,
|
|
68
|
+
paddingTop: tokenMap
|
|
69
|
+
// bottom: tokenMap,
|
|
70
|
+
// left: tokenMap,
|
|
71
|
+
// right: tokenMap,
|
|
72
|
+
// top: tokenMap,
|
|
73
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
values: {
|
|
3
|
+
ignore: ['auto', 'initial', 'inherit', 'unset', 'revert', 'revert-layer', 'none',
|
|
4
|
+
// outline-offset can be set to none
|
|
5
|
+
// Currently the DST opinion is that 0 is valid. It doesn't need to be converted to `space.0`
|
|
6
|
+
0, '0', '0px', '0em', '0rem']
|
|
7
|
+
}
|
|
8
|
+
};
|
package/dist/esm/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as ast from '../../../../ast-nodes';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Currently this is defined here because it's not very general purpose.
|
|
5
|
+
* If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
|
|
6
|
+
* and the other half would be in `Import`.
|
|
7
|
+
*
|
|
8
|
+
* TODO: Refactor and move to `ast-nodes`
|
|
9
|
+
*
|
|
10
|
+
* Note: It does not handle default imports, namespace imports, or aliased imports.
|
|
11
|
+
*/
|
|
12
|
+
export var upsertImportDeclaration = function upsertImportDeclaration(_ref, context, fixer) {
|
|
13
|
+
var module = _ref.module,
|
|
14
|
+
specifiers = _ref.specifiers;
|
|
15
|
+
// Find any imports that match the packageName
|
|
16
|
+
var root = context.getSourceCode().ast.body;
|
|
17
|
+
var importDeclarations = ast.Root.findImportsByModule(root, module);
|
|
18
|
+
|
|
19
|
+
// The import doesn't exist yet, we can just insert a whole new one
|
|
20
|
+
if (importDeclarations.length === 0) {
|
|
21
|
+
return ast.Root.insertImport(root, {
|
|
22
|
+
module: module,
|
|
23
|
+
specifiers: specifiers
|
|
24
|
+
}, fixer);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// The import exists so, modify the existing one
|
|
28
|
+
return ast.Import.insertNamedSpecifiers(importDeclarations[0], specifiers, fixer);
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isStringOrNumber } from './is-string-or-number';
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { Property, SpreadElement } from 'eslint-codemod-utils';
|
|
3
|
-
declare const ObjectEntry: {
|
|
3
|
+
export declare const ObjectEntry: {
|
|
4
|
+
getProperty(node: Property): {
|
|
5
|
+
type: 'Identifier';
|
|
6
|
+
value: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'Literal';
|
|
9
|
+
value: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: undefined;
|
|
12
|
+
value: undefined;
|
|
13
|
+
};
|
|
14
|
+
getValue(node: Property): string | number | bigint | true | RegExp | undefined;
|
|
4
15
|
deleteEntry(node: Property | SpreadElement, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix;
|
|
5
16
|
getPropertyName(node: Property | SpreadElement): string | undefined;
|
|
6
17
|
};
|
|
7
|
-
export { ObjectEntry };
|
|
@@ -48,5 +48,6 @@ declare const ASTObjectExpression: {
|
|
|
48
48
|
* Will result in `{ padding: 'space.100', margin: 'space.200'}`.
|
|
49
49
|
*/
|
|
50
50
|
appendEntry(node: ObjectExpression, key: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
51
|
+
recurse(node: ObjectExpression, callback: Function): void;
|
|
51
52
|
};
|
|
52
53
|
export { ASTObjectExpression as Object };
|
|
@@ -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-space': string;
|
|
35
36
|
'@atlaskit/design-system/use-tokens-typography': string;
|
|
36
37
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
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::d95217b658f807294de3c81123068bf1>>
|
|
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-space': string;
|
|
38
39
|
'@atlaskit/design-system/use-tokens-typography': string;
|
|
39
40
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
40
41
|
};
|
|
@@ -5,13 +5,13 @@ declare const _default: {
|
|
|
5
5
|
'icon-label': import("eslint").Rule.RuleModule;
|
|
6
6
|
'no-banned-imports': import("eslint").Rule.RuleModule;
|
|
7
7
|
'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
8
|
-
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint
|
|
8
|
+
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
|
|
9
9
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
10
|
-
}], import("@typescript-eslint/utils/dist/ts-eslint
|
|
10
|
+
}], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
|
|
11
11
|
'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
|
|
12
|
-
'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint
|
|
12
|
+
'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
|
|
13
13
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
14
|
-
}], import("@typescript-eslint/utils/dist/ts-eslint
|
|
14
|
+
}], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
|
|
15
15
|
'no-empty-styled-expression': import("eslint").Rule.RuleModule;
|
|
16
16
|
'no-exported-css': import("eslint").Rule.RuleModule;
|
|
17
17
|
'no-exported-keyframes': import("eslint").Rule.RuleModule;
|
|
@@ -32,6 +32,7 @@ declare const _default: {
|
|
|
32
32
|
'use-href-in-link-item': import("eslint").Rule.RuleModule;
|
|
33
33
|
'use-primitives': import("eslint").Rule.RuleModule;
|
|
34
34
|
'use-primitives-text': import("eslint").Rule.RuleModule;
|
|
35
|
+
'use-tokens-space': import("eslint").Rule.RuleModule;
|
|
35
36
|
'use-tokens-typography': import("eslint").Rule.RuleModule;
|
|
36
37
|
'use-visually-hidden': import("eslint").Rule.RuleModule;
|
|
37
38
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StyleProperty } from './style-property';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { Property } from 'eslint-codemod-utils';
|
|
3
|
+
type Ref = {
|
|
4
|
+
node: Property;
|
|
5
|
+
token?: string;
|
|
6
|
+
fallback?: string | number;
|
|
7
|
+
};
|
|
8
|
+
type Check = {
|
|
9
|
+
success: false;
|
|
10
|
+
ref: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
success: true;
|
|
13
|
+
ref: Ref;
|
|
14
|
+
};
|
|
15
|
+
export declare const StyleProperty: {
|
|
16
|
+
lint(node: Rule.Node, { context }: {
|
|
17
|
+
context: Rule.RuleContext;
|
|
18
|
+
}): void;
|
|
19
|
+
_check(node: Rule.Node): Check;
|
|
20
|
+
/**
|
|
21
|
+
* All required validation steps have been taken care of before this
|
|
22
|
+
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
23
|
+
*/
|
|
24
|
+
_fix(ref: Ref, context: Rule.RuleContext): (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
25
|
+
};
|
|
26
|
+
export {};
|
package/dist/types/rules/use-tokens-space/transformers/style-property/upsert-import-declaration.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* Currently this is defined here because it's not very general purpose.
|
|
4
|
+
* If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
|
|
5
|
+
* and the other half would be in `Import`.
|
|
6
|
+
*
|
|
7
|
+
* TODO: Refactor and move to `ast-nodes`
|
|
8
|
+
*
|
|
9
|
+
* Note: It does not handle default imports, namespace imports, or aliased imports.
|
|
10
|
+
*/
|
|
11
|
+
export declare const upsertImportDeclaration: ({ module, specifiers, }: {
|
|
12
|
+
module: string;
|
|
13
|
+
specifiers: string[];
|
|
14
|
+
}, context: Rule.RuleContext, fixer: Rule.RuleFixer) => Rule.Fix | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isStringOrNumber } from './is-string-or-number';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isStringOrNumber: (value: string | number | bigint | true | RegExp | undefined) => value is string | number;
|
|
@@ -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";
|
|
@@ -9,7 +9,7 @@ import type { Rule } from 'eslint';
|
|
|
9
9
|
* @private
|
|
10
10
|
* @deprecated
|
|
11
11
|
*/
|
|
12
|
-
export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint
|
|
12
|
+
export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<TMessageIds, TOptions, TRuleListener>;
|
|
13
13
|
export interface LintRule extends Omit<Rule.RuleModule, 'meta'> {
|
|
14
14
|
/**
|
|
15
15
|
* Including this for backwards compat moving from the typescript-eslint util.
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import { Property, SpreadElement } from 'eslint-codemod-utils';
|
|
3
|
-
declare const ObjectEntry: {
|
|
3
|
+
export declare const ObjectEntry: {
|
|
4
|
+
getProperty(node: Property): {
|
|
5
|
+
type: 'Identifier';
|
|
6
|
+
value: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: 'Literal';
|
|
9
|
+
value: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: undefined;
|
|
12
|
+
value: undefined;
|
|
13
|
+
};
|
|
14
|
+
getValue(node: Property): string | number | bigint | true | RegExp | undefined;
|
|
4
15
|
deleteEntry(node: Property | SpreadElement, context: Rule.RuleContext, fixer: Rule.RuleFixer): Rule.Fix;
|
|
5
16
|
getPropertyName(node: Property | SpreadElement): string | undefined;
|
|
6
17
|
};
|
|
7
|
-
export { ObjectEntry };
|
|
@@ -48,5 +48,6 @@ declare const ASTObjectExpression: {
|
|
|
48
48
|
* Will result in `{ padding: 'space.100', margin: 'space.200'}`.
|
|
49
49
|
*/
|
|
50
50
|
appendEntry(node: ObjectExpression, key: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
|
|
51
|
+
recurse(node: ObjectExpression, callback: Function): void;
|
|
51
52
|
};
|
|
52
53
|
export { ASTObjectExpression as Object };
|
|
@@ -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-space': string;
|
|
35
36
|
'@atlaskit/design-system/use-tokens-typography': string;
|
|
36
37
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
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::d95217b658f807294de3c81123068bf1>>
|
|
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-space': string;
|
|
38
39
|
'@atlaskit/design-system/use-tokens-typography': string;
|
|
39
40
|
'@atlaskit/design-system/use-visually-hidden': string;
|
|
40
41
|
};
|
|
@@ -5,17 +5,17 @@ declare const _default: {
|
|
|
5
5
|
'icon-label': import("eslint").Rule.RuleModule;
|
|
6
6
|
'no-banned-imports': import("eslint").Rule.RuleModule;
|
|
7
7
|
'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
|
|
8
|
-
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint
|
|
8
|
+
'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
|
|
9
9
|
{
|
|
10
10
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
11
11
|
}
|
|
12
|
-
], import("@typescript-eslint/utils/dist/ts-eslint
|
|
12
|
+
], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
|
|
13
13
|
'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
|
|
14
|
-
'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint
|
|
14
|
+
'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
|
|
15
15
|
{
|
|
16
16
|
deprecatedConfig: import("./utils/types").DeprecatedConfig;
|
|
17
17
|
}
|
|
18
|
-
], import("@typescript-eslint/utils/dist/ts-eslint
|
|
18
|
+
], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
|
|
19
19
|
'no-empty-styled-expression': import("eslint").Rule.RuleModule;
|
|
20
20
|
'no-exported-css': import("eslint").Rule.RuleModule;
|
|
21
21
|
'no-exported-keyframes': import("eslint").Rule.RuleModule;
|
|
@@ -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-space': import("eslint").Rule.RuleModule;
|
|
39
40
|
'use-tokens-typography': import("eslint").Rule.RuleModule;
|
|
40
41
|
'use-visually-hidden': import("eslint").Rule.RuleModule;
|
|
41
42
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { StyleProperty } from './style-property';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import { Property } from 'eslint-codemod-utils';
|
|
3
|
+
type Ref = {
|
|
4
|
+
node: Property;
|
|
5
|
+
token?: string;
|
|
6
|
+
fallback?: string | number;
|
|
7
|
+
};
|
|
8
|
+
type Check = {
|
|
9
|
+
success: false;
|
|
10
|
+
ref: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
success: true;
|
|
13
|
+
ref: Ref;
|
|
14
|
+
};
|
|
15
|
+
export declare const StyleProperty: {
|
|
16
|
+
lint(node: Rule.Node, { context }: {
|
|
17
|
+
context: Rule.RuleContext;
|
|
18
|
+
}): void;
|
|
19
|
+
_check(node: Rule.Node): Check;
|
|
20
|
+
/**
|
|
21
|
+
* All required validation steps have been taken care of before this
|
|
22
|
+
* transformer is called, so it just goes ahead providing all necessary fixes
|
|
23
|
+
*/
|
|
24
|
+
_fix(ref: Ref, context: Rule.RuleContext): (fixer: Rule.RuleFixer) => Rule.Fix[];
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* Currently this is defined here because it's not very general purpose.
|
|
4
|
+
* If we were to move this to `ast-nodes`, half the implementation would be in `Root`,
|
|
5
|
+
* and the other half would be in `Import`.
|
|
6
|
+
*
|
|
7
|
+
* TODO: Refactor and move to `ast-nodes`
|
|
8
|
+
*
|
|
9
|
+
* Note: It does not handle default imports, namespace imports, or aliased imports.
|
|
10
|
+
*/
|
|
11
|
+
export declare const upsertImportDeclaration: ({ module, specifiers, }: {
|
|
12
|
+
module: string;
|
|
13
|
+
specifiers: string[];
|
|
14
|
+
}, context: Rule.RuleContext, fixer: Rule.RuleFixer) => Rule.Fix | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isStringOrNumber } from './is-string-or-number';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isStringOrNumber: (value: string | number | bigint | true | RegExp | undefined) => value is string | number;
|
|
@@ -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";
|
|
@@ -9,7 +9,7 @@ import type { Rule } from 'eslint';
|
|
|
9
9
|
* @private
|
|
10
10
|
* @deprecated
|
|
11
11
|
*/
|
|
12
|
-
export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint
|
|
12
|
+
export declare const createRule: <TOptions extends readonly unknown[], TMessageIds extends string, TRuleListener extends import("@typescript-eslint/utils/dist/ts-eslint").RuleListener = import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>({ name, meta, ...rule }: Readonly<ESLintUtils.RuleWithMetaAndName<TOptions, TMessageIds, TRuleListener>>) => import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<TMessageIds, TOptions, TRuleListener>;
|
|
13
13
|
export interface LintRule extends Omit<Rule.RuleModule, 'meta'> {
|
|
14
14
|
/**
|
|
15
15
|
* Including this for backwards compat moving from the typescript-eslint util.
|
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.38.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"ts-jest": "26.5.6",
|
|
65
65
|
"ts-node": "^10.9.1",
|
|
66
66
|
"tsconfig-paths": "^4.2.0",
|
|
67
|
-
"typescript": "~4.
|
|
67
|
+
"typescript": "~5.4.2"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"ak-postbuild": "cp -r configs dist",
|
|
@@ -87,4 +87,4 @@
|
|
|
87
87
|
},
|
|
88
88
|
"homepage": "https://atlassian.design/components/eslint-plugin-design-system",
|
|
89
89
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
90
|
-
}
|
|
90
|
+
}
|