@atlaskit/eslint-plugin-design-system 10.0.1 → 10.1.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 +8 -0
- package/dist/cjs/rules/no-unsafe-design-token-usage/index.js +16 -3
- package/dist/es2019/rules/no-unsafe-design-token-usage/index.js +14 -1
- package/dist/esm/rules/no-unsafe-design-token-usage/index.js +16 -3
- package/dist/types/rules/use-tokens-typography/utils.d.ts +19 -19
- package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +19 -19
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 10.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#98883](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/98883)
|
|
8
|
+
[`482fe4d89379`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/482fe4d89379) -
|
|
9
|
+
Automatically insert the default fallback value for a token when fallbacks are enforced
|
|
10
|
+
|
|
3
11
|
## 10.0.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ exports.default = void 0;
|
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
10
10
|
var _renameMapping = _interopRequireDefault(require("@atlaskit/tokens/rename-mapping"));
|
|
11
|
+
var _tokenDefaultValues = _interopRequireDefault(require("@atlaskit/tokens/token-default-values"));
|
|
11
12
|
var _tokenIds = require("@atlaskit/tokens/token-ids");
|
|
12
13
|
var _tokenNames = _interopRequireDefault(require("@atlaskit/tokens/token-names"));
|
|
13
14
|
var _createRule = require("../utils/create-rule");
|
|
@@ -92,18 +93,30 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
94
95
|
if (node.arguments.length < 2 && config.fallbackUsage === 'forced') {
|
|
96
|
+
var fix;
|
|
97
|
+
if (node.arguments[0].type === 'Literal') {
|
|
98
|
+
var value = node.arguments[0].value;
|
|
99
|
+
var tokenName = value;
|
|
100
|
+
var fallbackValue = _tokenDefaultValues.default[tokenName] || null;
|
|
101
|
+
if (fallbackValue) {
|
|
102
|
+
fix = function fix(fixer) {
|
|
103
|
+
return fixer.replaceText(node, "".concat((0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') ? node.callee.name : 'token', "('").concat(tokenName, "', '").concat(fallbackValue, "')"));
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
95
107
|
context.report({
|
|
96
108
|
messageId: 'tokenFallbackEnforced',
|
|
97
|
-
node: node
|
|
109
|
+
node: node,
|
|
110
|
+
fix: fix
|
|
98
111
|
});
|
|
99
112
|
} else if (node.arguments.length > 1 && config.fallbackUsage === 'none') {
|
|
100
113
|
if (node.arguments[0].type === 'Literal') {
|
|
101
|
-
var
|
|
114
|
+
var _value = node.arguments[0].value;
|
|
102
115
|
context.report({
|
|
103
116
|
messageId: 'tokenFallbackRestricted',
|
|
104
117
|
node: node.arguments[1],
|
|
105
118
|
fix: function fix(fixer) {
|
|
106
|
-
return fixer.replaceText(node, "".concat((0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') ? node.callee.name : 'token', "('").concat(
|
|
119
|
+
return fixer.replaceText(node, "".concat((0, _eslintCodemodUtils.isNodeOfType)(node.callee, 'Identifier') ? node.callee.name : 'token', "('").concat(_value, "')"));
|
|
107
120
|
}
|
|
108
121
|
});
|
|
109
122
|
} else {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
4
4
|
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
5
|
+
import tokenDefaultValues from '@atlaskit/tokens/token-default-values';
|
|
5
6
|
import { getTokenId } from '@atlaskit/tokens/token-ids';
|
|
6
7
|
import tokens from '@atlaskit/tokens/token-names';
|
|
7
8
|
import { createLintRule } from '../utils/create-rule';
|
|
@@ -104,9 +105,21 @@ token('color.background.blanket');
|
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
107
|
if (node.arguments.length < 2 && config.fallbackUsage === 'forced') {
|
|
108
|
+
let fix;
|
|
109
|
+
if (node.arguments[0].type === 'Literal') {
|
|
110
|
+
const {
|
|
111
|
+
value
|
|
112
|
+
} = node.arguments[0];
|
|
113
|
+
const tokenName = value;
|
|
114
|
+
const fallbackValue = tokenDefaultValues[tokenName] || null;
|
|
115
|
+
if (fallbackValue) {
|
|
116
|
+
fix = fixer => fixer.replaceText(node, `${isNodeOfType(node.callee, 'Identifier') ? node.callee.name : 'token'}('${tokenName}', '${fallbackValue}')`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
107
119
|
context.report({
|
|
108
120
|
messageId: 'tokenFallbackEnforced',
|
|
109
|
-
node
|
|
121
|
+
node,
|
|
122
|
+
fix
|
|
110
123
|
});
|
|
111
124
|
} else if (node.arguments.length > 1 && config.fallbackUsage === 'none') {
|
|
112
125
|
if (node.arguments[0].type === 'Literal') {
|
|
@@ -5,6 +5,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
5
5
|
|
|
6
6
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
7
7
|
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
8
|
+
import tokenDefaultValues from '@atlaskit/tokens/token-default-values';
|
|
8
9
|
import { getTokenId } from '@atlaskit/tokens/token-ids';
|
|
9
10
|
import tokens from '@atlaskit/tokens/token-names';
|
|
10
11
|
import { createLintRule } from '../utils/create-rule';
|
|
@@ -87,18 +88,30 @@ var rule = createLintRule({
|
|
|
87
88
|
return;
|
|
88
89
|
}
|
|
89
90
|
if (node.arguments.length < 2 && config.fallbackUsage === 'forced') {
|
|
91
|
+
var fix;
|
|
92
|
+
if (node.arguments[0].type === 'Literal') {
|
|
93
|
+
var value = node.arguments[0].value;
|
|
94
|
+
var tokenName = value;
|
|
95
|
+
var fallbackValue = tokenDefaultValues[tokenName] || null;
|
|
96
|
+
if (fallbackValue) {
|
|
97
|
+
fix = function fix(fixer) {
|
|
98
|
+
return fixer.replaceText(node, "".concat(isNodeOfType(node.callee, 'Identifier') ? node.callee.name : 'token', "('").concat(tokenName, "', '").concat(fallbackValue, "')"));
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
90
102
|
context.report({
|
|
91
103
|
messageId: 'tokenFallbackEnforced',
|
|
92
|
-
node: node
|
|
104
|
+
node: node,
|
|
105
|
+
fix: fix
|
|
93
106
|
});
|
|
94
107
|
} else if (node.arguments.length > 1 && config.fallbackUsage === 'none') {
|
|
95
108
|
if (node.arguments[0].type === 'Literal') {
|
|
96
|
-
var
|
|
109
|
+
var _value = node.arguments[0].value;
|
|
97
110
|
context.report({
|
|
98
111
|
messageId: 'tokenFallbackRestricted',
|
|
99
112
|
node: node.arguments[1],
|
|
100
113
|
fix: function fix(fixer) {
|
|
101
|
-
return fixer.replaceText(node, "".concat(isNodeOfType(node.callee, 'Identifier') ? node.callee.name : 'token', "('").concat(
|
|
114
|
+
return fixer.replaceText(node, "".concat(isNodeOfType(node.callee, 'Identifier') ? node.callee.name : 'token', "('").concat(_value, "')"));
|
|
102
115
|
}
|
|
103
116
|
});
|
|
104
117
|
} else {
|
|
@@ -41,8 +41,8 @@ export declare const fontFamilyTokens: ({
|
|
|
41
41
|
state: string;
|
|
42
42
|
introduced: string;
|
|
43
43
|
description: string;
|
|
44
|
-
responsiveSmallerVariant?: undefined;
|
|
45
44
|
deprecated?: undefined;
|
|
45
|
+
responsiveSmallerVariant?: undefined;
|
|
46
46
|
};
|
|
47
47
|
value: string;
|
|
48
48
|
filePath: string;
|
|
@@ -53,8 +53,8 @@ export declare const fontFamilyTokens: ({
|
|
|
53
53
|
state: string;
|
|
54
54
|
introduced: string;
|
|
55
55
|
description: string;
|
|
56
|
-
responsiveSmallerVariant?: undefined;
|
|
57
56
|
deprecated?: undefined;
|
|
57
|
+
responsiveSmallerVariant?: undefined;
|
|
58
58
|
};
|
|
59
59
|
value: string;
|
|
60
60
|
};
|
|
@@ -67,8 +67,8 @@ export declare const fontFamilyTokens: ({
|
|
|
67
67
|
state: string;
|
|
68
68
|
introduced: string;
|
|
69
69
|
description: string;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
deprecated: string;
|
|
71
|
+
responsiveSmallerVariant?: undefined;
|
|
72
72
|
};
|
|
73
73
|
value: string;
|
|
74
74
|
filePath: string;
|
|
@@ -79,17 +79,10 @@ export declare const fontFamilyTokens: ({
|
|
|
79
79
|
state: string;
|
|
80
80
|
introduced: string;
|
|
81
81
|
description: string;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
value: {
|
|
86
|
-
fontWeight: string;
|
|
87
|
-
fontSize: string;
|
|
88
|
-
lineHeight: string;
|
|
89
|
-
fontFamily: string;
|
|
90
|
-
fontStyle: string;
|
|
91
|
-
letterSpacing: string;
|
|
82
|
+
deprecated: string;
|
|
83
|
+
responsiveSmallerVariant?: undefined;
|
|
92
84
|
};
|
|
85
|
+
value: string;
|
|
93
86
|
};
|
|
94
87
|
name: string;
|
|
95
88
|
path: string[];
|
|
@@ -100,7 +93,7 @@ export declare const fontFamilyTokens: ({
|
|
|
100
93
|
state: string;
|
|
101
94
|
introduced: string;
|
|
102
95
|
description: string;
|
|
103
|
-
responsiveSmallerVariant
|
|
96
|
+
responsiveSmallerVariant: string;
|
|
104
97
|
deprecated?: undefined;
|
|
105
98
|
};
|
|
106
99
|
value: string;
|
|
@@ -112,7 +105,7 @@ export declare const fontFamilyTokens: ({
|
|
|
112
105
|
state: string;
|
|
113
106
|
introduced: string;
|
|
114
107
|
description: string;
|
|
115
|
-
responsiveSmallerVariant
|
|
108
|
+
responsiveSmallerVariant: string;
|
|
116
109
|
deprecated?: undefined;
|
|
117
110
|
};
|
|
118
111
|
value: {
|
|
@@ -133,7 +126,7 @@ export declare const fontFamilyTokens: ({
|
|
|
133
126
|
state: string;
|
|
134
127
|
introduced: string;
|
|
135
128
|
description: string;
|
|
136
|
-
deprecated
|
|
129
|
+
deprecated?: undefined;
|
|
137
130
|
responsiveSmallerVariant?: undefined;
|
|
138
131
|
};
|
|
139
132
|
value: string;
|
|
@@ -145,10 +138,17 @@ export declare const fontFamilyTokens: ({
|
|
|
145
138
|
state: string;
|
|
146
139
|
introduced: string;
|
|
147
140
|
description: string;
|
|
148
|
-
deprecated
|
|
141
|
+
deprecated?: undefined;
|
|
149
142
|
responsiveSmallerVariant?: undefined;
|
|
150
143
|
};
|
|
151
|
-
value:
|
|
144
|
+
value: {
|
|
145
|
+
fontWeight: string;
|
|
146
|
+
fontSize: string;
|
|
147
|
+
lineHeight: string;
|
|
148
|
+
fontFamily: string;
|
|
149
|
+
fontStyle: string;
|
|
150
|
+
letterSpacing: string;
|
|
151
|
+
};
|
|
152
152
|
};
|
|
153
153
|
name: string;
|
|
154
154
|
path: string[];
|
|
@@ -41,8 +41,8 @@ export declare const fontFamilyTokens: ({
|
|
|
41
41
|
state: string;
|
|
42
42
|
introduced: string;
|
|
43
43
|
description: string;
|
|
44
|
-
responsiveSmallerVariant?: undefined;
|
|
45
44
|
deprecated?: undefined;
|
|
45
|
+
responsiveSmallerVariant?: undefined;
|
|
46
46
|
};
|
|
47
47
|
value: string;
|
|
48
48
|
filePath: string;
|
|
@@ -53,8 +53,8 @@ export declare const fontFamilyTokens: ({
|
|
|
53
53
|
state: string;
|
|
54
54
|
introduced: string;
|
|
55
55
|
description: string;
|
|
56
|
-
responsiveSmallerVariant?: undefined;
|
|
57
56
|
deprecated?: undefined;
|
|
57
|
+
responsiveSmallerVariant?: undefined;
|
|
58
58
|
};
|
|
59
59
|
value: string;
|
|
60
60
|
};
|
|
@@ -67,8 +67,8 @@ export declare const fontFamilyTokens: ({
|
|
|
67
67
|
state: string;
|
|
68
68
|
introduced: string;
|
|
69
69
|
description: string;
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
deprecated: string;
|
|
71
|
+
responsiveSmallerVariant?: undefined;
|
|
72
72
|
};
|
|
73
73
|
value: string;
|
|
74
74
|
filePath: string;
|
|
@@ -79,17 +79,10 @@ export declare const fontFamilyTokens: ({
|
|
|
79
79
|
state: string;
|
|
80
80
|
introduced: string;
|
|
81
81
|
description: string;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
};
|
|
85
|
-
value: {
|
|
86
|
-
fontWeight: string;
|
|
87
|
-
fontSize: string;
|
|
88
|
-
lineHeight: string;
|
|
89
|
-
fontFamily: string;
|
|
90
|
-
fontStyle: string;
|
|
91
|
-
letterSpacing: string;
|
|
82
|
+
deprecated: string;
|
|
83
|
+
responsiveSmallerVariant?: undefined;
|
|
92
84
|
};
|
|
85
|
+
value: string;
|
|
93
86
|
};
|
|
94
87
|
name: string;
|
|
95
88
|
path: string[];
|
|
@@ -100,7 +93,7 @@ export declare const fontFamilyTokens: ({
|
|
|
100
93
|
state: string;
|
|
101
94
|
introduced: string;
|
|
102
95
|
description: string;
|
|
103
|
-
responsiveSmallerVariant
|
|
96
|
+
responsiveSmallerVariant: string;
|
|
104
97
|
deprecated?: undefined;
|
|
105
98
|
};
|
|
106
99
|
value: string;
|
|
@@ -112,7 +105,7 @@ export declare const fontFamilyTokens: ({
|
|
|
112
105
|
state: string;
|
|
113
106
|
introduced: string;
|
|
114
107
|
description: string;
|
|
115
|
-
responsiveSmallerVariant
|
|
108
|
+
responsiveSmallerVariant: string;
|
|
116
109
|
deprecated?: undefined;
|
|
117
110
|
};
|
|
118
111
|
value: {
|
|
@@ -133,7 +126,7 @@ export declare const fontFamilyTokens: ({
|
|
|
133
126
|
state: string;
|
|
134
127
|
introduced: string;
|
|
135
128
|
description: string;
|
|
136
|
-
deprecated
|
|
129
|
+
deprecated?: undefined;
|
|
137
130
|
responsiveSmallerVariant?: undefined;
|
|
138
131
|
};
|
|
139
132
|
value: string;
|
|
@@ -145,10 +138,17 @@ export declare const fontFamilyTokens: ({
|
|
|
145
138
|
state: string;
|
|
146
139
|
introduced: string;
|
|
147
140
|
description: string;
|
|
148
|
-
deprecated
|
|
141
|
+
deprecated?: undefined;
|
|
149
142
|
responsiveSmallerVariant?: undefined;
|
|
150
143
|
};
|
|
151
|
-
value:
|
|
144
|
+
value: {
|
|
145
|
+
fontWeight: string;
|
|
146
|
+
fontSize: string;
|
|
147
|
+
lineHeight: string;
|
|
148
|
+
fontFamily: string;
|
|
149
|
+
fontStyle: string;
|
|
150
|
+
letterSpacing: string;
|
|
151
|
+
};
|
|
152
152
|
};
|
|
153
153
|
name: string;
|
|
154
154
|
path: 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": "10.0
|
|
4
|
+
"version": "10.1.0",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@af/formatting": "*",
|
|
57
57
|
"@atlaskit/ds-lib": "^2.3.0",
|
|
58
|
-
"@atlaskit/theme": "^12.
|
|
58
|
+
"@atlaskit/theme": "^12.8.0",
|
|
59
59
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
60
60
|
"@atlassian/codegen": "*",
|
|
61
61
|
"@atlassian/eslint-utils": "^0.4.0",
|