@atlaskit/eslint-plugin-design-system 13.1.1 → 13.1.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
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#131298](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/131298)
|
|
8
|
+
[`13ebcc2fd6d07`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/13ebcc2fd6d07) -
|
|
9
|
+
Update `use-modal-dialog-close-button` rule to include code within expression containers and
|
|
10
|
+
logical expressions.
|
|
11
|
+
|
|
3
12
|
## 13.1.1
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -77,34 +77,58 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
77
77
|
}
|
|
78
78
|
var modalHeaderNode = null;
|
|
79
79
|
var closeButtonNode = null;
|
|
80
|
-
var
|
|
80
|
+
var checkNode = function checkNode(node) {
|
|
81
|
+
if (modalHeaderNode && closeButtonNode) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Add expression conatiner's body if an expression container
|
|
86
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXExpressionContainer')) {
|
|
87
|
+
if (((0, _eslintCodemodUtils.isNodeOfType)(node.expression, 'ArrowFunctionExpression') || (0, _eslintCodemodUtils.isNodeOfType)(node.expression, 'FunctionExpression')) && (0, _eslintCodemodUtils.isNodeOfType)(node.expression.body, 'JSXElement')) {
|
|
88
|
+
searchNode(node.expression.body, true);
|
|
89
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(node.expression, 'LogicalExpression')) {
|
|
90
|
+
var _node$expression = node.expression,
|
|
91
|
+
left = _node$expression.left,
|
|
92
|
+
right = _node$expression.right;
|
|
93
|
+
[left, right].forEach(function (e) {
|
|
94
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(e, 'JSXElement')) {
|
|
95
|
+
searchNode(e, true);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Skip if not a JSX Element
|
|
102
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Skip if opening element is not an identifier
|
|
107
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.openingElement.name, 'JSXIdentifier')) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// if child is CloseButton, return true
|
|
112
|
+
if (node.openingElement.name.name === closeButtonLocalName) {
|
|
113
|
+
closeButtonNode = node;
|
|
114
|
+
} else if (node.openingElement.name.name === modalHeaderLocalName) {
|
|
115
|
+
modalHeaderNode = node;
|
|
116
|
+
}
|
|
117
|
+
if (node.children) {
|
|
118
|
+
searchNode(node);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var searchNode = function searchNode(node) {
|
|
122
|
+
var searchSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
123
|
+
if (searchSelf) {
|
|
124
|
+
checkNode(node);
|
|
125
|
+
}
|
|
81
126
|
var _iterator = _createForOfIteratorHelper(node.children),
|
|
82
127
|
_step;
|
|
83
128
|
try {
|
|
84
129
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
85
130
|
var child = _step.value;
|
|
86
|
-
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
// Skip if not a JSX Element
|
|
90
|
-
if (!(0, _eslintCodemodUtils.isNodeOfType)(child, 'JSXElement')) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Skip if opening element is not an identifier
|
|
95
|
-
if (!(0, _eslintCodemodUtils.isNodeOfType)(child.openingElement.name, 'JSXIdentifier')) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// if child is CloseButton, return true
|
|
100
|
-
if (child.openingElement.name.name === closeButtonLocalName) {
|
|
101
|
-
closeButtonNode = child;
|
|
102
|
-
} else if (child.openingElement.name.name === modalHeaderLocalName) {
|
|
103
|
-
modalHeaderNode = child;
|
|
104
|
-
}
|
|
105
|
-
if (child.children) {
|
|
106
|
-
_searchChildren(child);
|
|
107
|
-
}
|
|
131
|
+
checkNode(child);
|
|
108
132
|
}
|
|
109
133
|
} catch (err) {
|
|
110
134
|
_iterator.e(err);
|
|
@@ -112,7 +136,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
112
136
|
_iterator.f();
|
|
113
137
|
}
|
|
114
138
|
};
|
|
115
|
-
|
|
139
|
+
searchNode(node);
|
|
116
140
|
|
|
117
141
|
// If there is a close button, skip the rest, as this satisfies the rule.
|
|
118
142
|
if (closeButtonNode) {
|
|
@@ -70,33 +70,57 @@ const rule = createLintRule({
|
|
|
70
70
|
}
|
|
71
71
|
let modalHeaderNode = null;
|
|
72
72
|
let closeButtonNode = null;
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
// Skip if not a JSX Element
|
|
79
|
-
if (!isNodeOfType(child, 'JSXElement')) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
73
|
+
const checkNode = node => {
|
|
74
|
+
if (modalHeaderNode && closeButtonNode) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
82
77
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
// Add expression conatiner's body if an expression container
|
|
79
|
+
if (isNodeOfType(node, 'JSXExpressionContainer')) {
|
|
80
|
+
if ((isNodeOfType(node.expression, 'ArrowFunctionExpression') || isNodeOfType(node.expression, 'FunctionExpression')) && isNodeOfType(node.expression.body, 'JSXElement')) {
|
|
81
|
+
searchNode(node.expression.body, true);
|
|
82
|
+
} else if (isNodeOfType(node.expression, 'LogicalExpression')) {
|
|
83
|
+
const {
|
|
84
|
+
left,
|
|
85
|
+
right
|
|
86
|
+
} = node.expression;
|
|
87
|
+
[left, right].forEach(e => {
|
|
88
|
+
if (isNodeOfType(e, 'JSXElement')) {
|
|
89
|
+
searchNode(e, true);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
86
92
|
}
|
|
93
|
+
}
|
|
87
94
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
// Skip if not a JSX Element
|
|
96
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Skip if opening element is not an identifier
|
|
101
|
+
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// if child is CloseButton, return true
|
|
106
|
+
if (node.openingElement.name.name === closeButtonLocalName) {
|
|
107
|
+
closeButtonNode = node;
|
|
108
|
+
} else if (node.openingElement.name.name === modalHeaderLocalName) {
|
|
109
|
+
modalHeaderNode = node;
|
|
110
|
+
}
|
|
111
|
+
if (node.children) {
|
|
112
|
+
searchNode(node);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const searchNode = (node, searchSelf = false) => {
|
|
116
|
+
if (searchSelf) {
|
|
117
|
+
checkNode(node);
|
|
118
|
+
}
|
|
119
|
+
for (let child of node.children) {
|
|
120
|
+
checkNode(child);
|
|
97
121
|
}
|
|
98
122
|
};
|
|
99
|
-
|
|
123
|
+
searchNode(node);
|
|
100
124
|
|
|
101
125
|
// If there is a close button, skip the rest, as this satisfies the rule.
|
|
102
126
|
if (closeButtonNode) {
|
|
@@ -73,34 +73,58 @@ var rule = createLintRule({
|
|
|
73
73
|
}
|
|
74
74
|
var modalHeaderNode = null;
|
|
75
75
|
var closeButtonNode = null;
|
|
76
|
-
var
|
|
76
|
+
var checkNode = function checkNode(node) {
|
|
77
|
+
if (modalHeaderNode && closeButtonNode) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Add expression conatiner's body if an expression container
|
|
82
|
+
if (isNodeOfType(node, 'JSXExpressionContainer')) {
|
|
83
|
+
if ((isNodeOfType(node.expression, 'ArrowFunctionExpression') || isNodeOfType(node.expression, 'FunctionExpression')) && isNodeOfType(node.expression.body, 'JSXElement')) {
|
|
84
|
+
searchNode(node.expression.body, true);
|
|
85
|
+
} else if (isNodeOfType(node.expression, 'LogicalExpression')) {
|
|
86
|
+
var _node$expression = node.expression,
|
|
87
|
+
left = _node$expression.left,
|
|
88
|
+
right = _node$expression.right;
|
|
89
|
+
[left, right].forEach(function (e) {
|
|
90
|
+
if (isNodeOfType(e, 'JSXElement')) {
|
|
91
|
+
searchNode(e, true);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Skip if not a JSX Element
|
|
98
|
+
if (!isNodeOfType(node, 'JSXElement')) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Skip if opening element is not an identifier
|
|
103
|
+
if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// if child is CloseButton, return true
|
|
108
|
+
if (node.openingElement.name.name === closeButtonLocalName) {
|
|
109
|
+
closeButtonNode = node;
|
|
110
|
+
} else if (node.openingElement.name.name === modalHeaderLocalName) {
|
|
111
|
+
modalHeaderNode = node;
|
|
112
|
+
}
|
|
113
|
+
if (node.children) {
|
|
114
|
+
searchNode(node);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var searchNode = function searchNode(node) {
|
|
118
|
+
var searchSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
119
|
+
if (searchSelf) {
|
|
120
|
+
checkNode(node);
|
|
121
|
+
}
|
|
77
122
|
var _iterator = _createForOfIteratorHelper(node.children),
|
|
78
123
|
_step;
|
|
79
124
|
try {
|
|
80
125
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
81
126
|
var child = _step.value;
|
|
82
|
-
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
// Skip if not a JSX Element
|
|
86
|
-
if (!isNodeOfType(child, 'JSXElement')) {
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Skip if opening element is not an identifier
|
|
91
|
-
if (!isNodeOfType(child.openingElement.name, 'JSXIdentifier')) {
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// if child is CloseButton, return true
|
|
96
|
-
if (child.openingElement.name.name === closeButtonLocalName) {
|
|
97
|
-
closeButtonNode = child;
|
|
98
|
-
} else if (child.openingElement.name.name === modalHeaderLocalName) {
|
|
99
|
-
modalHeaderNode = child;
|
|
100
|
-
}
|
|
101
|
-
if (child.children) {
|
|
102
|
-
_searchChildren(child);
|
|
103
|
-
}
|
|
127
|
+
checkNode(child);
|
|
104
128
|
}
|
|
105
129
|
} catch (err) {
|
|
106
130
|
_iterator.e(err);
|
|
@@ -108,7 +132,7 @@ var rule = createLintRule({
|
|
|
108
132
|
_iterator.f();
|
|
109
133
|
}
|
|
110
134
|
};
|
|
111
|
-
|
|
135
|
+
searchNode(node);
|
|
112
136
|
|
|
113
137
|
// If there is a close button, skip the rest, as this satisfies the rule.
|
|
114
138
|
if (closeButtonNode) {
|
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.1.
|
|
4
|
+
"version": "13.1.2",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"publishConfig": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@types/estraverse": "^5.1.7",
|
|
73
73
|
"@types/json-schema": "^7.0.15",
|
|
74
74
|
"eslint": "^8.57.0",
|
|
75
|
-
"jscodeshift": "^0.
|
|
75
|
+
"jscodeshift": "^17.0.0",
|
|
76
76
|
"outdent": "^0.5.0",
|
|
77
77
|
"react": "^18.2.0",
|
|
78
78
|
"ts-jest": "^29.2.2",
|