@atlaskit/eslint-plugin-design-system 4.3.0 → 4.4.2
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 +33 -0
- package/README.md +19 -3
- package/dist/cjs/rules/ensure-design-token-usage/index.js +1 -3
- package/dist/cjs/rules/no-deprecated-design-token-usage/index.js +5 -9
- package/dist/cjs/rules/no-unsafe-design-token-usage/index.js +4 -8
- package/dist/cjs/rules/utils/is-color.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/rules/ensure-design-token-usage/index.js +1 -1
- package/dist/es2019/rules/no-deprecated-design-token-usage/index.js +5 -7
- package/dist/es2019/rules/no-unsafe-design-token-usage/index.js +3 -5
- package/dist/es2019/rules/utils/is-color.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/rules/ensure-design-token-usage/index.js +1 -3
- package/dist/esm/rules/no-deprecated-design-token-usage/index.js +5 -11
- package/dist/esm/rules/no-unsafe-design-token-usage/index.js +3 -9
- package/dist/esm/rules/utils/is-color.js +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 4.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b3e5a62a9e3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b3e5a62a9e3) - Adds `static` techstack to package, enforcing stricter style linting. In this case the package already satisfied this requirement so there have been no changes to styles.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 4.4.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`236e6040fb9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/236e6040fb9) - Fixes a bug in the rule `ensure-design-token-usage` where some color value types were not being detected as hardcoded color usage. This affected Styled Components and Emotion CSS prop syntaxes.
|
|
15
|
+
|
|
16
|
+
These color types have been fixed:
|
|
17
|
+
|
|
18
|
+
- rgb
|
|
19
|
+
- rgba
|
|
20
|
+
- hsl
|
|
21
|
+
- hsla
|
|
22
|
+
- lch
|
|
23
|
+
- lab
|
|
24
|
+
- color()
|
|
25
|
+
|
|
26
|
+
## 4.4.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [`1065b5b1bbb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1065b5b1bbb) - Fixed bug where deleted '[default]' tokens were not being detected by lint tooling
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- Updated dependencies
|
|
35
|
+
|
|
3
36
|
## 4.3.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -15,21 +15,37 @@ Add the plugin to your `.eslintrc.js` file.
|
|
|
15
15
|
```diff
|
|
16
16
|
module.exports = {
|
|
17
17
|
plugins: [
|
|
18
|
-
+ '@atlaskit/
|
|
18
|
+
+ '@atlaskit/design-system',
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Extend the configuration file.
|
|
24
24
|
|
|
25
25
|
```diff
|
|
26
26
|
module.exports = {
|
|
27
27
|
extends: [
|
|
28
|
-
+ 'plugin:@atlaskit/
|
|
28
|
+
+ 'plugin:@atlaskit/design-system/recommended',
|
|
29
29
|
],
|
|
30
30
|
};
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
Enable any desired rules.
|
|
34
|
+
|
|
35
|
+
```diff
|
|
36
|
+
module.exports = {
|
|
37
|
+
rules: {
|
|
38
|
+
+ '@atlaskit/design-system/ensure-design-token-usage': ['error', { 'shouldEnsureFallbackUsage': true }],
|
|
39
|
+
+ '@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
|
|
40
|
+
+ '@atlaskit/design-system/no-unsafe-design-token-usage': ['error', { 'shouldEnsureFallbackUsage': true }],
|
|
41
|
+
+ '@atlaskit/design-system/use-visually-hidden': 'error',
|
|
42
|
+
+ '@atlaskit/design-system/no-deprecated-imports': 'error',
|
|
43
|
+
+ '@atlaskit/design-system/no-deprecated-api-usage': 'error'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
```
|
|
48
|
+
|
|
33
49
|
Rules will where possible come with fixers.
|
|
34
50
|
For individual rules see the [`rules`](./src/rules) folder,
|
|
35
51
|
however its strongly recommended to use the rules as above.
|
|
@@ -129,9 +129,7 @@ var rule = {
|
|
|
129
129
|
* This is necessary to avoid cases where a property might have a color in its name ie. "white-space"
|
|
130
130
|
*/
|
|
131
131
|
|
|
132
|
-
var cssProperties = value.replace(/\n/g, '').split(/;|{|}/).
|
|
133
|
-
return !el.match(/\.|\@|\(|\)/);
|
|
134
|
-
}).map(function (el) {
|
|
132
|
+
var cssProperties = value.replace(/\n/g, '').split(/;|{|}/).map(function (el) {
|
|
135
133
|
return el.trim().split(':').pop() || '';
|
|
136
134
|
});
|
|
137
135
|
cssProperties.forEach(function (property) {
|
|
@@ -9,11 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _renameMapping = _interopRequireDefault(require("@atlaskit/tokens/rename-mapping"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
return path.split('.').filter(function (el) {
|
|
14
|
-
return el !== '[default]';
|
|
15
|
-
}).join('.');
|
|
16
|
-
};
|
|
12
|
+
var _tokenIds = require("@atlaskit/tokens/token-ids");
|
|
17
13
|
|
|
18
14
|
var rule = {
|
|
19
15
|
meta: {
|
|
@@ -50,20 +46,20 @@ var rule = {
|
|
|
50
46
|
var migrationMeta = _renameMapping.default.filter(function (t) {
|
|
51
47
|
return t.state === 'deprecated';
|
|
52
48
|
}).find(function (t) {
|
|
53
|
-
return
|
|
49
|
+
return (0, _tokenIds.getTokenId)(t.path) === tokenKey;
|
|
54
50
|
});
|
|
55
51
|
|
|
56
52
|
if (migrationMeta) {
|
|
57
|
-
var
|
|
53
|
+
var replacement = (0, _tokenIds.getTokenId)(migrationMeta.replacement);
|
|
58
54
|
context.report({
|
|
59
55
|
messageId: 'tokenRenamed',
|
|
60
56
|
node: node,
|
|
61
57
|
data: {
|
|
62
58
|
name: tokenKey,
|
|
63
|
-
replacement:
|
|
59
|
+
replacement: replacement
|
|
64
60
|
},
|
|
65
61
|
fix: function fix(fixer) {
|
|
66
|
-
return fixer.replaceText(node.arguments[0], "'".concat(
|
|
62
|
+
return fixer.replaceText(node.arguments[0], "'".concat(replacement, "'"));
|
|
67
63
|
}
|
|
68
64
|
});
|
|
69
65
|
return;
|
|
@@ -9,18 +9,14 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _renameMapping = _interopRequireDefault(require("@atlaskit/tokens/rename-mapping"));
|
|
11
11
|
|
|
12
|
+
var _tokenIds = require("@atlaskit/tokens/token-ids");
|
|
13
|
+
|
|
12
14
|
var _tokenNames = _interopRequireDefault(require("@atlaskit/tokens/token-names"));
|
|
13
15
|
|
|
14
16
|
var _isNode = require("../utils/is-node");
|
|
15
17
|
|
|
16
18
|
var _isToken = require("../utils/is-token");
|
|
17
19
|
|
|
18
|
-
var getCleanPathId = function getCleanPathId(path) {
|
|
19
|
-
return path.split('.').filter(function (el) {
|
|
20
|
-
return el !== '[default]';
|
|
21
|
-
}).join('.');
|
|
22
|
-
};
|
|
23
|
-
|
|
24
20
|
var defaultConfig = {
|
|
25
21
|
shouldEnforceFallbacks: false
|
|
26
22
|
};
|
|
@@ -139,11 +135,11 @@ var rule = {
|
|
|
139
135
|
var migrationMeta = _renameMapping.default.filter(function (t) {
|
|
140
136
|
return t.state === 'deleted';
|
|
141
137
|
}).find(function (t) {
|
|
142
|
-
return t.path === tokenKey;
|
|
138
|
+
return (0, _tokenIds.getTokenId)(t.path) === tokenKey;
|
|
143
139
|
});
|
|
144
140
|
|
|
145
141
|
if (typeof tokenKey === 'string' && migrationMeta) {
|
|
146
|
-
var cleanTokenKey =
|
|
142
|
+
var cleanTokenKey = (0, _tokenIds.getTokenId)(migrationMeta.replacement);
|
|
147
143
|
context.report({
|
|
148
144
|
messageId: 'tokenRemoved',
|
|
149
145
|
node: node,
|
|
@@ -34,7 +34,7 @@ exports.isLegacyNamedColor = isLegacyNamedColor;
|
|
|
34
34
|
var includesHardCodedColor = function includesHardCodedColor(raw) {
|
|
35
35
|
var value = raw.toLowerCase();
|
|
36
36
|
|
|
37
|
-
if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|(?:rgb|hsl)a
|
|
37
|
+
if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|((?:rgb|hsl)a?|(lch|lab|color))\([^\)]*\)/.exec(value.toLowerCase())) {
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
40
40
|
|
package/dist/cjs/version.json
CHANGED
|
@@ -129,7 +129,7 @@ ${' '.repeat(getNodeColumn(node) - 2)}box-shadow: \${token('${elevation.shadow}'
|
|
|
129
129
|
* This is necessary to avoid cases where a property might have a color in its name ie. "white-space"
|
|
130
130
|
*/
|
|
131
131
|
|
|
132
|
-
const cssProperties = value.replace(/\n/g, '').split(/;|{|}/).
|
|
132
|
+
const cssProperties = value.replace(/\n/g, '').split(/;|{|}/).map(el => el.trim().split(':').pop() || '');
|
|
133
133
|
cssProperties.forEach(property => {
|
|
134
134
|
if (includesHardCodedColor(property)) {
|
|
135
135
|
context.report({
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
2
|
-
|
|
3
|
-
const getCleanPathId = path => path.split('.').filter(el => el !== '[default]').join('.');
|
|
4
|
-
|
|
2
|
+
import { getTokenId } from '@atlaskit/tokens/token-ids';
|
|
5
3
|
const rule = {
|
|
6
4
|
meta: {
|
|
7
5
|
docs: {
|
|
@@ -35,18 +33,18 @@ const rule = {
|
|
|
35
33
|
return;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
const migrationMeta = renameMapping.filter(t => t.state === 'deprecated').find(t =>
|
|
36
|
+
const migrationMeta = renameMapping.filter(t => t.state === 'deprecated').find(t => getTokenId(t.path) === tokenKey);
|
|
39
37
|
|
|
40
38
|
if (migrationMeta) {
|
|
41
|
-
const
|
|
39
|
+
const replacement = getTokenId(migrationMeta.replacement);
|
|
42
40
|
context.report({
|
|
43
41
|
messageId: 'tokenRenamed',
|
|
44
42
|
node,
|
|
45
43
|
data: {
|
|
46
44
|
name: tokenKey,
|
|
47
|
-
replacement
|
|
45
|
+
replacement
|
|
48
46
|
},
|
|
49
|
-
fix: fixer => fixer.replaceText(node.arguments[0], `'${
|
|
47
|
+
fix: fixer => fixer.replaceText(node.arguments[0], `'${replacement}'`)
|
|
50
48
|
});
|
|
51
49
|
return;
|
|
52
50
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
2
|
+
import { getTokenId } from '@atlaskit/tokens/token-ids';
|
|
2
3
|
import tokens from '@atlaskit/tokens/token-names';
|
|
3
4
|
import { isDecendantOfStyleBlock, isDecendantOfStyleJsxAttribute } from '../utils/is-node';
|
|
4
5
|
import { isToken } from '../utils/is-token';
|
|
5
|
-
|
|
6
|
-
const getCleanPathId = path => path.split('.').filter(el => el !== '[default]').join('.');
|
|
7
|
-
|
|
8
6
|
const defaultConfig = {
|
|
9
7
|
shouldEnforceFallbacks: false
|
|
10
8
|
};
|
|
@@ -139,10 +137,10 @@ token('color.background.blanket');
|
|
|
139
137
|
return;
|
|
140
138
|
}
|
|
141
139
|
|
|
142
|
-
const migrationMeta = renameMapping.filter(t => t.state === 'deleted').find(t => t.path === tokenKey);
|
|
140
|
+
const migrationMeta = renameMapping.filter(t => t.state === 'deleted').find(t => getTokenId(t.path) === tokenKey);
|
|
143
141
|
|
|
144
142
|
if (typeof tokenKey === 'string' && migrationMeta) {
|
|
145
|
-
const cleanTokenKey =
|
|
143
|
+
const cleanTokenKey = getTokenId(migrationMeta.replacement);
|
|
146
144
|
context.report({
|
|
147
145
|
messageId: 'tokenRemoved',
|
|
148
146
|
node,
|
|
@@ -18,7 +18,7 @@ export const isLegacyNamedColor = value => legacyColorMixins.includes(value);
|
|
|
18
18
|
export const includesHardCodedColor = raw => {
|
|
19
19
|
const value = raw.toLowerCase();
|
|
20
20
|
|
|
21
|
-
if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|(?:rgb|hsl)a
|
|
21
|
+
if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|((?:rgb|hsl)a?|(lch|lab|color))\([^\)]*\)/.exec(value.toLowerCase())) {
|
|
22
22
|
return true;
|
|
23
23
|
}
|
|
24
24
|
|
package/dist/es2019/version.json
CHANGED
|
@@ -119,9 +119,7 @@ var rule = {
|
|
|
119
119
|
* This is necessary to avoid cases where a property might have a color in its name ie. "white-space"
|
|
120
120
|
*/
|
|
121
121
|
|
|
122
|
-
var cssProperties = value.replace(/\n/g, '').split(/;|{|}/).
|
|
123
|
-
return !el.match(/\.|\@|\(|\)/);
|
|
124
|
-
}).map(function (el) {
|
|
122
|
+
var cssProperties = value.replace(/\n/g, '').split(/;|{|}/).map(function (el) {
|
|
125
123
|
return el.trim().split(':').pop() || '';
|
|
126
124
|
});
|
|
127
125
|
cssProperties.forEach(function (property) {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
2
|
-
|
|
3
|
-
var getCleanPathId = function getCleanPathId(path) {
|
|
4
|
-
return path.split('.').filter(function (el) {
|
|
5
|
-
return el !== '[default]';
|
|
6
|
-
}).join('.');
|
|
7
|
-
};
|
|
8
|
-
|
|
2
|
+
import { getTokenId } from '@atlaskit/tokens/token-ids';
|
|
9
3
|
var rule = {
|
|
10
4
|
meta: {
|
|
11
5
|
docs: {
|
|
@@ -41,20 +35,20 @@ var rule = {
|
|
|
41
35
|
var migrationMeta = renameMapping.filter(function (t) {
|
|
42
36
|
return t.state === 'deprecated';
|
|
43
37
|
}).find(function (t) {
|
|
44
|
-
return
|
|
38
|
+
return getTokenId(t.path) === tokenKey;
|
|
45
39
|
});
|
|
46
40
|
|
|
47
41
|
if (migrationMeta) {
|
|
48
|
-
var
|
|
42
|
+
var replacement = getTokenId(migrationMeta.replacement);
|
|
49
43
|
context.report({
|
|
50
44
|
messageId: 'tokenRenamed',
|
|
51
45
|
node: node,
|
|
52
46
|
data: {
|
|
53
47
|
name: tokenKey,
|
|
54
|
-
replacement:
|
|
48
|
+
replacement: replacement
|
|
55
49
|
},
|
|
56
50
|
fix: function fix(fixer) {
|
|
57
|
-
return fixer.replaceText(node.arguments[0], "'".concat(
|
|
51
|
+
return fixer.replaceText(node.arguments[0], "'".concat(replacement, "'"));
|
|
58
52
|
}
|
|
59
53
|
});
|
|
60
54
|
return;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import renameMapping from '@atlaskit/tokens/rename-mapping';
|
|
2
|
+
import { getTokenId } from '@atlaskit/tokens/token-ids';
|
|
2
3
|
import tokens from '@atlaskit/tokens/token-names';
|
|
3
4
|
import { isDecendantOfStyleBlock, isDecendantOfStyleJsxAttribute } from '../utils/is-node';
|
|
4
5
|
import { isToken } from '../utils/is-token';
|
|
5
|
-
|
|
6
|
-
var getCleanPathId = function getCleanPathId(path) {
|
|
7
|
-
return path.split('.').filter(function (el) {
|
|
8
|
-
return el !== '[default]';
|
|
9
|
-
}).join('.');
|
|
10
|
-
};
|
|
11
|
-
|
|
12
6
|
var defaultConfig = {
|
|
13
7
|
shouldEnforceFallbacks: false
|
|
14
8
|
};
|
|
@@ -127,11 +121,11 @@ var rule = {
|
|
|
127
121
|
var migrationMeta = renameMapping.filter(function (t) {
|
|
128
122
|
return t.state === 'deleted';
|
|
129
123
|
}).find(function (t) {
|
|
130
|
-
return t.path === tokenKey;
|
|
124
|
+
return getTokenId(t.path) === tokenKey;
|
|
131
125
|
});
|
|
132
126
|
|
|
133
127
|
if (typeof tokenKey === 'string' && migrationMeta) {
|
|
134
|
-
var cleanTokenKey =
|
|
128
|
+
var cleanTokenKey = getTokenId(migrationMeta.replacement);
|
|
135
129
|
context.report({
|
|
136
130
|
messageId: 'tokenRemoved',
|
|
137
131
|
node: node,
|
|
@@ -22,7 +22,7 @@ export var isLegacyNamedColor = function isLegacyNamedColor(value) {
|
|
|
22
22
|
export var includesHardCodedColor = function includesHardCodedColor(raw) {
|
|
23
23
|
var value = raw.toLowerCase();
|
|
24
24
|
|
|
25
|
-
if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|(?:rgb|hsl)a
|
|
25
|
+
if (/#(?:[a-f0-9]{3}|[a-f0-9]{6}|[a-f0-9]{8})\b|((?:rgb|hsl)a?|(lch|lab|color))\([^\)]*\)/.exec(value.toLowerCase())) {
|
|
26
26
|
return true;
|
|
27
27
|
}
|
|
28
28
|
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-design-system",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"author": "Atlassian Pty Ltd",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
".": "./src/index.tsx"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaskit/tokens": "^0.
|
|
23
|
+
"@atlaskit/tokens": "^0.9.0",
|
|
24
24
|
"@babel/runtime": "^7.0.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"react": "^16.8.0",
|
|
33
33
|
"ts-node": "^10.0.0",
|
|
34
34
|
"tsconfig-paths": "^3.9.0",
|
|
35
|
-
"typescript": "3.9.
|
|
35
|
+
"typescript": "3.9.10"
|
|
36
36
|
},
|
|
37
37
|
"techstack": {
|
|
38
38
|
"@atlassian/frontend": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"design-system": "v1",
|
|
44
44
|
"deprecation": "no-deprecated-imports",
|
|
45
45
|
"styling": [
|
|
46
|
+
"static",
|
|
46
47
|
"emotion"
|
|
47
48
|
]
|
|
48
49
|
}
|