@atlaskit/eslint-plugin-design-system 9.3.0 → 9.3.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 +6 -0
- package/dist/cjs/rules/utils/create-no-tagged-template-expression-rule/index.js +5 -7
- package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +21 -9
- package/dist/esm/rules/utils/create-no-tagged-template-expression-rule/index.js +6 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 9.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#88012](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88012) [`c478a4d80fc9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c478a4d80fc9) - The `no-*-tagged-template-expression` rules will no longer autofix usages with mixins in nested selectors. This is because they were producing an array syntax that is not valid in compiled or styled-components.
|
|
8
|
+
|
|
3
9
|
## 9.3.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -80,7 +80,7 @@ var createNoTaggedTemplateExpressionRule = exports.createNoTaggedTemplateExpress
|
|
|
80
80
|
return _context.abrupt("return");
|
|
81
81
|
case 11:
|
|
82
82
|
args = (0, _toArguments.toArguments)(source, quasi);
|
|
83
|
-
if (!
|
|
83
|
+
if (!args.some(hasNestedSelectorWithMultipleArguments)) {
|
|
84
84
|
_context.next = 14;
|
|
85
85
|
break;
|
|
86
86
|
}
|
|
@@ -140,19 +140,17 @@ var createNoTaggedTemplateExpressionRule = exports.createNoTaggedTemplateExpress
|
|
|
140
140
|
};
|
|
141
141
|
};
|
|
142
142
|
};
|
|
143
|
-
function
|
|
143
|
+
function hasNestedSelectorWithMultipleArguments(arg) {
|
|
144
144
|
if (arg.type === 'literal' || arg.type === 'expression' || arg.type === 'declaration') {
|
|
145
145
|
return false;
|
|
146
146
|
}
|
|
147
|
-
if (arg.type === 'rule' && arg.declarations.length > 1
|
|
148
|
-
return node.type === 'expression';
|
|
149
|
-
})) {
|
|
147
|
+
if (arg.type === 'rule' && arg.declarations.length > 1) {
|
|
150
148
|
return true;
|
|
151
149
|
}
|
|
152
150
|
if (arg.type === 'block') {
|
|
153
|
-
return arg.blocks.some(
|
|
151
|
+
return arg.blocks.some(hasNestedSelectorWithMultipleArguments);
|
|
154
152
|
}
|
|
155
153
|
if (arg.type === 'rule') {
|
|
156
|
-
return arg.declarations.some(
|
|
154
|
+
return arg.declarations.some(hasNestedSelectorWithMultipleArguments);
|
|
157
155
|
}
|
|
158
156
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3
3
|
|
|
4
4
|
import esquery from 'esquery';
|
|
5
|
-
import { getImportSources, isEmotion
|
|
5
|
+
import { getImportSources, isEmotion } from '@atlaskit/eslint-utils/is-supported-import';
|
|
6
6
|
import { generate } from './generate';
|
|
7
7
|
import { getTaggedTemplateExpressionOffset } from './get-tagged-template-expression-offset';
|
|
8
8
|
import { toArguments } from './to-arguments';
|
|
@@ -60,11 +60,23 @@ export const createNoTaggedTemplateExpressionRule = (isUsage, messageId) => cont
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
const args = toArguments(source, quasi);
|
|
63
|
-
if (
|
|
63
|
+
if (args.some(hasNestedSelectorWithMultipleArguments)) {
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
65
|
+
* We don't want to autofix if we would produce an array value, for example:
|
|
66
|
+
* ```
|
|
67
|
+
* styled.div({
|
|
68
|
+
* ':hover': [
|
|
69
|
+
* mixin,
|
|
70
|
+
* {
|
|
71
|
+
* color: 'red'
|
|
72
|
+
* }
|
|
73
|
+
* ]
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* This should only occur if there is a mixin in a nested selector.
|
|
78
|
+
*
|
|
79
|
+
* The array syntax is only supported by emotion.
|
|
68
80
|
*/
|
|
69
81
|
return;
|
|
70
82
|
}
|
|
@@ -136,17 +148,17 @@ export const createNoTaggedTemplateExpressionRule = (isUsage, messageId) => cont
|
|
|
136
148
|
}
|
|
137
149
|
};
|
|
138
150
|
};
|
|
139
|
-
function
|
|
151
|
+
function hasNestedSelectorWithMultipleArguments(arg) {
|
|
140
152
|
if (arg.type === 'literal' || arg.type === 'expression' || arg.type === 'declaration') {
|
|
141
153
|
return false;
|
|
142
154
|
}
|
|
143
|
-
if (arg.type === 'rule' && arg.declarations.length > 1
|
|
155
|
+
if (arg.type === 'rule' && arg.declarations.length > 1) {
|
|
144
156
|
return true;
|
|
145
157
|
}
|
|
146
158
|
if (arg.type === 'block') {
|
|
147
|
-
return arg.blocks.some(
|
|
159
|
+
return arg.blocks.some(hasNestedSelectorWithMultipleArguments);
|
|
148
160
|
}
|
|
149
161
|
if (arg.type === 'rule') {
|
|
150
|
-
return arg.declarations.some(
|
|
162
|
+
return arg.declarations.some(hasNestedSelectorWithMultipleArguments);
|
|
151
163
|
}
|
|
152
164
|
}
|
|
@@ -3,7 +3,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
4
|
|
|
5
5
|
import esquery from 'esquery';
|
|
6
|
-
import { getImportSources, isEmotion
|
|
6
|
+
import { getImportSources, isEmotion } from '@atlaskit/eslint-utils/is-supported-import';
|
|
7
7
|
import { generate } from './generate';
|
|
8
8
|
import { getTaggedTemplateExpressionOffset } from './get-tagged-template-expression-offset';
|
|
9
9
|
import { toArguments } from './to-arguments';
|
|
@@ -73,7 +73,7 @@ export var createNoTaggedTemplateExpressionRule = function createNoTaggedTemplat
|
|
|
73
73
|
return _context.abrupt("return");
|
|
74
74
|
case 11:
|
|
75
75
|
args = toArguments(source, quasi);
|
|
76
|
-
if (!
|
|
76
|
+
if (!args.some(hasNestedSelectorWithMultipleArguments)) {
|
|
77
77
|
_context.next = 14;
|
|
78
78
|
break;
|
|
79
79
|
}
|
|
@@ -133,19 +133,17 @@ export var createNoTaggedTemplateExpressionRule = function createNoTaggedTemplat
|
|
|
133
133
|
};
|
|
134
134
|
};
|
|
135
135
|
};
|
|
136
|
-
function
|
|
136
|
+
function hasNestedSelectorWithMultipleArguments(arg) {
|
|
137
137
|
if (arg.type === 'literal' || arg.type === 'expression' || arg.type === 'declaration') {
|
|
138
138
|
return false;
|
|
139
139
|
}
|
|
140
|
-
if (arg.type === 'rule' && arg.declarations.length > 1
|
|
141
|
-
return node.type === 'expression';
|
|
142
|
-
})) {
|
|
140
|
+
if (arg.type === 'rule' && arg.declarations.length > 1) {
|
|
143
141
|
return true;
|
|
144
142
|
}
|
|
145
143
|
if (arg.type === 'block') {
|
|
146
|
-
return arg.blocks.some(
|
|
144
|
+
return arg.blocks.some(hasNestedSelectorWithMultipleArguments);
|
|
147
145
|
}
|
|
148
146
|
if (arg.type === 'rule') {
|
|
149
|
-
return arg.declarations.some(
|
|
147
|
+
return arg.declarations.some(hasNestedSelectorWithMultipleArguments);
|
|
150
148
|
}
|
|
151
149
|
}
|
package/package.json
CHANGED