@atlaskit/eslint-plugin-ui-styling-standard 0.11.3 → 0.11.4
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 +144 -53
- package/constellation/no-unsafe-values/usage.mdx +1 -1
- package/dist/cjs/rules/no-important-styles/index.js +41 -29
- package/dist/es2019/rules/no-important-styles/index.js +28 -30
- package/dist/esm/rules/no-important-styles/index.js +42 -30
- package/package.json +1 -1
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +16 -0
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +22 -9
- package/src/rules/no-important-styles/index.tsx +32 -37
- package/src/rules/no-unsafe-values/README.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,212 +1,303 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.11.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#93427](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/93427)
|
|
8
|
+
[`d6d428f334b0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d6d428f334b0) -
|
|
9
|
+
The `no-important-styles` rule now checks template literal values in style objects
|
|
10
|
+
|
|
3
11
|
## 0.11.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
7
|
-
-
|
|
15
|
+
- [#95279](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/95279)
|
|
16
|
+
[`813a0e8d6227`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/813a0e8d6227) -
|
|
17
|
+
Deprecating @repo/internal/compiled/selectors ESlint rule
|
|
8
18
|
|
|
9
19
|
## 0.11.2
|
|
10
20
|
|
|
11
21
|
### Patch Changes
|
|
12
22
|
|
|
13
|
-
-
|
|
23
|
+
- [#94765](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94765)
|
|
24
|
+
[`8e5a3bddb686`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8e5a3bddb686) -
|
|
25
|
+
Adding no imported style values ESlint rule
|
|
14
26
|
|
|
15
27
|
## 0.11.1
|
|
16
28
|
|
|
17
29
|
### Patch Changes
|
|
18
30
|
|
|
19
|
-
-
|
|
31
|
+
- [#92963](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92963)
|
|
32
|
+
[`1bb8557fb0b6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1bb8557fb0b6) -
|
|
33
|
+
Added no-exported-styles eslint rule to disallow exports of css, cssMap, keyframes, styled and
|
|
34
|
+
xcss styling
|
|
20
35
|
|
|
21
36
|
## 0.11.0
|
|
22
37
|
|
|
23
38
|
### Minor Changes
|
|
24
39
|
|
|
25
|
-
-
|
|
40
|
+
- [#87213](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87213)
|
|
41
|
+
[`fbfa5a58cf39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fbfa5a58cf39) -
|
|
42
|
+
Adds `no-unsafe-values` rule, which forbids most dynamic styling in
|
|
43
|
+
`css`/`styled`/`keyframes`/`cssMap`/`xcss` function calls. This includes object spreading,
|
|
44
|
+
function calls, and so on.
|
|
26
45
|
|
|
27
46
|
### Patch Changes
|
|
28
47
|
|
|
29
|
-
-
|
|
48
|
+
- Updated dependencies
|
|
30
49
|
|
|
31
50
|
## 0.10.0
|
|
32
51
|
|
|
33
52
|
### Minor Changes
|
|
34
53
|
|
|
35
|
-
-
|
|
54
|
+
- [#91611](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91611)
|
|
55
|
+
[`943056d22c36`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/943056d22c36) -
|
|
56
|
+
Add `no-dynamic-styles` rule which blocks function expressions as values in style declarations.
|
|
36
57
|
|
|
37
58
|
## 0.9.1
|
|
38
59
|
|
|
39
60
|
### Patch Changes
|
|
40
61
|
|
|
41
|
-
-
|
|
62
|
+
- [#90977](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/90977)
|
|
63
|
+
[`becda03f375e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/becda03f375e) -
|
|
64
|
+
Create eslint rule to enforce style prop usage by disallowing passing static css values
|
|
42
65
|
|
|
43
66
|
## 0.9.0
|
|
44
67
|
|
|
45
68
|
### Minor Changes
|
|
46
69
|
|
|
47
|
-
-
|
|
70
|
+
- [#91840](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91840)
|
|
71
|
+
[`997a3d2d0ca0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/997a3d2d0ca0) -
|
|
72
|
+
Add `no-array-arguments` rule which prevents passing array arguments to style declaration
|
|
73
|
+
functions.
|
|
48
74
|
|
|
49
75
|
### Patch Changes
|
|
50
76
|
|
|
51
|
-
-
|
|
77
|
+
- Updated dependencies
|
|
52
78
|
|
|
53
79
|
## 0.8.4
|
|
54
80
|
|
|
55
81
|
### Patch Changes
|
|
56
82
|
|
|
57
|
-
-
|
|
83
|
+
- [#89936](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/89936)
|
|
84
|
+
[`eb8f66c5d0f3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eb8f66c5d0f3) -
|
|
85
|
+
Add @atlaskit/eslint-plugin-ui-styling-standard to the internal Atlassian push model.
|
|
58
86
|
|
|
59
87
|
## 0.8.3
|
|
60
88
|
|
|
61
89
|
### Patch Changes
|
|
62
90
|
|
|
63
|
-
-
|
|
91
|
+
- [#87496](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87496)
|
|
92
|
+
[`d5b439e94043`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d5b439e94043) -
|
|
93
|
+
Improve coverage of `convert-props-syntax` rule. Previously cases such as `css()` and
|
|
94
|
+
`styled(BaseComponent)()` were not covered by the rule.
|
|
64
95
|
|
|
65
96
|
## 0.8.2
|
|
66
97
|
|
|
67
98
|
### Patch Changes
|
|
68
99
|
|
|
69
|
-
-
|
|
100
|
+
- [#88753](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88753)
|
|
101
|
+
[`df5cbd4957ea`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/df5cbd4957ea) -
|
|
102
|
+
Fixed no nested selectors rule to skip @ queries, cssMap and keyFrames calls
|
|
70
103
|
|
|
71
104
|
## 0.8.1
|
|
72
105
|
|
|
73
106
|
### Patch Changes
|
|
74
107
|
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
-
|
|
108
|
+
- [#88029](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88029)
|
|
109
|
+
[`01d74d2899d5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/01d74d2899d5) -
|
|
110
|
+
Disabled ESlint rule convert-props-syntax on .attrs() calls
|
|
111
|
+
- [#87476](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87476)
|
|
112
|
+
[`af296d200ad2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/af296d200ad2) -
|
|
113
|
+
Internal refactoring to use `getCreateLintRule` from `@atlaskit/eslint-utils`
|
|
114
|
+
- Updated dependencies
|
|
78
115
|
|
|
79
116
|
## 0.8.0
|
|
80
117
|
|
|
81
118
|
### Minor Changes
|
|
82
119
|
|
|
83
|
-
-
|
|
120
|
+
- [#87972](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87972)
|
|
121
|
+
[`1f420b2c4a9f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1f420b2c4a9f) -
|
|
122
|
+
The `@atlaskit/design-system/no-styled-tagged-template-expression` rule will now lint against
|
|
123
|
+
`styled-components` by default in the preset configurations.
|
|
84
124
|
|
|
85
125
|
### Patch Changes
|
|
86
126
|
|
|
87
|
-
-
|
|
127
|
+
- [#86779](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86779)
|
|
128
|
+
[`4b4bbf195e39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4b4bbf195e39) -
|
|
129
|
+
Created no nested selectors eslint rule to prevent setting styles for child elements
|
|
88
130
|
|
|
89
131
|
## 0.7.2
|
|
90
132
|
|
|
91
133
|
### Patch Changes
|
|
92
134
|
|
|
93
|
-
-
|
|
94
|
-
-
|
|
135
|
+
- [#86638](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86638)
|
|
136
|
+
[`f003f07e88e1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f003f07e88e1) -
|
|
137
|
+
Internal refactoring to use a shared `@atlaskit/eslint-utils` package
|
|
138
|
+
- Updated dependencies
|
|
95
139
|
|
|
96
140
|
## 0.7.1
|
|
97
141
|
|
|
98
142
|
### Patch Changes
|
|
99
143
|
|
|
100
|
-
-
|
|
144
|
+
- [#84413](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84413)
|
|
145
|
+
[`2860b53c90d9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2860b53c90d9) -
|
|
146
|
+
Added eslint rule to block @container queries in css styling
|
|
101
147
|
|
|
102
148
|
## 0.7.0
|
|
103
149
|
|
|
104
150
|
### Minor Changes
|
|
105
151
|
|
|
106
|
-
-
|
|
152
|
+
- [#83454](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83454)
|
|
153
|
+
[`be8b7ad6ff8e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/be8b7ad6ff8e) -
|
|
154
|
+
Remove name autofixer from `consistent-css-prop-usage`. Variables for css / xcss / cssMap
|
|
155
|
+
functions will no longer be required to end with "Styles".
|
|
107
156
|
|
|
108
|
-
|
|
157
|
+
[BREAKING] Some rule options have been changed:
|
|
109
158
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
159
|
+
- `fixNamesOnly` and `autoFixNames` have been removed, as there is no longer an autofixer that
|
|
160
|
+
enforces variable names.
|
|
161
|
+
- If you use `fixNamesOnly: true`, we recommend switching to using `autoFix: false`.
|
|
162
|
+
- Users of the `autoFixNames` option should remove this from their configuration.
|
|
163
|
+
- `autoFix` option has been added. This controls whether the remaining autofixers should run
|
|
164
|
+
or not (e.g. hoisting `css` function calls, wrapping objects in `css` function calls), and
|
|
165
|
+
is `true` by default.
|
|
114
166
|
|
|
115
167
|
## 0.6.3
|
|
116
168
|
|
|
117
169
|
### Patch Changes
|
|
118
170
|
|
|
119
|
-
-
|
|
171
|
+
- [#83463](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83463)
|
|
172
|
+
[`fee29cf1335a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fee29cf1335a) -
|
|
173
|
+
Extend convert-props-syntax to Emotion as well as it has a type issue.
|
|
120
174
|
|
|
121
175
|
## 0.6.2
|
|
122
176
|
|
|
123
177
|
### Patch Changes
|
|
124
178
|
|
|
125
|
-
-
|
|
179
|
+
- [#83116](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/83116)
|
|
180
|
+
[`8d4e99057fe0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d4e99057fe0) -
|
|
181
|
+
Upgrade Typescript from `4.9.5` to `5.4.2`
|
|
126
182
|
|
|
127
183
|
## 0.6.1
|
|
128
184
|
|
|
129
185
|
### Patch Changes
|
|
130
186
|
|
|
131
|
-
-
|
|
132
|
-
|
|
187
|
+
- [#80129](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80129)
|
|
188
|
+
[`dc0ce9161fc1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/dc0ce9161fc1) -
|
|
189
|
+
Add `convert-prop-syntax` to convert invalid `styled-components` props syntax to valid
|
|
190
|
+
`styled-components` props syntax.
|
|
191
|
+
- [#79686](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79686)
|
|
192
|
+
[`7dc7cf06a8b9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7dc7cf06a8b9) -
|
|
193
|
+
Bump @compiled/react to v0.17.0
|
|
133
194
|
|
|
134
195
|
## 0.6.0
|
|
135
196
|
|
|
136
197
|
### Minor Changes
|
|
137
198
|
|
|
138
|
-
-
|
|
199
|
+
- [#81459](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81459)
|
|
200
|
+
[`08abd3b15614`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/08abd3b15614) -
|
|
201
|
+
Adds `no-classname-prop` rule which prevents the use of `className` in JSX.
|
|
139
202
|
|
|
140
203
|
## 0.5.2
|
|
141
204
|
|
|
142
205
|
### Patch Changes
|
|
143
206
|
|
|
144
|
-
-
|
|
207
|
+
- [#81702](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81702)
|
|
208
|
+
[`04e7850f449c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/04e7850f449c) -
|
|
209
|
+
Adding a missing LICENSE for this package, updating from "UNLICENSED" to make it clear this is
|
|
210
|
+
available for use.
|
|
145
211
|
|
|
146
212
|
## 0.5.1
|
|
147
213
|
|
|
148
214
|
### Patch Changes
|
|
149
215
|
|
|
150
|
-
-
|
|
216
|
+
- [#81166](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/81166)
|
|
217
|
+
[`a249a1bd29a6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a249a1bd29a6) -
|
|
218
|
+
Upgrade ESLint to version 8
|
|
151
219
|
|
|
152
220
|
## 0.5.0
|
|
153
221
|
|
|
154
222
|
### Minor Changes
|
|
155
223
|
|
|
156
|
-
-
|
|
224
|
+
- [#80523](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/80523)
|
|
225
|
+
[`1fbc903e5b7b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1fbc903e5b7b) -
|
|
226
|
+
Adds `no-important-styles` rule which prevents the use of `!important` flags in style
|
|
227
|
+
declarations.
|
|
157
228
|
|
|
158
229
|
## 0.4.1
|
|
159
230
|
|
|
160
231
|
### Patch Changes
|
|
161
232
|
|
|
162
|
-
-
|
|
233
|
+
- [#76885](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76885)
|
|
234
|
+
[`06030bc18dd4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/06030bc18dd4) -
|
|
235
|
+
Disable `styled-components` handling for `no-styled-tagged-template-expression` rule, due to
|
|
236
|
+
edge case where props are converted to output that fails typechecking.
|
|
163
237
|
|
|
164
238
|
## 0.4.0
|
|
165
239
|
|
|
166
240
|
### Minor Changes
|
|
167
241
|
|
|
168
|
-
-
|
|
242
|
+
- [#75600](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75600)
|
|
243
|
+
[`8875d9de2e5d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8875d9de2e5d) -
|
|
244
|
+
Migrates the ESLint rule from `@atlaskit/design-system/local-cx-xcss` to
|
|
245
|
+
`@atlaskit/ui-styling-standard/local-cx-xcss` and overhauls the codegen to enable better
|
|
246
|
+
documentation and rule distribution.
|
|
169
247
|
|
|
170
248
|
## 0.3.0
|
|
171
249
|
|
|
172
250
|
### Minor Changes
|
|
173
251
|
|
|
174
|
-
-
|
|
252
|
+
- [#74981](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/74981)
|
|
253
|
+
[`842300de03a1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/842300de03a1) -
|
|
254
|
+
Add the following rules:
|
|
175
255
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
256
|
+
- `consistent-css-prop-usage`: Ensures consistency with `css` and `xcss` prop usages
|
|
257
|
+
- `no-empty-styled-expression`: Forbids any styled expression to be used when passing empty
|
|
258
|
+
arguments to styled.div() (or other JSX elements).
|
|
259
|
+
- `no-exported-css`: Forbid exporting `css` function calls.
|
|
260
|
+
- `no-exported-keyframes`: Forbid exporting `keyframes` function calls.
|
|
261
|
+
- `no-invalid-css-map`: Checks the validity of a CSS map created through cssMap.
|
|
181
262
|
|
|
182
|
-
-
|
|
263
|
+
- [#72983](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/72983)
|
|
264
|
+
[`878065bfc4c0`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/878065bfc4c0) -
|
|
265
|
+
Adds the following rules to the recommended preset:
|
|
183
266
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
267
|
+
- `@atlaskit/design-system/no-css-tagged-template-expression`
|
|
268
|
+
- `@atlaskit/design-system/no-keyframes-tagged-template-expression`
|
|
269
|
+
- `@atlaskit/design-system/no-styled-tagged-template-expression`
|
|
187
270
|
|
|
188
271
|
### Patch Changes
|
|
189
272
|
|
|
190
|
-
-
|
|
273
|
+
- [#75152](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75152)
|
|
274
|
+
[`c16a175d372b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c16a175d372b) -
|
|
275
|
+
Change 'error' to 'warn' to unbreak AFM platform
|
|
191
276
|
|
|
192
277
|
## 0.2.1
|
|
193
278
|
|
|
194
279
|
### Patch Changes
|
|
195
280
|
|
|
196
|
-
-
|
|
281
|
+
- [#71319](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/71319)
|
|
282
|
+
[`d716e2b5e102`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d716e2b5e102) -
|
|
283
|
+
Ensures all dependencies are properly defined
|
|
197
284
|
|
|
198
285
|
## 0.2.0
|
|
199
286
|
|
|
200
287
|
### Minor Changes
|
|
201
288
|
|
|
202
|
-
-
|
|
289
|
+
- [#69723](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69723)
|
|
290
|
+
[`06cd0f04fefb`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/06cd0f04fefb) -
|
|
291
|
+
Adds the following rules to the recommended config:
|
|
203
292
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
293
|
+
- `local-cx-xcss` - Ensures the `cx()` function is only used within the `xcss` prop
|
|
294
|
+
- `no-supress-xcss` - Disallows supressing type violations when using the `xcss` prop
|
|
295
|
+
- `no-js-xcss` - Disallows using `xcss` prop inside JavaScript files
|
|
207
296
|
|
|
208
297
|
## 0.1.0
|
|
209
298
|
|
|
210
299
|
### Minor Changes
|
|
211
300
|
|
|
212
|
-
-
|
|
301
|
+
- [#63960](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/63960)
|
|
302
|
+
[`8e3774cada83`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8e3774cada83) -
|
|
303
|
+
Created the design system styling standard package
|
|
@@ -5,9 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _esquery = _interopRequireDefault(require("esquery"));
|
|
9
9
|
var _createRule = require("../utils/create-rule");
|
|
10
10
|
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
11
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
14
|
var schema = [{
|
|
12
15
|
type: 'object',
|
|
13
16
|
properties: {
|
|
@@ -40,36 +43,45 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
40
43
|
CallExpression: function CallExpression(node) {
|
|
41
44
|
var _context$getScope = context.getScope(),
|
|
42
45
|
references = _context$getScope.references;
|
|
43
|
-
if ((0, _isSupportedImport.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
67
|
-
*/
|
|
68
|
-
fallback: 'iteration'
|
|
69
|
-
});
|
|
46
|
+
if (!(0, _isSupportedImport.hasStyleObjectArguments)(node.callee, references, importSources)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
var matches = (0, _esquery.default)(node, 'Property');
|
|
50
|
+
var _iterator = _createForOfIteratorHelper(matches),
|
|
51
|
+
_step;
|
|
52
|
+
try {
|
|
53
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
54
|
+
var match = _step.value;
|
|
55
|
+
if (match.type !== 'Property') {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (isImportant(match.value)) {
|
|
59
|
+
context.report({
|
|
60
|
+
node: match.value,
|
|
61
|
+
messageId: 'no-important-styles'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch (err) {
|
|
66
|
+
_iterator.e(err);
|
|
67
|
+
} finally {
|
|
68
|
+
_iterator.f();
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
};
|
|
73
72
|
}
|
|
74
73
|
});
|
|
75
|
-
var _default = exports.default = rule;
|
|
74
|
+
var _default = exports.default = rule;
|
|
75
|
+
var importantRegex = /!\s*important\s*$/;
|
|
76
|
+
function isImportant(node) {
|
|
77
|
+
if (node.type === 'Literal') {
|
|
78
|
+
return typeof node.value === 'string' && importantRegex.test(node.value);
|
|
79
|
+
}
|
|
80
|
+
if (node.type === 'TemplateLiteral') {
|
|
81
|
+
var joinedRaw = node.quasis.map(function (element) {
|
|
82
|
+
return element.value.raw;
|
|
83
|
+
}).join('');
|
|
84
|
+
return importantRegex.test(joinedRaw);
|
|
85
|
+
}
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import esquery from 'esquery';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import {
|
|
3
|
+
import { getImportSources, hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
4
|
const schema = [{
|
|
5
5
|
type: 'object',
|
|
6
6
|
properties: {
|
|
@@ -34,36 +34,34 @@ export const rule = createLintRule({
|
|
|
34
34
|
const {
|
|
35
35
|
references
|
|
36
36
|
} = context.getScope();
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
52
|
-
if ((_node$value$value = node.value.value) !== null && _node$value$value !== void 0 && _node$value$value.toString().match(/!\s*important\s*$/gm)) {
|
|
53
|
-
context.report({
|
|
54
|
-
node: node.value,
|
|
55
|
-
messageId: 'no-important-styles'
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
/**
|
|
60
|
-
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
61
|
-
*/
|
|
62
|
-
fallback: 'iteration'
|
|
63
|
-
});
|
|
37
|
+
if (!hasStyleObjectArguments(node.callee, references, importSources)) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const matches = esquery(node, 'Property');
|
|
41
|
+
for (const match of matches) {
|
|
42
|
+
if (match.type !== 'Property') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (isImportant(match.value)) {
|
|
46
|
+
context.report({
|
|
47
|
+
node: match.value,
|
|
48
|
+
messageId: 'no-important-styles'
|
|
49
|
+
});
|
|
50
|
+
}
|
|
64
51
|
}
|
|
65
52
|
}
|
|
66
53
|
};
|
|
67
54
|
}
|
|
68
55
|
});
|
|
69
|
-
export default rule;
|
|
56
|
+
export default rule;
|
|
57
|
+
const importantRegex = /!\s*important\s*$/;
|
|
58
|
+
function isImportant(node) {
|
|
59
|
+
if (node.type === 'Literal') {
|
|
60
|
+
return typeof node.value === 'string' && importantRegex.test(node.value);
|
|
61
|
+
}
|
|
62
|
+
if (node.type === 'TemplateLiteral') {
|
|
63
|
+
const joinedRaw = node.quasis.map(element => element.value.raw).join('');
|
|
64
|
+
return importantRegex.test(joinedRaw);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
import esquery from 'esquery';
|
|
2
5
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import {
|
|
6
|
+
import { getImportSources, hasStyleObjectArguments } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
7
|
var schema = [{
|
|
5
8
|
type: 'object',
|
|
6
9
|
properties: {
|
|
@@ -33,36 +36,45 @@ export var rule = createLintRule({
|
|
|
33
36
|
CallExpression: function CallExpression(node) {
|
|
34
37
|
var _context$getScope = context.getScope(),
|
|
35
38
|
references = _context$getScope.references;
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
60
|
-
*/
|
|
61
|
-
fallback: 'iteration'
|
|
62
|
-
});
|
|
39
|
+
if (!hasStyleObjectArguments(node.callee, references, importSources)) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
var matches = esquery(node, 'Property');
|
|
43
|
+
var _iterator = _createForOfIteratorHelper(matches),
|
|
44
|
+
_step;
|
|
45
|
+
try {
|
|
46
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
47
|
+
var match = _step.value;
|
|
48
|
+
if (match.type !== 'Property') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (isImportant(match.value)) {
|
|
52
|
+
context.report({
|
|
53
|
+
node: match.value,
|
|
54
|
+
messageId: 'no-important-styles'
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} catch (err) {
|
|
59
|
+
_iterator.e(err);
|
|
60
|
+
} finally {
|
|
61
|
+
_iterator.f();
|
|
63
62
|
}
|
|
64
63
|
}
|
|
65
64
|
};
|
|
66
65
|
}
|
|
67
66
|
});
|
|
68
|
-
export default rule;
|
|
67
|
+
export default rule;
|
|
68
|
+
var importantRegex = /!\s*important\s*$/;
|
|
69
|
+
function isImportant(node) {
|
|
70
|
+
if (node.type === 'Literal') {
|
|
71
|
+
return typeof node.value === 'string' && importantRegex.test(node.value);
|
|
72
|
+
}
|
|
73
|
+
if (node.type === 'TemplateLiteral') {
|
|
74
|
+
var joinedRaw = node.quasis.map(function (element) {
|
|
75
|
+
return element.value.raw;
|
|
76
|
+
}).join('');
|
|
77
|
+
return importantRegex.test(joinedRaw);
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
package/package.json
CHANGED
|
@@ -124,5 +124,21 @@ tester.run('no-dynamic-styles', rule, {
|
|
|
124
124
|
`,
|
|
125
125
|
errors: [{ messageId: 'no-dynamic-styles' }],
|
|
126
126
|
},
|
|
127
|
+
{
|
|
128
|
+
name: 'dynamic styles when using styled and overriding another component',
|
|
129
|
+
code: `
|
|
130
|
+
import { styled } from '@compiled/react';
|
|
131
|
+
import { BaseComponent } from './base-component';
|
|
132
|
+
|
|
133
|
+
const Component = styled(BaseComponent)({
|
|
134
|
+
width: props => props.width,
|
|
135
|
+
height: function(props) { return props.height; }
|
|
136
|
+
});
|
|
137
|
+
`,
|
|
138
|
+
errors: [
|
|
139
|
+
{ messageId: 'no-dynamic-styles' },
|
|
140
|
+
{ messageId: 'no-dynamic-styles' },
|
|
141
|
+
],
|
|
142
|
+
},
|
|
127
143
|
],
|
|
128
144
|
});
|
|
@@ -11,7 +11,7 @@ tester.run('no-important-styles', rule, {
|
|
|
11
11
|
});
|
|
12
12
|
`,
|
|
13
13
|
{
|
|
14
|
-
|
|
14
|
+
name: 'custom import sources (subtractive)',
|
|
15
15
|
code: `
|
|
16
16
|
import { css } from '@compiled/react';
|
|
17
17
|
|
|
@@ -28,7 +28,7 @@ tester.run('no-important-styles', rule, {
|
|
|
28
28
|
],
|
|
29
29
|
invalid: [
|
|
30
30
|
{
|
|
31
|
-
|
|
31
|
+
name: 'basic test case',
|
|
32
32
|
code: `
|
|
33
33
|
import { css } from '@compiled/react';
|
|
34
34
|
|
|
@@ -39,7 +39,7 @@ tester.run('no-important-styles', rule, {
|
|
|
39
39
|
errors: [{ messageId: 'no-important-styles' }],
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
|
-
|
|
42
|
+
name: 'whitespace handling',
|
|
43
43
|
code: `
|
|
44
44
|
import { css } from '@compiled/react';
|
|
45
45
|
|
|
@@ -50,7 +50,7 @@ tester.run('no-important-styles', rule, {
|
|
|
50
50
|
errors: [{ messageId: 'no-important-styles' }],
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
|
|
53
|
+
name: 'nesting',
|
|
54
54
|
code: `
|
|
55
55
|
import { css } from '@compiled/react';
|
|
56
56
|
|
|
@@ -68,7 +68,7 @@ tester.run('no-important-styles', rule, {
|
|
|
68
68
|
errors: [{ messageId: 'no-important-styles' }],
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
|
|
71
|
+
name: 'styled API',
|
|
72
72
|
code: `
|
|
73
73
|
import { styled } from '@compiled/react';
|
|
74
74
|
|
|
@@ -86,7 +86,7 @@ tester.run('no-important-styles', rule, {
|
|
|
86
86
|
errors: [{ messageId: 'no-important-styles' }],
|
|
87
87
|
},
|
|
88
88
|
{
|
|
89
|
-
|
|
89
|
+
name: 'keyframes API',
|
|
90
90
|
code: `
|
|
91
91
|
import { keyframes } from '@compiled/react';
|
|
92
92
|
|
|
@@ -102,7 +102,7 @@ tester.run('no-important-styles', rule, {
|
|
|
102
102
|
errors: [{ messageId: 'no-important-styles' }],
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
|
-
|
|
105
|
+
name: 'cssMap API',
|
|
106
106
|
code: `
|
|
107
107
|
import { cssMap } from '@compiled/react';
|
|
108
108
|
|
|
@@ -114,7 +114,7 @@ tester.run('no-important-styles', rule, {
|
|
|
114
114
|
errors: [{ messageId: 'no-important-styles' }],
|
|
115
115
|
},
|
|
116
116
|
{
|
|
117
|
-
|
|
117
|
+
name: 'xcss API',
|
|
118
118
|
code: `
|
|
119
119
|
import { xcss } from '@atlaskit/primitives';
|
|
120
120
|
|
|
@@ -125,7 +125,7 @@ tester.run('no-important-styles', rule, {
|
|
|
125
125
|
errors: [{ messageId: 'no-important-styles' }],
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
|
-
|
|
128
|
+
name: 'custom import sources (additive)',
|
|
129
129
|
code: `
|
|
130
130
|
import { css } from 'custom-library';
|
|
131
131
|
|
|
@@ -136,5 +136,18 @@ tester.run('no-important-styles', rule, {
|
|
|
136
136
|
errors: [{ messageId: 'no-important-styles' }],
|
|
137
137
|
options: [{ importSources: ['custom-library'] }],
|
|
138
138
|
},
|
|
139
|
+
{
|
|
140
|
+
name: 'template string',
|
|
141
|
+
code: `
|
|
142
|
+
import { css } from '@compiled/react';
|
|
143
|
+
|
|
144
|
+
const color = 'red';
|
|
145
|
+
|
|
146
|
+
const styles = css({
|
|
147
|
+
color: \`\${color}!important\`
|
|
148
|
+
});
|
|
149
|
+
`,
|
|
150
|
+
errors: [{ messageId: 'no-important-styles' }],
|
|
151
|
+
},
|
|
139
152
|
],
|
|
140
153
|
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import esquery from 'esquery';
|
|
2
|
+
|
|
3
|
+
import type { Property } from 'estree';
|
|
2
4
|
|
|
3
5
|
import { createLintRule } from '../utils/create-rule';
|
|
4
6
|
import {
|
|
5
|
-
isCss,
|
|
6
7
|
getImportSources,
|
|
7
|
-
|
|
8
|
-
isKeyframes,
|
|
9
|
-
isCssMap,
|
|
10
|
-
isXcss,
|
|
8
|
+
hasStyleObjectArguments,
|
|
11
9
|
} from '@atlaskit/eslint-utils/is-supported-import';
|
|
12
10
|
import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
|
|
13
11
|
|
|
@@ -46,39 +44,22 @@ export const rule = createLintRule({
|
|
|
46
44
|
CallExpression(node) {
|
|
47
45
|
const { references } = context.getScope();
|
|
48
46
|
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
isKeyframes(node.callee, references, importSources) ||
|
|
53
|
-
isCssMap(node.callee, references, importSources) ||
|
|
54
|
-
isXcss(node.callee, references, importSources)
|
|
55
|
-
) {
|
|
56
|
-
estraverse.traverse(node, {
|
|
57
|
-
enter(node) {
|
|
58
|
-
if (node.type !== 'Property') {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
47
|
+
if (!hasStyleObjectArguments(node.callee, references, importSources)) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
61
50
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
51
|
+
const matches = esquery(node, 'Property');
|
|
52
|
+
for (const match of matches) {
|
|
53
|
+
if (match.type !== 'Property') {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
65
56
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
node: node.value,
|
|
73
|
-
messageId: 'no-important-styles',
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
79
|
-
*/
|
|
80
|
-
fallback: 'iteration',
|
|
81
|
-
});
|
|
57
|
+
if (isImportant(match.value)) {
|
|
58
|
+
context.report({
|
|
59
|
+
node: match.value,
|
|
60
|
+
messageId: 'no-important-styles',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
82
63
|
}
|
|
83
64
|
},
|
|
84
65
|
};
|
|
@@ -86,3 +67,17 @@ export const rule = createLintRule({
|
|
|
86
67
|
});
|
|
87
68
|
|
|
88
69
|
export default rule;
|
|
70
|
+
|
|
71
|
+
const importantRegex = /!\s*important\s*$/;
|
|
72
|
+
function isImportant(node: Property['value']): boolean {
|
|
73
|
+
if (node.type === 'Literal') {
|
|
74
|
+
return typeof node.value === 'string' && importantRegex.test(node.value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (node.type === 'TemplateLiteral') {
|
|
78
|
+
const joinedRaw = node.quasis.map((element) => element.value.raw).join('');
|
|
79
|
+
return importantRegex.test(joinedRaw);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return false;
|
|
83
|
+
}
|