@atlaskit/eslint-plugin-ui-styling-standard 0.15.2 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/constellation/consistent-css-prop-usage/usage.mdx +3 -1
- package/constellation/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/constellation/no-css-tagged-template-expression/usage.mdx +5 -2
- package/constellation/no-empty-styled-expression/usage.mdx +5 -2
- package/constellation/no-exported-css/usage.mdx +5 -2
- package/constellation/no-exported-keyframes/usage.mdx +5 -2
- package/constellation/no-invalid-css-map/usage.mdx +5 -2
- package/constellation/no-js-xcss/usage.mdx +3 -1
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +5 -2
- package/constellation/no-styled-tagged-template-expression/usage.mdx +5 -2
- package/constellation/no-suppress-xcss/usage.mdx +6 -3
- 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 +141 -128
- 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 +133 -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,96 +1,94 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
isCss,
|
|
4
|
+
getImportSources,
|
|
5
|
+
isStyled,
|
|
6
|
+
isKeyframes,
|
|
7
|
+
isCssMap,
|
|
8
|
+
isXcss,
|
|
9
9
|
} from '@atlaskit/eslint-utils/is-supported-import';
|
|
10
10
|
import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
|
|
11
11
|
import { Linter } from './utils';
|
|
12
12
|
import { messages } from './messages';
|
|
13
13
|
|
|
14
14
|
const schema: JSONSchema4 = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
15
|
+
{
|
|
16
|
+
type: 'object',
|
|
17
|
+
additionalProperties: false,
|
|
18
|
+
properties: {
|
|
19
|
+
importSources: {
|
|
20
|
+
type: 'array',
|
|
21
|
+
items: { type: 'string' },
|
|
22
|
+
uniqueItems: true,
|
|
23
|
+
},
|
|
24
|
+
allowedFunctionCalls: {
|
|
25
|
+
type: 'array',
|
|
26
|
+
items: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
minItems: 2,
|
|
29
|
+
maxItems: 2,
|
|
30
|
+
items: [{ type: 'string' }, { type: 'string' }],
|
|
31
|
+
},
|
|
32
|
+
uniqueItems: true,
|
|
33
|
+
},
|
|
34
|
+
allowedDynamicKeys: {
|
|
35
|
+
type: 'array',
|
|
36
|
+
items: {
|
|
37
|
+
type: 'array',
|
|
38
|
+
minItems: 2,
|
|
39
|
+
maxItems: 2,
|
|
40
|
+
items: [{ type: 'string' }, { type: 'string' }],
|
|
41
|
+
},
|
|
42
|
+
uniqueItems: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
46
|
];
|
|
47
47
|
|
|
48
48
|
export const rule = createLintRule({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const importSources = getImportSources(context);
|
|
49
|
+
meta: {
|
|
50
|
+
name: 'no-unsafe-values',
|
|
51
|
+
docs: {
|
|
52
|
+
description: 'Disallows styles that are difficult/impossible to statically anaylze.',
|
|
53
|
+
recommended: true,
|
|
54
|
+
severity: 'warn',
|
|
55
|
+
},
|
|
56
|
+
messages,
|
|
57
|
+
type: 'problem',
|
|
58
|
+
schema,
|
|
59
|
+
},
|
|
60
|
+
create(context) {
|
|
61
|
+
const importSources = getImportSources(context);
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
return {
|
|
64
|
+
CallExpression(node) {
|
|
65
|
+
const { references } = context.sourceCode.getScope(node);
|
|
67
66
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
67
|
+
if (
|
|
68
|
+
!isCss(node.callee, references, importSources) &&
|
|
69
|
+
!isStyled(node.callee, references, importSources) &&
|
|
70
|
+
!isKeyframes(node.callee, references, importSources) &&
|
|
71
|
+
!isCssMap(node.callee, references, importSources) &&
|
|
72
|
+
!isXcss(node.callee, references, importSources)
|
|
73
|
+
) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
77
|
+
if (
|
|
78
|
+
isStyled(node.callee, references, importSources) &&
|
|
79
|
+
(node.parent.type === 'CallExpression' || node.parent.type === 'TaggedTemplateExpression')
|
|
80
|
+
) {
|
|
81
|
+
/**
|
|
82
|
+
* If it is of the form styled(Base)({}) we don't want to lint the inner function arguments.
|
|
83
|
+
*/
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
const linter = new Linter(context, node);
|
|
88
|
+
linter.run();
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
},
|
|
94
92
|
});
|
|
95
93
|
|
|
96
94
|
export default rule;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import outdent from 'outdent';
|
|
2
2
|
|
|
3
3
|
const whereToGetHelp =
|
|
4
|
-
|
|
4
|
+
"If you think this should be allowed, or if you're running into issues, reach out in #help-ui-styling-standard";
|
|
5
5
|
|
|
6
6
|
export const messages = {
|
|
7
|
-
|
|
7
|
+
'no-array-values': outdent`
|
|
8
8
|
Arrays are not allowed in style objects. Support is inconsistent between styling libraries.
|
|
9
9
|
|
|
10
10
|
Compose styles with the css prop instead.
|
|
@@ -12,7 +12,7 @@ export const messages = {
|
|
|
12
12
|
${whereToGetHelp}
|
|
13
13
|
`,
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
'no-conditional-values': outdent`
|
|
16
16
|
Conditional expressions are not allowed in style objects.
|
|
17
17
|
|
|
18
18
|
Conditionally apply styles with the css prop instead.
|
|
@@ -20,19 +20,19 @@ export const messages = {
|
|
|
20
20
|
${whereToGetHelp}
|
|
21
21
|
`,
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
'no-dynamic-keys': outdent`
|
|
24
24
|
Dynamic keys are not allowed in style objects.
|
|
25
25
|
|
|
26
26
|
${whereToGetHelp}
|
|
27
27
|
`,
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
'no-function-calls': outdent`
|
|
30
30
|
Function calls are not allowed in style objects.
|
|
31
31
|
|
|
32
32
|
${whereToGetHelp}
|
|
33
33
|
`,
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
'no-identifier-arguments': outdent`
|
|
36
36
|
Variable arguments are not allowed.
|
|
37
37
|
|
|
38
38
|
Inline the object value, or compose styles with the css prop instead.
|
|
@@ -40,7 +40,7 @@ export const messages = {
|
|
|
40
40
|
${whereToGetHelp}
|
|
41
41
|
`,
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
'no-object-access': outdent`
|
|
44
44
|
Accessing object values is not allowed in style objects.
|
|
45
45
|
|
|
46
46
|
If you are accessing the component's props, use the style prop to apply dynamic values instead.
|
|
@@ -48,7 +48,7 @@ export const messages = {
|
|
|
48
48
|
${whereToGetHelp}
|
|
49
49
|
`,
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
'no-object-references': outdent`
|
|
52
52
|
Referencing objects is not allowed in style objects.
|
|
53
53
|
|
|
54
54
|
Inline the object value instead.
|
|
@@ -56,7 +56,7 @@ export const messages = {
|
|
|
56
56
|
${whereToGetHelp}
|
|
57
57
|
`,
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
'no-spread-elements': outdent`
|
|
60
60
|
Spread elements are not allowed in style objects.
|
|
61
61
|
|
|
62
62
|
Compose styles with the css prop instead.
|
|
@@ -64,14 +64,14 @@ export const messages = {
|
|
|
64
64
|
${whereToGetHelp}
|
|
65
65
|
`,
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
// Fallback case if a more specific message is not applicable
|
|
68
|
+
'no-unsafe-values': outdent`
|
|
69
69
|
Unsafe values are not allowed in style objects.
|
|
70
70
|
|
|
71
71
|
${whereToGetHelp}
|
|
72
72
|
`,
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
'no-variables': outdent`
|
|
75
75
|
Variables are not allowed in style objects, unless they:
|
|
76
76
|
|
|
77
77
|
- Have a simple, static value.
|