@atlaskit/eslint-plugin-design-system 8.24.0 → 8.25.1
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/dist/cjs/rules/ensure-design-token-usage/color.js +3 -0
- package/dist/cjs/rules/use-button-group-label/index.js +11 -9
- package/dist/cjs/rules/utils/is-node.js +13 -1
- package/dist/es2019/rules/ensure-design-token-usage/color.js +4 -1
- package/dist/es2019/rules/use-button-group-label/index.js +13 -9
- package/dist/es2019/rules/utils/is-node.js +12 -0
- package/dist/esm/rules/ensure-design-token-usage/color.js +4 -1
- package/dist/esm/rules/use-button-group-label/index.js +11 -9
- package/dist/esm/rules/utils/is-node.js +12 -0
- package/dist/types/rules/utils/is-node.d.ts +1 -0
- package/dist/types-ts4.5/rules/utils/is-node.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 8.25.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#67941](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67941) [`0b1def807516`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0b1def807516) - Now rule is aplicable only to ButtonGroup ImportSpecifiers
|
|
8
|
+
|
|
9
|
+
## 8.25.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#70369](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/70369) [`611434ce1fe5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/611434ce1fe5) - ensure-design-token-usage no longer errors on color properties defined in SVG JSX elements.
|
|
14
|
+
|
|
3
15
|
## 8.24.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -140,6 +140,9 @@ var lintJSXLiteralForColor = exports.lintJSXLiteralForColor = function lintJSXLi
|
|
|
140
140
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.parent.name, 'JSXIdentifier')) {
|
|
141
141
|
return;
|
|
142
142
|
}
|
|
143
|
+
if ((0, _isNode.isDecendantOfSvgElement)(node.parent)) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
143
146
|
if (['alt', 'src', 'label', 'key'].includes(node.parent.name.name)) {
|
|
144
147
|
return;
|
|
145
148
|
}
|
|
@@ -30,16 +30,18 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
30
30
|
var contextLocalIdentifier = [];
|
|
31
31
|
return {
|
|
32
32
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
contextLocalIdentifier.push(local.name);
|
|
41
|
-
}
|
|
33
|
+
var _node$specifiers;
|
|
34
|
+
var buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
35
|
+
if (node.source.value === '@atlaskit/button') {
|
|
36
|
+
var _spec$imported;
|
|
37
|
+
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
38
|
+
} else if (node.source.value === '@atlaskit/button/button-group') {
|
|
39
|
+
return spec.type === 'ImportDefaultSpecifier';
|
|
42
40
|
}
|
|
41
|
+
});
|
|
42
|
+
if (buttonGroupIdentifier !== null && buttonGroupIdentifier !== void 0 && buttonGroupIdentifier.length) {
|
|
43
|
+
var local = buttonGroupIdentifier[0].local;
|
|
44
|
+
contextLocalIdentifier.push(local.name);
|
|
43
45
|
}
|
|
44
46
|
},
|
|
45
47
|
JSXElement: function JSXElement(node) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPropertyKey = exports.isDecendantOfType = exports.isDecendantOfStyleJsxAttribute = exports.isDecendantOfStyleBlock = exports.isDecendantOfGlobalToken = exports.isCssInJsTemplateNode = exports.isCssInJsObjectNode = exports.isCssInJsCallNode = exports.isChildOfType = void 0;
|
|
6
|
+
exports.isPropertyKey = exports.isDecendantOfType = exports.isDecendantOfSvgElement = exports.isDecendantOfStyleJsxAttribute = exports.isDecendantOfStyleBlock = exports.isDecendantOfGlobalToken = exports.isCssInJsTemplateNode = exports.isCssInJsObjectNode = exports.isCssInJsCallNode = exports.isChildOfType = void 0;
|
|
7
7
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
8
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
9
|
|
|
@@ -42,6 +42,18 @@ var isDecendantOfStyleJsxAttribute = exports.isDecendantOfStyleJsxAttribute = fu
|
|
|
42
42
|
}
|
|
43
43
|
return false;
|
|
44
44
|
};
|
|
45
|
+
var isDecendantOfSvgElement = exports.isDecendantOfSvgElement = function isDecendantOfSvgElement(node) {
|
|
46
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
if (node.openingElement.name.name === 'svg') {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (node.parent) {
|
|
53
|
+
return isDecendantOfSvgElement(node.parent);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
45
57
|
var cssInJsCallees = ['css', 'styled', 'styled2'];
|
|
46
58
|
var isCssInJsTemplateNode = exports.isCssInJsTemplateNode = function isCssInJsTemplateNode(node) {
|
|
47
59
|
return (node === null || node === void 0 ? void 0 : node.type) === 'TaggedTemplateExpression' && node.tag.type === 'MemberExpression' && node.tag.object.type === 'Identifier' && node.tag.object.name === 'styled';
|
|
@@ -4,7 +4,7 @@ import { node as generate, isNodeOfType } from 'eslint-codemod-utils';
|
|
|
4
4
|
import { getIsException } from '../utils/get-is-exception';
|
|
5
5
|
import { includesHardCodedColor, isHardCodedColor, isLegacyColor, isLegacyNamedColor } from '../utils/is-color';
|
|
6
6
|
import { isLegacyElevation } from '../utils/is-elevation';
|
|
7
|
-
import { isChildOfType, isDecendantOfGlobalToken, isDecendantOfStyleBlock } from '../utils/is-node';
|
|
7
|
+
import { isChildOfType, isDecendantOfGlobalToken, isDecendantOfStyleBlock, isDecendantOfSvgElement } from '../utils/is-node';
|
|
8
8
|
// TemplateLiteral > Identifier
|
|
9
9
|
export const lintTemplateIdentifierForColor = (node, context, config) => {
|
|
10
10
|
if (node.type !== 'Identifier') {
|
|
@@ -135,6 +135,9 @@ export const lintJSXLiteralForColor = (node, context, config) => {
|
|
|
135
135
|
if (!isNodeOfType(node.parent.name, 'JSXIdentifier')) {
|
|
136
136
|
return;
|
|
137
137
|
}
|
|
138
|
+
if (isDecendantOfSvgElement(node.parent)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
138
141
|
if (['alt', 'src', 'label', 'key'].includes(node.parent.name.name)) {
|
|
139
142
|
return;
|
|
140
143
|
}
|
|
@@ -24,16 +24,20 @@ const rule = createLintRule({
|
|
|
24
24
|
const contextLocalIdentifier = [];
|
|
25
25
|
return {
|
|
26
26
|
ImportDeclaration(node) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
contextLocalIdentifier.push(local.name);
|
|
35
|
-
}
|
|
27
|
+
var _node$specifiers;
|
|
28
|
+
const buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(spec => {
|
|
29
|
+
if (node.source.value === '@atlaskit/button') {
|
|
30
|
+
var _spec$imported;
|
|
31
|
+
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
32
|
+
} else if (node.source.value === '@atlaskit/button/button-group') {
|
|
33
|
+
return spec.type === 'ImportDefaultSpecifier';
|
|
36
34
|
}
|
|
35
|
+
});
|
|
36
|
+
if (buttonGroupIdentifier !== null && buttonGroupIdentifier !== void 0 && buttonGroupIdentifier.length) {
|
|
37
|
+
const {
|
|
38
|
+
local
|
|
39
|
+
} = buttonGroupIdentifier[0];
|
|
40
|
+
contextLocalIdentifier.push(local.name);
|
|
37
41
|
}
|
|
38
42
|
},
|
|
39
43
|
JSXElement(node) {
|
|
@@ -35,6 +35,18 @@ export const isDecendantOfStyleJsxAttribute = node => {
|
|
|
35
35
|
}
|
|
36
36
|
return false;
|
|
37
37
|
};
|
|
38
|
+
export const isDecendantOfSvgElement = node => {
|
|
39
|
+
if (isNodeOfType(node, 'JSXElement')) {
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
if (node.openingElement.name.name === 'svg') {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (node.parent) {
|
|
46
|
+
return isDecendantOfSvgElement(node.parent);
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
};
|
|
38
50
|
const cssInJsCallees = ['css', 'styled', 'styled2'];
|
|
39
51
|
export const isCssInJsTemplateNode = node => (node === null || node === void 0 ? void 0 : node.type) === 'TaggedTemplateExpression' && node.tag.type === 'MemberExpression' && node.tag.object.type === 'Identifier' && node.tag.object.name === 'styled';
|
|
40
52
|
export const isCssInJsCallNode = node => (node === null || node === void 0 ? void 0 : node.type) === 'CallExpression' && node.callee.type === 'Identifier' && cssInJsCallees.includes(node.callee.name);
|
|
@@ -4,7 +4,7 @@ import { node as generate, isNodeOfType } from 'eslint-codemod-utils';
|
|
|
4
4
|
import { getIsException } from '../utils/get-is-exception';
|
|
5
5
|
import { includesHardCodedColor, isHardCodedColor, isLegacyColor, isLegacyNamedColor } from '../utils/is-color';
|
|
6
6
|
import { isLegacyElevation } from '../utils/is-elevation';
|
|
7
|
-
import { isChildOfType, isDecendantOfGlobalToken, isDecendantOfStyleBlock } from '../utils/is-node';
|
|
7
|
+
import { isChildOfType, isDecendantOfGlobalToken, isDecendantOfStyleBlock, isDecendantOfSvgElement } from '../utils/is-node';
|
|
8
8
|
// TemplateLiteral > Identifier
|
|
9
9
|
export var lintTemplateIdentifierForColor = function lintTemplateIdentifierForColor(node, context, config) {
|
|
10
10
|
if (node.type !== 'Identifier') {
|
|
@@ -134,6 +134,9 @@ export var lintJSXLiteralForColor = function lintJSXLiteralForColor(node, contex
|
|
|
134
134
|
if (!isNodeOfType(node.parent.name, 'JSXIdentifier')) {
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
+
if (isDecendantOfSvgElement(node.parent)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
137
140
|
if (['alt', 'src', 'label', 'key'].includes(node.parent.name.name)) {
|
|
138
141
|
return;
|
|
139
142
|
}
|
|
@@ -24,16 +24,18 @@ var rule = createLintRule({
|
|
|
24
24
|
var contextLocalIdentifier = [];
|
|
25
25
|
return {
|
|
26
26
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
contextLocalIdentifier.push(local.name);
|
|
35
|
-
}
|
|
27
|
+
var _node$specifiers;
|
|
28
|
+
var buttonGroupIdentifier = (_node$specifiers = node.specifiers) === null || _node$specifiers === void 0 ? void 0 : _node$specifiers.filter(function (spec) {
|
|
29
|
+
if (node.source.value === '@atlaskit/button') {
|
|
30
|
+
var _spec$imported;
|
|
31
|
+
return spec.type === 'ImportSpecifier' && ((_spec$imported = spec.imported) === null || _spec$imported === void 0 ? void 0 : _spec$imported.name) === 'ButtonGroup';
|
|
32
|
+
} else if (node.source.value === '@atlaskit/button/button-group') {
|
|
33
|
+
return spec.type === 'ImportDefaultSpecifier';
|
|
36
34
|
}
|
|
35
|
+
});
|
|
36
|
+
if (buttonGroupIdentifier !== null && buttonGroupIdentifier !== void 0 && buttonGroupIdentifier.length) {
|
|
37
|
+
var local = buttonGroupIdentifier[0].local;
|
|
38
|
+
contextLocalIdentifier.push(local.name);
|
|
37
39
|
}
|
|
38
40
|
},
|
|
39
41
|
JSXElement: function JSXElement(node) {
|
|
@@ -36,6 +36,18 @@ export var isDecendantOfStyleJsxAttribute = function isDecendantOfStyleJsxAttrib
|
|
|
36
36
|
}
|
|
37
37
|
return false;
|
|
38
38
|
};
|
|
39
|
+
export var isDecendantOfSvgElement = function isDecendantOfSvgElement(node) {
|
|
40
|
+
if (isNodeOfType(node, 'JSXElement')) {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
if (node.openingElement.name.name === 'svg') {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (node.parent) {
|
|
47
|
+
return isDecendantOfSvgElement(node.parent);
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
};
|
|
39
51
|
var cssInJsCallees = ['css', 'styled', 'styled2'];
|
|
40
52
|
export var isCssInJsTemplateNode = function isCssInJsTemplateNode(node) {
|
|
41
53
|
return (node === null || node === void 0 ? void 0 : node.type) === 'TaggedTemplateExpression' && node.tag.type === 'MemberExpression' && node.tag.object.type === 'Identifier' && node.tag.object.name === 'styled';
|
|
@@ -4,6 +4,7 @@ export declare const isDecendantOfGlobalToken: (node: EslintNode) => boolean;
|
|
|
4
4
|
export declare const isDecendantOfType: (node: Rule.Node, type: Rule.Node['type'], skipNode?: boolean) => boolean;
|
|
5
5
|
export declare const isPropertyKey: (node: Rule.Node) => boolean;
|
|
6
6
|
export declare const isDecendantOfStyleJsxAttribute: (node: Rule.Node) => boolean;
|
|
7
|
+
export declare const isDecendantOfSvgElement: (node: Rule.Node) => boolean;
|
|
7
8
|
export declare const isCssInJsTemplateNode: (node?: Expression | null) => node is TaggedTemplateExpression;
|
|
8
9
|
export declare const isCssInJsCallNode: (node?: Expression | null) => node is CallExpression;
|
|
9
10
|
export declare const isCssInJsObjectNode: (node?: Expression | null) => node is CallExpression;
|
|
@@ -4,6 +4,7 @@ export declare const isDecendantOfGlobalToken: (node: EslintNode) => boolean;
|
|
|
4
4
|
export declare const isDecendantOfType: (node: Rule.Node, type: Rule.Node['type'], skipNode?: boolean) => boolean;
|
|
5
5
|
export declare const isPropertyKey: (node: Rule.Node) => boolean;
|
|
6
6
|
export declare const isDecendantOfStyleJsxAttribute: (node: Rule.Node) => boolean;
|
|
7
|
+
export declare const isDecendantOfSvgElement: (node: Rule.Node) => boolean;
|
|
7
8
|
export declare const isCssInJsTemplateNode: (node?: Expression | null) => node is TaggedTemplateExpression;
|
|
8
9
|
export declare const isCssInJsCallNode: (node?: Expression | null) => node is CallExpression;
|
|
9
10
|
export declare const isCssInJsObjectNode: (node?: Expression | null) => node is CallExpression;
|
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.25.1",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|