@atlaskit/eslint-plugin-ui-styling-standard 0.11.2 → 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 +149 -52
- 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,206 +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
|
+
|
|
11
|
+
## 0.11.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
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
|
|
18
|
+
|
|
3
19
|
## 0.11.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
6
22
|
|
|
7
|
-
-
|
|
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
|
|
8
26
|
|
|
9
27
|
## 0.11.1
|
|
10
28
|
|
|
11
29
|
### Patch Changes
|
|
12
30
|
|
|
13
|
-
-
|
|
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
|
|
14
35
|
|
|
15
36
|
## 0.11.0
|
|
16
37
|
|
|
17
38
|
### Minor Changes
|
|
18
39
|
|
|
19
|
-
-
|
|
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.
|
|
20
45
|
|
|
21
46
|
### Patch Changes
|
|
22
47
|
|
|
23
|
-
-
|
|
48
|
+
- Updated dependencies
|
|
24
49
|
|
|
25
50
|
## 0.10.0
|
|
26
51
|
|
|
27
52
|
### Minor Changes
|
|
28
53
|
|
|
29
|
-
-
|
|
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.
|
|
30
57
|
|
|
31
58
|
## 0.9.1
|
|
32
59
|
|
|
33
60
|
### Patch Changes
|
|
34
61
|
|
|
35
|
-
-
|
|
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
|
|
36
65
|
|
|
37
66
|
## 0.9.0
|
|
38
67
|
|
|
39
68
|
### Minor Changes
|
|
40
69
|
|
|
41
|
-
-
|
|
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.
|
|
42
74
|
|
|
43
75
|
### Patch Changes
|
|
44
76
|
|
|
45
|
-
-
|
|
77
|
+
- Updated dependencies
|
|
46
78
|
|
|
47
79
|
## 0.8.4
|
|
48
80
|
|
|
49
81
|
### Patch Changes
|
|
50
82
|
|
|
51
|
-
-
|
|
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.
|
|
52
86
|
|
|
53
87
|
## 0.8.3
|
|
54
88
|
|
|
55
89
|
### Patch Changes
|
|
56
90
|
|
|
57
|
-
-
|
|
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.
|
|
58
95
|
|
|
59
96
|
## 0.8.2
|
|
60
97
|
|
|
61
98
|
### Patch Changes
|
|
62
99
|
|
|
63
|
-
-
|
|
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
|
|
64
103
|
|
|
65
104
|
## 0.8.1
|
|
66
105
|
|
|
67
106
|
### Patch Changes
|
|
68
107
|
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
-
|
|
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
|
|
72
115
|
|
|
73
116
|
## 0.8.0
|
|
74
117
|
|
|
75
118
|
### Minor Changes
|
|
76
119
|
|
|
77
|
-
-
|
|
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.
|
|
78
124
|
|
|
79
125
|
### Patch Changes
|
|
80
126
|
|
|
81
|
-
-
|
|
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
|
|
82
130
|
|
|
83
131
|
## 0.7.2
|
|
84
132
|
|
|
85
133
|
### Patch Changes
|
|
86
134
|
|
|
87
|
-
-
|
|
88
|
-
-
|
|
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
|
|
89
139
|
|
|
90
140
|
## 0.7.1
|
|
91
141
|
|
|
92
142
|
### Patch Changes
|
|
93
143
|
|
|
94
|
-
-
|
|
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
|
|
95
147
|
|
|
96
148
|
## 0.7.0
|
|
97
149
|
|
|
98
150
|
### Minor Changes
|
|
99
151
|
|
|
100
|
-
-
|
|
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".
|
|
101
156
|
|
|
102
|
-
|
|
157
|
+
[BREAKING] Some rule options have been changed:
|
|
103
158
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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.
|
|
108
166
|
|
|
109
167
|
## 0.6.3
|
|
110
168
|
|
|
111
169
|
### Patch Changes
|
|
112
170
|
|
|
113
|
-
-
|
|
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.
|
|
114
174
|
|
|
115
175
|
## 0.6.2
|
|
116
176
|
|
|
117
177
|
### Patch Changes
|
|
118
178
|
|
|
119
|
-
-
|
|
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`
|
|
120
182
|
|
|
121
183
|
## 0.6.1
|
|
122
184
|
|
|
123
185
|
### Patch Changes
|
|
124
186
|
|
|
125
|
-
-
|
|
126
|
-
|
|
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
|
|
127
194
|
|
|
128
195
|
## 0.6.0
|
|
129
196
|
|
|
130
197
|
### Minor Changes
|
|
131
198
|
|
|
132
|
-
-
|
|
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.
|
|
133
202
|
|
|
134
203
|
## 0.5.2
|
|
135
204
|
|
|
136
205
|
### Patch Changes
|
|
137
206
|
|
|
138
|
-
-
|
|
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.
|
|
139
211
|
|
|
140
212
|
## 0.5.1
|
|
141
213
|
|
|
142
214
|
### Patch Changes
|
|
143
215
|
|
|
144
|
-
-
|
|
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
|
|
145
219
|
|
|
146
220
|
## 0.5.0
|
|
147
221
|
|
|
148
222
|
### Minor Changes
|
|
149
223
|
|
|
150
|
-
-
|
|
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.
|
|
151
228
|
|
|
152
229
|
## 0.4.1
|
|
153
230
|
|
|
154
231
|
### Patch Changes
|
|
155
232
|
|
|
156
|
-
-
|
|
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.
|
|
157
237
|
|
|
158
238
|
## 0.4.0
|
|
159
239
|
|
|
160
240
|
### Minor Changes
|
|
161
241
|
|
|
162
|
-
-
|
|
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.
|
|
163
247
|
|
|
164
248
|
## 0.3.0
|
|
165
249
|
|
|
166
250
|
### Minor Changes
|
|
167
251
|
|
|
168
|
-
-
|
|
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:
|
|
169
255
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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.
|
|
175
262
|
|
|
176
|
-
-
|
|
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:
|
|
177
266
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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`
|
|
181
270
|
|
|
182
271
|
### Patch Changes
|
|
183
272
|
|
|
184
|
-
-
|
|
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
|
|
185
276
|
|
|
186
277
|
## 0.2.1
|
|
187
278
|
|
|
188
279
|
### Patch Changes
|
|
189
280
|
|
|
190
|
-
-
|
|
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
|
|
191
284
|
|
|
192
285
|
## 0.2.0
|
|
193
286
|
|
|
194
287
|
### Minor Changes
|
|
195
288
|
|
|
196
|
-
-
|
|
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:
|
|
197
292
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
|
201
296
|
|
|
202
297
|
## 0.1.0
|
|
203
298
|
|
|
204
299
|
### Minor Changes
|
|
205
300
|
|
|
206
|
-
-
|
|
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
|
+
}
|