@atlaskit/eslint-plugin-ui-styling-standard 0.15.1 → 0.16.0
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 +17 -0
- package/constellation/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
- package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
- package/dist/esm/rules/no-nested-selectors/index.js +64 -49
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
- package/index.js +9 -9
- package/package.json +3 -3
- package/scripts/codegen.tsx +223 -284
- package/src/rules/__tests__/utils/_tester.tsx +24 -24
- package/src/rules/atlaskit-theme/README.md +21 -19
- package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
- package/src/rules/atlaskit-theme/index.ts +107 -115
- package/src/rules/convert-props-syntax/README.md +32 -22
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
- package/src/rules/convert-props-syntax/index.tsx +356 -386
- package/src/rules/enforce-style-prop/README.md +21 -18
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
- package/src/rules/enforce-style-prop/index.tsx +144 -160
- package/src/rules/external-rules.tsx +163 -164
- package/src/rules/local-cx-xcss/README.md +10 -6
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
- package/src/rules/local-cx-xcss/index.tsx +46 -56
- package/src/rules/no-array-arguments/README.md +2 -1
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
- package/src/rules/no-array-arguments/index.tsx +68 -69
- package/src/rules/no-classname-prop/README.md +7 -4
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
- package/src/rules/no-classname-prop/index.tsx +25 -25
- package/src/rules/no-container-queries/README.md +11 -9
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
- package/src/rules/no-container-queries/index.tsx +75 -81
- package/src/rules/no-dynamic-styles/README.md +16 -19
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
- package/src/rules/no-dynamic-styles/index.tsx +45 -48
- package/src/rules/no-exported-styles/README.md +17 -12
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
- package/src/rules/no-exported-styles/index.tsx +36 -36
- package/src/rules/no-global-styles/README.md +15 -14
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
- package/src/rules/no-global-styles/index.tsx +59 -62
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
- package/src/rules/no-important-styles/index.tsx +49 -49
- package/src/rules/no-imported-style-values/README.md +23 -15
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
- package/src/rules/no-imported-style-values/index.tsx +116 -120
- package/src/rules/no-nested-selectors/README.md +15 -13
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +186 -149
- package/src/rules/no-nested-selectors/index.tsx +92 -105
- package/src/rules/no-styled/README.md +14 -9
- package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
- package/src/rules/no-styled/index.tsx +34 -41
- package/src/rules/no-unsafe-selectors/README.md +103 -93
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
- package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
- package/src/rules/no-unsafe-values/README.md +34 -40
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
- package/src/rules/no-unsafe-values/index.tsx +76 -78
- package/src/rules/no-unsafe-values/messages.tsx +12 -12
- package/src/rules/no-unsafe-values/utils.tsx +370 -382
- package/src/rules/use-compiled/README.md +11 -8
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
- package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
- package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
- package/src/rules/use-compiled/index.tsx +203 -226
- package/src/rules/use-compiled/is-safe.tsx +113 -117
- package/src/rules/use-compiled/utils.tsx +14 -18
- package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
- package/src/rules/utils/create-rule.tsx +3 -6
|
@@ -2,87 +2,84 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
typescriptEslintTester.run(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
'no-exported-styles',
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
rule,
|
|
8
|
+
{
|
|
9
|
+
valid: [
|
|
10
|
+
{
|
|
11
|
+
name: 'Basic valid test for css',
|
|
12
|
+
code: `
|
|
13
13
|
import { css } from '@compiled/react';
|
|
14
14
|
const styles = css({});
|
|
15
15
|
`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'Basic valid test for cssMap',
|
|
19
|
+
code: `
|
|
20
20
|
import { cssMap } from '@compiled/react';
|
|
21
21
|
const styles = xcss({});
|
|
22
22
|
`,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'Basic valid test for keyframes',
|
|
26
|
+
code: `
|
|
27
27
|
import { css } from '@compiled/react';
|
|
28
28
|
const styles = css({});
|
|
29
29
|
`,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'Basic valid test for styled',
|
|
33
|
+
code: `
|
|
34
34
|
import { styled } from '@compiled/react';
|
|
35
35
|
const Component = styled.div({});
|
|
36
36
|
`,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'Basic valid test for xcss',
|
|
40
|
+
code: `
|
|
41
41
|
import { css } from '@compiled/react';
|
|
42
42
|
const styles = css({});
|
|
43
43
|
`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'Custom import sources (subtractive)',
|
|
47
|
+
code: `
|
|
48
48
|
import { css } from '@compiled/react';
|
|
49
49
|
export const styles = css({});
|
|
50
50
|
`,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
options: [
|
|
52
|
+
{
|
|
53
|
+
importSources: [],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'Exporting a div with css styles is ok',
|
|
59
|
+
code: `
|
|
60
60
|
import { css } from '@compiled/react';
|
|
61
61
|
const styles = css({});
|
|
62
62
|
export default () => (
|
|
63
63
|
<div css={styles} />
|
|
64
64
|
);
|
|
65
65
|
`,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
invalid: [
|
|
69
|
+
{
|
|
70
|
+
name: 'Export of css',
|
|
71
|
+
code: `
|
|
72
72
|
import { css } from '@compiled/react';
|
|
73
73
|
|
|
74
74
|
export const styles = css({});
|
|
75
75
|
|
|
76
76
|
export default css({});
|
|
77
77
|
`,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
name: 'Export of css from emotion',
|
|
85
|
-
code: `
|
|
78
|
+
errors: [{ messageId: 'no-exported-styles' }, { messageId: 'no-exported-styles' }],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'Export of css from emotion',
|
|
82
|
+
code: `
|
|
86
83
|
import { css } from '@emotion/react';
|
|
87
84
|
|
|
88
85
|
export const styles = css(
|
|
@@ -93,11 +90,11 @@ typescriptEslintTester.run(
|
|
|
93
90
|
borderRadius,
|
|
94
91
|
);
|
|
95
92
|
`,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
93
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: 'Export of cssMap',
|
|
97
|
+
code: `
|
|
101
98
|
import { cssMap } from '@compiled/react';
|
|
102
99
|
|
|
103
100
|
export const borderStyleMap = cssMap({
|
|
@@ -107,37 +104,31 @@ typescriptEslintTester.run(
|
|
|
107
104
|
|
|
108
105
|
export default cssMap({});
|
|
109
106
|
`,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
{
|
|
116
|
-
name: 'Export of keyframes',
|
|
117
|
-
code: `
|
|
107
|
+
errors: [{ messageId: 'no-exported-styles' }, { messageId: 'no-exported-styles' }],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'Export of keyframes',
|
|
111
|
+
code: `
|
|
118
112
|
import { keyframes } from '@compiled/react';
|
|
119
113
|
|
|
120
114
|
export const animation = keyframes({});
|
|
121
115
|
|
|
122
116
|
export default keyframes({});
|
|
123
117
|
`,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
name: 'Exporting styled component',
|
|
131
|
-
code: `
|
|
118
|
+
errors: [{ messageId: 'no-exported-styles' }, { messageId: 'no-exported-styles' }],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'Exporting styled component',
|
|
122
|
+
code: `
|
|
132
123
|
import { styled } from '@compiled/react';
|
|
133
124
|
|
|
134
125
|
export const Component = styled.div({});
|
|
135
126
|
`,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
127
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'Exporting css styles',
|
|
131
|
+
code: `
|
|
141
132
|
import { css } from '@compiled/react';
|
|
142
133
|
import { colors, getColor } from '@mui/theme';
|
|
143
134
|
import { ff } from '@atlaskit/ff';
|
|
@@ -153,31 +144,31 @@ typescriptEslintTester.run(
|
|
|
153
144
|
background: colors['red'],
|
|
154
145
|
});
|
|
155
146
|
`,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: 'Export let css',
|
|
151
|
+
code: `
|
|
161
152
|
import { css } from '@compiled/react';
|
|
162
153
|
|
|
163
154
|
export let styles = css({});
|
|
164
155
|
`,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
156
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'Export style in object',
|
|
160
|
+
code: `
|
|
170
161
|
import { css } from '@compiled/react';
|
|
171
162
|
|
|
172
163
|
const styles = css({});
|
|
173
164
|
|
|
174
165
|
export { styles };
|
|
175
166
|
`,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
167
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: 'Exporting nested style',
|
|
171
|
+
code: `
|
|
181
172
|
import { css } from '@compiled/react';
|
|
182
173
|
|
|
183
174
|
const styles = {
|
|
@@ -186,40 +177,40 @@ typescriptEslintTester.run(
|
|
|
186
177
|
|
|
187
178
|
export { styles };
|
|
188
179
|
`,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
180
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'Exporting styled components',
|
|
184
|
+
code: `
|
|
194
185
|
import styled from 'styled-components'
|
|
195
186
|
|
|
196
187
|
export const PasswordInput = styled.input.attrs(props => ({
|
|
197
188
|
type: "password"
|
|
198
189
|
}))
|
|
199
190
|
`,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
191
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: 'Exporting styled component with base component',
|
|
195
|
+
code: `
|
|
205
196
|
import styled from 'styled-components'
|
|
206
197
|
|
|
207
198
|
const BaseComponent = styled.div({});
|
|
208
199
|
export const Component = styled(BaseComponent)({});
|
|
209
200
|
`,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
201
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: 'Exporting styled component from compiled',
|
|
205
|
+
code: `
|
|
215
206
|
import { styled as styled2 } from '@compiled/react'
|
|
216
207
|
|
|
217
208
|
export const Component = styled2.div({
|
|
218
209
|
margin: \`\${token('space.200', '16px')} 0\`,
|
|
219
210
|
})
|
|
220
211
|
`,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
212
|
+
errors: [{ messageId: 'no-exported-styles' }],
|
|
213
|
+
},
|
|
214
|
+
],
|
|
215
|
+
},
|
|
225
216
|
);
|
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
isCss,
|
|
4
|
+
isStyled,
|
|
5
|
+
isKeyframes,
|
|
6
|
+
isCssMap,
|
|
7
|
+
isXcss,
|
|
8
|
+
type SupportedNameChecker,
|
|
9
9
|
} from '@atlaskit/eslint-utils/is-supported-import';
|
|
10
10
|
import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
|
|
11
11
|
import { createNoExportedRule } from '@atlaskit/eslint-utils/create-no-exported-rule';
|
|
12
12
|
|
|
13
13
|
const schema: JSONSchema4 = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
{
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
importSources: {
|
|
18
|
+
type: 'array',
|
|
19
|
+
items: { type: 'string' },
|
|
20
|
+
uniqueItems: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
24
|
];
|
|
25
25
|
|
|
26
26
|
const supportedImports: readonly SupportedNameChecker[] = [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
isCss,
|
|
28
|
+
isCssMap,
|
|
29
|
+
isKeyframes,
|
|
30
|
+
isXcss,
|
|
31
|
+
isStyled,
|
|
32
32
|
];
|
|
33
33
|
|
|
34
34
|
export const rule = createLintRule({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
meta: {
|
|
36
|
+
name: 'no-exported-styles',
|
|
37
|
+
docs: {
|
|
38
|
+
description: 'Disallows exports of css, keyframes, styled and xcss',
|
|
39
|
+
recommended: true,
|
|
40
|
+
severity: 'warn',
|
|
41
|
+
},
|
|
42
|
+
messages: {
|
|
43
|
+
'no-exported-styles':
|
|
44
|
+
'Styles from css, cssMap, keyframes, styled and xcss should not be exported. All styles should be defined and used in the same file instead.',
|
|
45
|
+
},
|
|
46
|
+
type: 'problem',
|
|
47
|
+
schema,
|
|
48
|
+
},
|
|
49
|
+
create: createNoExportedRule(supportedImports, 'no-exported-styles'),
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
export default rule;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
This rule prevents global styles through CSS-in-JS or CSS module imports.
|
|
2
2
|
|
|
3
|
-
Requiring local definition of styles helps to ensure that style dependencies are statically
|
|
3
|
+
Requiring local definition of styles helps to ensure that style dependencies are statically
|
|
4
|
+
resolvable.
|
|
4
5
|
|
|
5
6
|
## Examples
|
|
6
7
|
|
|
@@ -10,12 +11,12 @@ Requiring local definition of styles helps to ensure that style dependencies are
|
|
|
10
11
|
import { Global } from '@emotion/react';
|
|
11
12
|
|
|
12
13
|
<Global
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
styles={{
|
|
15
|
+
'.some-class': {
|
|
16
|
+
fontSize: 50,
|
|
17
|
+
textAlign: 'center',
|
|
18
|
+
},
|
|
19
|
+
}}
|
|
19
20
|
/>;
|
|
20
21
|
```
|
|
21
22
|
|
|
@@ -23,9 +24,9 @@ import { Global } from '@emotion/react';
|
|
|
23
24
|
import { createGlobalStyle } from 'styled-components';
|
|
24
25
|
|
|
25
26
|
const GlobalStyle = createGlobalStyle({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
body: {
|
|
28
|
+
margin: 0,
|
|
29
|
+
},
|
|
29
30
|
});
|
|
30
31
|
```
|
|
31
32
|
|
|
@@ -33,15 +34,15 @@ const GlobalStyle = createGlobalStyle({
|
|
|
33
34
|
import { injectGlobal } from 'styled-components';
|
|
34
35
|
|
|
35
36
|
injectGlobal({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
body: {
|
|
38
|
+
margin: 0,
|
|
39
|
+
},
|
|
39
40
|
});
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
```tsx
|
|
43
44
|
<style>
|
|
44
|
-
|
|
45
|
+
{`
|
|
45
46
|
.some-class {
|
|
46
47
|
color: red;
|
|
47
48
|
}
|
|
@@ -2,32 +2,32 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
tester.run('no-css-modules', rule, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
5
|
+
valid: [
|
|
6
|
+
"import 'styles-css';",
|
|
7
|
+
"import 'less';",
|
|
8
|
+
"import 'sass-module';",
|
|
9
|
+
"import 'something-scss-something';",
|
|
10
|
+
],
|
|
11
|
+
invalid: [
|
|
12
|
+
{
|
|
13
|
+
name: '.css import',
|
|
14
|
+
code: "import 'styles.css';",
|
|
15
|
+
errors: [{ messageId: 'no-css-modules' }],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: '.less import',
|
|
19
|
+
code: "import 'styles.less';",
|
|
20
|
+
errors: [{ messageId: 'no-css-modules' }],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: '.sass import',
|
|
24
|
+
code: "import 'styles.sass';",
|
|
25
|
+
errors: [{ messageId: 'no-css-modules' }],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: '.scss import',
|
|
29
|
+
code: "import 'styles.scss';",
|
|
30
|
+
errors: [{ messageId: 'no-css-modules' }],
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
33
|
});
|
|
@@ -2,45 +2,45 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
tester.run('no-global-styles', rule, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
5
|
+
valid: [
|
|
6
|
+
"import { css } from '@emotion/react';",
|
|
7
|
+
"import { keyframes } from '@emotion/core';",
|
|
8
|
+
"import styled from 'styled-components';",
|
|
9
|
+
],
|
|
10
|
+
invalid: [
|
|
11
|
+
{
|
|
12
|
+
name: '[@emotion/react] Global',
|
|
13
|
+
code: "import { Global } from '@emotion/react';",
|
|
14
|
+
errors: [{ messageId: 'no-global-styles' }],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: '[@emotion/core] Global',
|
|
18
|
+
code: "import { Global } from '@emotion/core';",
|
|
19
|
+
errors: [{ messageId: 'no-global-styles' }],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: '[styled-components] injectGlobal',
|
|
23
|
+
code: "import { injectGlobal } from 'styled-components';",
|
|
24
|
+
errors: [{ messageId: 'no-global-styles' }],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: '[styled-components] createGlobalStyle',
|
|
28
|
+
code: "import { createGlobalStyle } from 'styled-components';",
|
|
29
|
+
errors: [{ messageId: 'no-global-styles' }],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'aliasing',
|
|
33
|
+
code: "import { Global as EmotionGlobal } from '@emotion/react';",
|
|
34
|
+
errors: [{ messageId: 'no-global-styles' }],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'style tag',
|
|
38
|
+
code: `
|
|
39
39
|
<style>
|
|
40
40
|
{'.my-class { color: red; }'}
|
|
41
41
|
</style>
|
|
42
42
|
`,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
errors: [{ messageId: 'no-global-styles' }],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
46
|
});
|