@atlaskit/eslint-plugin-ui-styling-standard 1.3.0 → 1.4.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
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#115551](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/115551)
|
|
8
|
+
[`b773fe465608e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b773fe465608e) -
|
|
9
|
+
Allows `@atlaskit/ui-styling-standard/no-classname-prop` to work with bounded pass-through, eg.
|
|
10
|
+
`className={props.xcss}`
|
|
11
|
+
|
|
3
12
|
## 1.3.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -42,23 +42,23 @@ module.exports = {
|
|
|
42
42
|
|
|
43
43
|
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
44
44
|
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
45
|
-
| <a href="./src/rules/atlaskit-theme/README.md">atlaskit-theme</a>
|
|
46
|
-
| <a href="./src/rules/convert-props-syntax/README.md">convert-props-syntax</a>
|
|
47
|
-
| <a href="./src/rules/enforce-style-prop/README.md">enforce-style-prop</a>
|
|
48
|
-
| <a href="./src/rules/local-cx-xcss/README.md">local-cx-xcss</a>
|
|
49
|
-
| <a href="./src/rules/no-array-arguments/README.md">no-array-arguments</a>
|
|
50
|
-
| <a href="./src/rules/no-classname-prop/README.md">no-classname-prop</a>
|
|
51
|
-
| <a href="./src/rules/no-container-queries/README.md">no-container-queries</a>
|
|
52
|
-
| <a href="./src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a>
|
|
53
|
-
| <a href="./src/rules/no-exported-styles/README.md">no-exported-styles</a>
|
|
54
|
-
| <a href="./src/rules/no-global-styles/README.md">no-global-styles</a>
|
|
55
|
-
| <a href="./src/rules/no-important-styles/README.md">no-important-styles</a>
|
|
56
|
-
| <a href="./src/rules/no-imported-style-values/README.md">no-imported-style-values</a>
|
|
57
|
-
| <a href="./src/rules/no-nested-selectors/README.md">no-nested-selectors</a>
|
|
58
|
-
| <a href="./src/rules/no-styled/README.md">no-styled</a>
|
|
59
|
-
| <a href="./src/rules/no-unsafe-selectors/README.md">no-unsafe-selectors</a>
|
|
60
|
-
| <a href="./src/rules/no-unsafe-values/README.md">no-unsafe-values</a>
|
|
61
|
-
| <a href="./src/rules/use-compiled/README.md">use-compiled</a>
|
|
45
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/atlaskit-theme/README.md">atlaskit-theme</a> | Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand | Yes | | |
|
|
46
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/convert-props-syntax/README.md">convert-props-syntax</a> | Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries. | Yes | Yes | |
|
|
47
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/enforce-style-prop/README.md">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
|
|
48
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/local-cx-xcss/README.md">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
|
|
49
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-array-arguments/README.md">no-array-arguments</a> | Prevents usage of array arguments to style declaration functions | Yes | Yes | |
|
|
50
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
51
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
52
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-dynamic-styles/README.md">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
|
|
53
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-exported-styles/README.md">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
|
|
54
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-global-styles/README.md">no-global-styles</a> | Prevents global styles through CSS-in-JS or CSS module imports | Yes | | |
|
|
55
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
56
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-imported-style-values/README.md">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
|
|
57
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
58
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-styled/README.md">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
|
|
59
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-unsafe-selectors/README.md">no-unsafe-selectors</a> | Disallows use of nested styles in `css` functions. | Yes | Yes | Yes |
|
|
60
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/no-unsafe-values/README.md">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
|
|
61
|
+
| <a href="./packages/design-system/eslint-plugin-ui-styling-standard/src/rules/use-compiled/README.md">use-compiled</a> | Ensures usage of `@compiled/react` instead of other CSS-in-JS libraries | Yes | Yes | |
|
|
62
62
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
63
63
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
64
64
|
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
@@ -6,6 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
7
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
8
|
var _createRule = require("../utils/create-rule");
|
|
9
|
+
var isXcssProp = function isXcssProp(propName) {
|
|
10
|
+
if (propName === 'xcss') {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return propName.endsWith('Xcss');
|
|
14
|
+
};
|
|
9
15
|
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
10
16
|
meta: {
|
|
11
17
|
name: 'no-classname-prop',
|
|
@@ -25,12 +31,35 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
|
25
31
|
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXAttribute')) {
|
|
26
32
|
return;
|
|
27
33
|
}
|
|
28
|
-
if (node.name.name
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
if (node.name.name !== 'className' || !node.value) {
|
|
35
|
+
// Ignore, we can't parse this—it either isn't a `className` prop or has no value.
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node.value, 'JSXExpressionContainer')) {
|
|
39
|
+
/**
|
|
40
|
+
* We're basically looking for `className={xcss}` and nothing else…
|
|
41
|
+
*/
|
|
42
|
+
var propValueName = null;
|
|
43
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node.value.expression, 'Identifier')) {
|
|
44
|
+
// eg. `className={xcss}`
|
|
45
|
+
propValueName = node.value.expression.name;
|
|
46
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(node.value.expression, 'MemberExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.value.expression.property, 'Identifier')) {
|
|
47
|
+
// eg. `className={props.xcss}`
|
|
48
|
+
propValueName = node.value.expression.property.name;
|
|
49
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(node.value.expression, 'MemberExpression') && (0, _eslintCodemodUtils.isNodeOfType)(node.value.expression.property, 'Literal') && typeof node.value.expression.property.value === 'string') {
|
|
50
|
+
// eg. `className={props['xcss']}`
|
|
51
|
+
propValueName = node.value.expression.property.value;
|
|
52
|
+
}
|
|
53
|
+
if (propValueName && isXcssProp(propValueName)) {
|
|
54
|
+
// Ignore, it's valid to have `className={xcss}`
|
|
55
|
+
// We just assume people have this typed correctly, eg. they're not using `xcss?: any`
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
33
58
|
}
|
|
59
|
+
context.report({
|
|
60
|
+
node: node,
|
|
61
|
+
messageId: 'no-classname-prop'
|
|
62
|
+
});
|
|
34
63
|
}
|
|
35
64
|
};
|
|
36
65
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
const isXcssProp = propName => {
|
|
4
|
+
if (propName === 'xcss') {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return propName.endsWith('Xcss');
|
|
8
|
+
};
|
|
3
9
|
export const rule = createLintRule({
|
|
4
10
|
meta: {
|
|
5
11
|
name: 'no-classname-prop',
|
|
@@ -19,12 +25,35 @@ export const rule = createLintRule({
|
|
|
19
25
|
if (!isNodeOfType(node, 'JSXAttribute')) {
|
|
20
26
|
return;
|
|
21
27
|
}
|
|
22
|
-
if (node.name.name
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (node.name.name !== 'className' || !node.value) {
|
|
29
|
+
// Ignore, we can't parse this—it either isn't a `className` prop or has no value.
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (isNodeOfType(node.value, 'JSXExpressionContainer')) {
|
|
33
|
+
/**
|
|
34
|
+
* We're basically looking for `className={xcss}` and nothing else…
|
|
35
|
+
*/
|
|
36
|
+
let propValueName = null;
|
|
37
|
+
if (isNodeOfType(node.value.expression, 'Identifier')) {
|
|
38
|
+
// eg. `className={xcss}`
|
|
39
|
+
propValueName = node.value.expression.name;
|
|
40
|
+
} else if (isNodeOfType(node.value.expression, 'MemberExpression') && isNodeOfType(node.value.expression.property, 'Identifier')) {
|
|
41
|
+
// eg. `className={props.xcss}`
|
|
42
|
+
propValueName = node.value.expression.property.name;
|
|
43
|
+
} else if (isNodeOfType(node.value.expression, 'MemberExpression') && isNodeOfType(node.value.expression.property, 'Literal') && typeof node.value.expression.property.value === 'string') {
|
|
44
|
+
// eg. `className={props['xcss']}`
|
|
45
|
+
propValueName = node.value.expression.property.value;
|
|
46
|
+
}
|
|
47
|
+
if (propValueName && isXcssProp(propValueName)) {
|
|
48
|
+
// Ignore, it's valid to have `className={xcss}`
|
|
49
|
+
// We just assume people have this typed correctly, eg. they're not using `xcss?: any`
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
27
52
|
}
|
|
53
|
+
context.report({
|
|
54
|
+
node,
|
|
55
|
+
messageId: 'no-classname-prop'
|
|
56
|
+
});
|
|
28
57
|
}
|
|
29
58
|
};
|
|
30
59
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
var isXcssProp = function isXcssProp(propName) {
|
|
4
|
+
if (propName === 'xcss') {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return propName.endsWith('Xcss');
|
|
8
|
+
};
|
|
3
9
|
export var rule = createLintRule({
|
|
4
10
|
meta: {
|
|
5
11
|
name: 'no-classname-prop',
|
|
@@ -19,12 +25,35 @@ export var rule = createLintRule({
|
|
|
19
25
|
if (!isNodeOfType(node, 'JSXAttribute')) {
|
|
20
26
|
return;
|
|
21
27
|
}
|
|
22
|
-
if (node.name.name
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (node.name.name !== 'className' || !node.value) {
|
|
29
|
+
// Ignore, we can't parse this—it either isn't a `className` prop or has no value.
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (isNodeOfType(node.value, 'JSXExpressionContainer')) {
|
|
33
|
+
/**
|
|
34
|
+
* We're basically looking for `className={xcss}` and nothing else…
|
|
35
|
+
*/
|
|
36
|
+
var propValueName = null;
|
|
37
|
+
if (isNodeOfType(node.value.expression, 'Identifier')) {
|
|
38
|
+
// eg. `className={xcss}`
|
|
39
|
+
propValueName = node.value.expression.name;
|
|
40
|
+
} else if (isNodeOfType(node.value.expression, 'MemberExpression') && isNodeOfType(node.value.expression.property, 'Identifier')) {
|
|
41
|
+
// eg. `className={props.xcss}`
|
|
42
|
+
propValueName = node.value.expression.property.name;
|
|
43
|
+
} else if (isNodeOfType(node.value.expression, 'MemberExpression') && isNodeOfType(node.value.expression.property, 'Literal') && typeof node.value.expression.property.value === 'string') {
|
|
44
|
+
// eg. `className={props['xcss']}`
|
|
45
|
+
propValueName = node.value.expression.property.value;
|
|
46
|
+
}
|
|
47
|
+
if (propValueName && isXcssProp(propValueName)) {
|
|
48
|
+
// Ignore, it's valid to have `className={xcss}`
|
|
49
|
+
// We just assume people have this typed correctly, eg. they're not using `xcss?: any`
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
27
52
|
}
|
|
53
|
+
context.report({
|
|
54
|
+
node: node,
|
|
55
|
+
messageId: 'no-classname-prop'
|
|
56
|
+
});
|
|
28
57
|
}
|
|
29
58
|
};
|
|
30
59
|
}
|
package/package.json
CHANGED