@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
|
@@ -1,112 +1,99 @@
|
|
|
1
1
|
import type { Property } from 'estree';
|
|
2
|
+
import cssSelectorParser, { type Selector, isNesting, isPseudo } from 'postcss-selector-parser';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
];
|
|
24
|
-
|
|
25
|
-
const getCssSelector = (node: Property): string | null => {
|
|
26
|
-
if (node.key.type === 'Literal' && typeof node.key.value === 'string') {
|
|
27
|
-
return node.key.value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (node.key.type === 'Identifier' && typeof node.key.name === 'string') {
|
|
31
|
-
return node.key.name;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (node.key.type === 'TemplateLiteral') {
|
|
35
|
-
return node.key.quasis.map((quasi) => quasi.value.raw).join(' ');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return null;
|
|
4
|
+
import { walkStyleProperties } from '@atlaskit/eslint-utils/walk-style-properties';
|
|
5
|
+
import { importSources } from '@atlaskit/eslint-utils/schema';
|
|
6
|
+
|
|
7
|
+
import { createLintRuleWithTypedConfig } from '../utils/create-rule-with-typed-config';
|
|
8
|
+
|
|
9
|
+
const getCssSelector = (key: Property['key']): string | null => {
|
|
10
|
+
if (key.type === 'Literal' && typeof key.value === 'string') {
|
|
11
|
+
return key.value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (key.type === 'Identifier' && typeof key.name === 'string') {
|
|
15
|
+
return key.name;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (key.type === 'TemplateLiteral') {
|
|
19
|
+
return key.quasis.map((quasi) => quasi.value.raw).join(' ');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return null;
|
|
39
23
|
};
|
|
40
24
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
25
|
+
function isAllowedSelector(selector: Selector): boolean {
|
|
26
|
+
const [head, ...tail] = selector.nodes;
|
|
27
|
+
|
|
28
|
+
// The first node must be a nesting selector (`&`) or pseudo-selector.
|
|
29
|
+
const isHeadAllowed = isNesting(head) || isPseudo(head);
|
|
30
|
+
|
|
31
|
+
// All remaining nodes must be pseudo selectors.
|
|
32
|
+
const isTailAllowed = tail.every(isPseudo);
|
|
33
|
+
|
|
34
|
+
return isHeadAllowed && isTailAllowed;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const cssSelectorProcessor = cssSelectorParser();
|
|
38
|
+
|
|
39
|
+
export const rule = createLintRuleWithTypedConfig({
|
|
40
|
+
meta: {
|
|
41
|
+
name: 'no-nested-selectors',
|
|
42
|
+
docs: {
|
|
43
|
+
description: 'Prevents usage of nested selectors within css styling',
|
|
44
|
+
recommended: true,
|
|
45
|
+
severity: 'warn',
|
|
46
|
+
},
|
|
47
|
+
messages: {
|
|
48
|
+
'no-nested-selectors':
|
|
49
|
+
'Please avoid setting styles for child elements or elements that require context from other elements.',
|
|
50
|
+
},
|
|
51
|
+
type: 'problem',
|
|
52
|
+
schema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
importSources,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
create(context, { importSources }) {
|
|
60
|
+
return {
|
|
61
|
+
CallExpression(node) {
|
|
62
|
+
const { references } = context.getScope();
|
|
63
|
+
|
|
64
|
+
walkStyleProperties(node, references, importSources, ({ key, value }) => {
|
|
65
|
+
if (value.type !== 'ObjectExpression') {
|
|
66
|
+
// If the value is a CSS object, safe to assume we're at a CSS selector
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const selectorText = getCssSelector(key);
|
|
71
|
+
if (selectorText === null) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Ignore at-rules
|
|
76
|
+
if (selectorText.includes('@')) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const selectorList = cssSelectorProcessor.astSync(selectorText);
|
|
82
|
+
|
|
83
|
+
if (!selectorList.nodes.every(isAllowedSelector)) {
|
|
84
|
+
context.report({
|
|
85
|
+
messageId: 'no-nested-selectors',
|
|
86
|
+
node: key,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
} catch (_) {
|
|
90
|
+
// If it is not parsable then `no-unsafe-selectors` will give it an error,
|
|
91
|
+
// we can ignore it here.
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
},
|
|
110
97
|
});
|
|
111
98
|
|
|
112
99
|
export default rule;
|
|
@@ -10,7 +10,7 @@ Avoid usages of styled, eg. `styled.div`, `styled('div')`, `styled(Component)`,
|
|
|
10
10
|
import styled from 'styled-components';
|
|
11
11
|
|
|
12
12
|
const Component = styled.div`
|
|
13
|
-
|
|
13
|
+
color: red;
|
|
14
14
|
`;
|
|
15
15
|
export default styled.div({ color: 'red' });
|
|
16
16
|
```
|
|
@@ -33,7 +33,7 @@ export const ComponentTwo = styled3(Component)({ … });
|
|
|
33
33
|
import styled from 'styled-components';
|
|
34
34
|
|
|
35
35
|
export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))({
|
|
36
|
-
|
|
36
|
+
color: 'red',
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))({
|
|
|
41
41
|
import styled from 'styled-components';
|
|
42
42
|
|
|
43
43
|
export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))`
|
|
44
|
-
|
|
44
|
+
color: red;
|
|
45
45
|
`;
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -53,7 +53,7 @@ import { css, jsx } from '@emotion/react';
|
|
|
53
53
|
const styles = css({ color: 'red' });
|
|
54
54
|
|
|
55
55
|
const Component = ({ children }) => {
|
|
56
|
-
|
|
56
|
+
return <div css={styles}>{children}</div>;
|
|
57
57
|
};
|
|
58
58
|
```
|
|
59
59
|
|
|
@@ -62,11 +62,11 @@ const Component = ({ children }) => {
|
|
|
62
62
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
63
63
|
|
|
64
64
|
const styles = xcss({
|
|
65
|
-
|
|
65
|
+
color: 'color.text.subtlest',
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
const Component = ({ children }) => {
|
|
69
|
-
|
|
69
|
+
return <Box xcss={styles}>{children}</Box>;
|
|
70
70
|
};
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -74,9 +74,14 @@ const Component = ({ children }) => {
|
|
|
74
74
|
|
|
75
75
|
### Why avoid using `styled` imports?
|
|
76
76
|
|
|
77
|
-
Using `styled` imports impacts file readability, has TypeScript implications, adds linting
|
|
77
|
+
Using `styled` imports impacts file readability, has TypeScript implications, adds linting
|
|
78
|
+
complexity, promotes exported styles, and potential refactoring efforts. Using `css()` with the
|
|
79
|
+
`<div css={…}>` syntax is more performant and clear.
|
|
78
80
|
|
|
79
81
|
### How will I extend like `styled(Button)`?
|
|
80
82
|
|
|
81
|
-
Primarily, we would suggest you don't extend styles of a component you don't own unless they have an
|
|
82
|
-
|
|
83
|
+
Primarily, we would suggest you don't extend styles of a component you don't own unless they have an
|
|
84
|
+
explicit bounded interface for you to customize against. The Atlassian Design System for example has
|
|
85
|
+
removed `styled(Button)` interactivity in our latest variants because they are unsafe for us to
|
|
86
|
+
evolve the system with. Instead, make use of reusable component patterns to pass props around which
|
|
87
|
+
impact the styles of that component.
|
|
@@ -2,9 +2,9 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
tester.run('no-styled', rule, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
valid: [
|
|
6
|
+
{
|
|
7
|
+
code: `
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
|
|
10
10
|
const styles = css({ color: 'red' });
|
|
@@ -13,9 +13,9 @@ tester.run('no-styled', rule, {
|
|
|
13
13
|
return <div css={styles}>{children}</div>;
|
|
14
14
|
};
|
|
15
15
|
`,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
code: `
|
|
19
19
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
20
20
|
|
|
21
21
|
const styles = xcss({
|
|
@@ -25,49 +25,49 @@ tester.run('no-styled', rule, {
|
|
|
25
25
|
const Component = ({ children }) => {
|
|
26
26
|
return <Box xcss={styles}>{children}</Box>;
|
|
27
27
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
invalid: [
|
|
32
|
+
{
|
|
33
|
+
code: `
|
|
34
34
|
import styled from 'styled-components';
|
|
35
35
|
|
|
36
36
|
const Component = styled.div\`color: red;\`
|
|
37
37
|
`,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
errors: [{ messageId: 'no-styled' }],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
code: `
|
|
42
42
|
import styled from 'styled-components';
|
|
43
43
|
|
|
44
44
|
export default styled.div({ color: 'red' });
|
|
45
45
|
`,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
errors: [{ messageId: 'no-styled' }],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
code: `
|
|
50
50
|
import { styled as styled3 } from '@compiled/react';
|
|
51
51
|
|
|
52
52
|
export const ComponentTwo = styled3(Component)({ color: 'blue' });
|
|
53
53
|
`,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
errors: [{ messageId: 'no-styled' }],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
code: `
|
|
58
58
|
import styled from 'styled-components';
|
|
59
59
|
|
|
60
60
|
export default styled.div.attrs(props => ({ 'data-testid': props.testId }))({ color: 'red' });
|
|
61
61
|
`,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
errors: [{ messageId: 'no-styled' }],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
code: `
|
|
66
66
|
import styled from 'styled-components';
|
|
67
67
|
|
|
68
68
|
export default styled.div.attrs(props => ({ 'data-testid': props.testId }))\`color: red\`;
|
|
69
69
|
`,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
errors: [{ messageId: 'no-styled' }],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
73
|
});
|
|
@@ -1,52 +1,45 @@
|
|
|
1
1
|
import { type MemberExpression, type CallExpression } from 'eslint-codemod-utils';
|
|
2
2
|
import { isStyled, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
3
|
|
|
4
|
-
|
|
5
4
|
import { createLintRule } from '../utils/create-rule';
|
|
6
5
|
|
|
7
6
|
export const rule = createLintRule({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
isStyled(node, references, importSources)
|
|
28
|
-
) {
|
|
29
|
-
context.report({ node, messageId: 'no-styled' });
|
|
30
|
-
}
|
|
7
|
+
meta: {
|
|
8
|
+
name: 'no-styled',
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Disallows usage of the `styled` imports',
|
|
11
|
+
recommended: true,
|
|
12
|
+
severity: 'warn',
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
'no-styled': "Avoid usages of styled, eg. styled.div, styled('div'), styled(Component), etc.",
|
|
16
|
+
},
|
|
17
|
+
type: 'problem',
|
|
18
|
+
},
|
|
19
|
+
create(context) {
|
|
20
|
+
return {
|
|
21
|
+
CallExpression: (node: CallExpression) => {
|
|
22
|
+
const references = context.getScope().references;
|
|
23
|
+
const importSources = getImportSources(context);
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
if (isStyled(node, references, importSources)) {
|
|
26
|
+
context.report({ node, messageId: 'no-styled' });
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
MemberExpression: (node: MemberExpression) => {
|
|
30
|
+
const references = context.getScope().references;
|
|
31
|
+
const importSources = getImportSources(context);
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
},
|
|
33
|
+
if (node.object.type === 'Identifier' && isStyled(node.object, references, importSources)) {
|
|
34
|
+
const parent = context.getAncestors().at(-1);
|
|
35
|
+
if (parent && (parent.type === 'CallExpression' || parent.type === 'MemberExpression')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
context.report({ node, messageId: 'no-styled' });
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
50
43
|
});
|
|
51
44
|
|
|
52
45
|
export default rule;
|