@atlaskit/eslint-plugin-ui-styling-standard 0.7.1 → 0.8.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/README.md +2 -1
- package/constellation/index/overview.mdx +2 -1
- package/constellation/no-nested-selectors/usage.mdx +60 -0
- package/dist/cjs/presets/all.codegen.js +3 -4
- package/dist/cjs/presets/recommended.codegen.js +3 -4
- package/dist/cjs/rules/convert-props-syntax/index.js +1 -1
- package/dist/cjs/rules/external-rules.js +1 -27
- package/dist/cjs/rules/index.codegen.js +4 -2
- package/dist/cjs/rules/local-cx-xcss/index.js +1 -1
- package/dist/cjs/rules/no-container-queries/index.js +1 -1
- package/dist/cjs/rules/no-important-styles/index.js +1 -1
- package/dist/cjs/rules/no-nested-selectors/index.js +82 -0
- package/dist/es2019/presets/all.codegen.js +3 -4
- package/dist/es2019/presets/recommended.codegen.js +3 -4
- package/dist/es2019/rules/convert-props-syntax/index.js +1 -1
- package/dist/es2019/rules/external-rules.js +1 -27
- package/dist/es2019/rules/index.codegen.js +4 -2
- package/dist/es2019/rules/local-cx-xcss/index.js +1 -1
- package/dist/es2019/rules/no-container-queries/index.js +1 -1
- package/dist/es2019/rules/no-important-styles/index.js +1 -1
- package/dist/es2019/rules/no-nested-selectors/index.js +71 -0
- package/dist/esm/presets/all.codegen.js +3 -4
- package/dist/esm/presets/recommended.codegen.js +3 -4
- package/dist/esm/rules/convert-props-syntax/index.js +1 -1
- package/dist/esm/rules/external-rules.js +1 -27
- package/dist/esm/rules/index.codegen.js +4 -2
- package/dist/esm/rules/local-cx-xcss/index.js +1 -1
- package/dist/esm/rules/no-container-queries/index.js +1 -1
- package/dist/esm/rules/no-important-styles/index.js +1 -1
- package/dist/esm/rules/no-nested-selectors/index.js +76 -0
- package/dist/types/index.codegen.d.ts +4 -6
- package/dist/types/presets/all.codegen.d.ts +3 -4
- package/dist/types/presets/recommended.codegen.d.ts +3 -4
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-nested-selectors/index.d.ts +2 -0
- package/dist/types-ts4.5/index.codegen.d.ts +4 -6
- package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -4
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +3 -4
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-nested-selectors/index.d.ts +2 -0
- package/package.json +2 -1
- package/src/presets/all.codegen.tsx +3 -13
- package/src/presets/recommended.codegen.tsx +3 -13
- package/src/rules/convert-props-syntax/index.tsx +4 -1
- package/src/rules/external-rules.tsx +0 -30
- package/src/rules/index.codegen.tsx +3 -1
- package/src/rules/local-cx-xcss/index.tsx +4 -1
- package/src/rules/no-container-queries/index.tsx +1 -1
- package/src/rules/no-important-styles/index.tsx +1 -1
- package/src/rules/no-nested-selectors/README.md +58 -0
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +236 -0
- package/src/rules/no-nested-selectors/index.tsx +115 -0
- package/tsconfig.app.json +3 -0
- package/dist/cjs/rules/utils/is-supported-import.js +0 -160
- package/dist/es2019/rules/utils/is-supported-import.js +0 -150
- package/dist/esm/rules/utils/is-supported-import.js +0 -154
- package/dist/types/rules/utils/is-supported-import.d.ts +0 -46
- package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +0 -46
- package/src/rules/utils/README.md +0 -1
- package/src/rules/utils/is-supported-import.tsx +0 -227
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#87972](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/87972) [`1f420b2c4a9f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1f420b2c4a9f) - The `@atlaskit/design-system/no-styled-tagged-template-expression` rule will now lint against `styled-components` by default in the preset configurations.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#86779](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86779) [`4b4bbf195e39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4b4bbf195e39) - Created no nested selectors eslint rule to prevent setting styles for child elements
|
|
12
|
+
|
|
13
|
+
## 0.7.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#86638](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/86638) [`f003f07e88e1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f003f07e88e1) - Internal refactoring to use a shared `@atlaskit/eslint-utils` package
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 0.7.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -16,8 +16,9 @@ Not intended for use outside the Atlassian frontend repository.
|
|
|
16
16
|
| <a href="./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 | |
|
|
17
17
|
| <a href="./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 | | |
|
|
18
18
|
| <a href="./src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
19
|
-
| <a href="./src/rules/no-container-queries/README.md">no-container-queries</a> |
|
|
19
|
+
| <a href="./src/rules/no-container-queries/README.md">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
20
20
|
| <a href="./src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
21
|
+
| <a href="./src/rules/no-nested-selectors/README.md">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
21
22
|
| <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 | |
|
|
22
23
|
| <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 | |
|
|
23
24
|
| <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 | |
|
|
@@ -14,8 +14,9 @@ but more are planned to support the standard over time.
|
|
|
14
14
|
| <a href="convert-props-syntax/usage">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 | |
|
|
15
15
|
| <a href="local-cx-xcss/usage">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 | | |
|
|
16
16
|
| <a href="no-classname-prop/usage">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
17
|
-
| <a href="no-container-queries/usage">no-container-queries</a> |
|
|
17
|
+
| <a href="no-container-queries/usage">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
18
18
|
| <a href="no-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
19
|
+
| <a href="no-nested-selectors/usage">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
19
20
|
| <a href="consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
|
|
20
21
|
| <a href="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 | |
|
|
21
22
|
| <a href="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 | |
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# no-nested-selectors
|
|
2
|
+
|
|
3
|
+
This rule prevents the usage of the nested selectors in style declarations. Avoid setting styles for any child elements or elements that require context from other elements.
|
|
4
|
+
|
|
5
|
+
## Examples
|
|
6
|
+
|
|
7
|
+
### Incorrect
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { css } from '@compiled/react';
|
|
11
|
+
const styles = css({
|
|
12
|
+
h2: {
|
|
13
|
+
fontSize: '1.5rem',
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { styled } from '@compiled/react';
|
|
20
|
+
const Component = styled.div({
|
|
21
|
+
'*': {
|
|
22
|
+
padding: 0,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { styled } from '@compiled/react';
|
|
29
|
+
const Component = styled.div({
|
|
30
|
+
'.myclass': {
|
|
31
|
+
padding: 0,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Correct
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import { css } from '@compiled/react';
|
|
40
|
+
const styles = css({
|
|
41
|
+
display: 'flex',
|
|
42
|
+
flexDirection: 'column',
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Options
|
|
47
|
+
|
|
48
|
+
### importSources
|
|
49
|
+
|
|
50
|
+
By default, this rule will check `css` usages from:
|
|
51
|
+
|
|
52
|
+
- `@atlaskit/css`
|
|
53
|
+
- `@atlaskit/primitives`
|
|
54
|
+
- `@compiled/react`
|
|
55
|
+
- `@emotion/react`
|
|
56
|
+
- `@emotion/core`
|
|
57
|
+
- `@emotion/styled`
|
|
58
|
+
- `styled-components`
|
|
59
|
+
|
|
60
|
+
To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -17,14 +17,13 @@ var _default = exports.default = {
|
|
|
17
17
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
18
18
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
19
19
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
20
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
20
21
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
21
22
|
excludeReactComponents: true
|
|
22
23
|
}],
|
|
23
24
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
24
25
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
25
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
26
|
-
importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
|
|
27
|
-
}],
|
|
26
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
28
27
|
'@compiled/no-suppress-xcss': 'warn',
|
|
29
28
|
'@compiled/no-js-xcss': 'warn',
|
|
30
29
|
'@atlaskit/design-system/no-empty-styled-expression': ['warn', {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
9
|
-
* @codegen <<SignedSource::
|
|
9
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -17,14 +17,13 @@ var _default = exports.default = {
|
|
|
17
17
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
18
18
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
19
19
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
20
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
20
21
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
21
22
|
excludeReactComponents: true
|
|
22
23
|
}],
|
|
23
24
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
24
25
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
25
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
26
|
-
importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
|
|
27
|
-
}],
|
|
26
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
28
27
|
'@compiled/no-suppress-xcss': 'warn',
|
|
29
28
|
'@compiled/no-js-xcss': 'warn',
|
|
30
29
|
'@atlaskit/design-system/no-empty-styled-expression': ['warn', {
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
8
|
var _eslintScope = require("eslint-scope");
|
|
9
9
|
var _createRule = require("../utils/create-rule");
|
|
10
|
-
var _isSupportedImport = require("
|
|
10
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
11
11
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
12
12
|
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; } } }; }
|
|
13
13
|
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); }
|
|
@@ -8,29 +8,6 @@ var _createRule = require("./utils/create-rule");
|
|
|
8
8
|
/** External rules must be scoped, have a display name, and external urls. */
|
|
9
9
|
|
|
10
10
|
var importSources = ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components'];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Same as importSources, but excludes `styled-components` because the type-checking
|
|
14
|
-
* for `styled-components` does not support the `no-styled-tagged-template-expression`
|
|
15
|
-
* lint output for this:
|
|
16
|
-
*
|
|
17
|
-
* export const Container = styled(Section)`
|
|
18
|
-
* max-height: ${gridSize * 46}px;
|
|
19
|
-
* overflow: auto;
|
|
20
|
-
* `;
|
|
21
|
-
*
|
|
22
|
-
* export const ErrorStateContainer = styled(Container)`
|
|
23
|
-
* margin: ${
|
|
24
|
-
* (props: any) =>
|
|
25
|
-
* props.canManageAutomations // Use negative margin to reduce whitespace when the Footer component is shown
|
|
26
|
-
* ? `${gridSize * -4}px ${gridSize * 2}px`
|
|
27
|
-
* : `0 ${gridSize * 2}px`
|
|
28
|
-
* };
|
|
29
|
-
* `;
|
|
30
|
-
*/
|
|
31
|
-
var noStyledTaggedTemplateExpressionImportSources = ['@compiled/react', '@atlaskit/css',
|
|
32
|
-
// doesn't do anything because @atlaskit/css doesn't expose a styled API
|
|
33
|
-
'@emotion/core', '@emotion/react', '@emotion/styled'];
|
|
34
11
|
var externalRules = exports.externalRules = [{
|
|
35
12
|
name: '@atlaskit/design-system/consistent-css-prop-usage',
|
|
36
13
|
displayName: 'consistent-css-prop-usage',
|
|
@@ -83,10 +60,7 @@ var externalRules = exports.externalRules = [{
|
|
|
83
60
|
url: (0, _createRule.getRuleUrl)('no-styled-tagged-template-expression'),
|
|
84
61
|
externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage',
|
|
85
62
|
recommended: true,
|
|
86
|
-
severity: 'warn'
|
|
87
|
-
pluginConfig: {
|
|
88
|
-
importSources: noStyledTaggedTemplateExpressionImportSources
|
|
89
|
-
}
|
|
63
|
+
severity: 'warn'
|
|
90
64
|
}
|
|
91
65
|
}, {
|
|
92
66
|
name: '@compiled/no-suppress-xcss',
|
|
@@ -10,9 +10,10 @@ var _localCxXcss = _interopRequireDefault(require("./local-cx-xcss"));
|
|
|
10
10
|
var _noClassnameProp = _interopRequireDefault(require("./no-classname-prop"));
|
|
11
11
|
var _noContainerQueries = _interopRequireDefault(require("./no-container-queries"));
|
|
12
12
|
var _noImportantStyles = _interopRequireDefault(require("./no-important-styles"));
|
|
13
|
+
var _noNestedSelectors = _interopRequireDefault(require("./no-nested-selectors"));
|
|
13
14
|
/**
|
|
14
15
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
15
|
-
* @codegen <<SignedSource::
|
|
16
|
+
* @codegen <<SignedSource::c50c5112f3633542ef17c291cd9d88a8>>
|
|
16
17
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
17
18
|
*/
|
|
18
19
|
var _default = exports.default = {
|
|
@@ -20,5 +21,6 @@ var _default = exports.default = {
|
|
|
20
21
|
'local-cx-xcss': _localCxXcss.default,
|
|
21
22
|
'no-classname-prop': _noClassnameProp.default,
|
|
22
23
|
'no-container-queries': _noContainerQueries.default,
|
|
23
|
-
'no-important-styles': _noImportantStyles.default
|
|
24
|
+
'no-important-styles': _noImportantStyles.default,
|
|
25
|
+
'no-nested-selectors': _noNestedSelectors.default
|
|
24
26
|
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.rule = exports.default = void 0;
|
|
7
7
|
var _createRule = require("../utils/create-rule");
|
|
8
|
-
var _isSupportedImport = require("
|
|
8
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
9
9
|
var IMPORT_SOURCES = [_isSupportedImport.CSS_IN_JS_IMPORTS.compiled, _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
10
10
|
function getParentJSXAttribute(node) {
|
|
11
11
|
var parent = node.parent;
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
8
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
9
9
|
var _createRule = require("../utils/create-rule");
|
|
10
|
-
var _isSupportedImport = require("
|
|
10
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
11
11
|
var schema = [{
|
|
12
12
|
type: 'object',
|
|
13
13
|
properties: {
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.rule = exports.default = void 0;
|
|
8
8
|
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
9
9
|
var _createRule = require("../utils/create-rule");
|
|
10
|
-
var _isSupportedImport = require("
|
|
10
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
11
11
|
var schema = [{
|
|
12
12
|
type: 'object',
|
|
13
13
|
properties: {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.rule = exports.default = void 0;
|
|
7
|
+
var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
|
|
8
|
+
var _createRule = require("../utils/create-rule");
|
|
9
|
+
var schema = [{
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
importSources: {
|
|
13
|
+
type: 'array',
|
|
14
|
+
items: {
|
|
15
|
+
type: 'string'
|
|
16
|
+
},
|
|
17
|
+
uniqueItems: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}];
|
|
21
|
+
var getCssSelector = function getCssSelector(node) {
|
|
22
|
+
if (node.key.type === 'Literal' && typeof node.key.value === 'string') {
|
|
23
|
+
return node.key.value;
|
|
24
|
+
}
|
|
25
|
+
if (node.key.type === 'Identifier' && typeof node.key.name === 'string') {
|
|
26
|
+
return node.key.name;
|
|
27
|
+
}
|
|
28
|
+
if (node.key.type === 'TemplateLiteral') {
|
|
29
|
+
return node.key.quasis.map(function (quasi) {
|
|
30
|
+
return quasi.value.raw;
|
|
31
|
+
}).join(' ');
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
36
|
+
meta: {
|
|
37
|
+
name: 'no-nested-selectors',
|
|
38
|
+
docs: {
|
|
39
|
+
description: 'Prevents usage of nested selectors within css styling',
|
|
40
|
+
recommended: true,
|
|
41
|
+
severity: 'warn'
|
|
42
|
+
},
|
|
43
|
+
messages: {
|
|
44
|
+
'no-nested-selectors': 'Please avoid setting styles for child elements or elements that require context from other elements.'
|
|
45
|
+
},
|
|
46
|
+
type: 'problem',
|
|
47
|
+
schema: schema
|
|
48
|
+
},
|
|
49
|
+
create: function create(context) {
|
|
50
|
+
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
51
|
+
return {
|
|
52
|
+
'CallExpression Property': function CallExpressionProperty(node) {
|
|
53
|
+
var _context$getScope = context.getScope(),
|
|
54
|
+
references = _context$getScope.references;
|
|
55
|
+
var ancestors = context.getAncestors();
|
|
56
|
+
if (ancestors.every(function (ancestor) {
|
|
57
|
+
return ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !((0, _isSupportedImport.isCss)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isStyled)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isKeyframes)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isCssMap)(ancestor.callee, references, importSources) || (0, _isSupportedImport.isXcss)(ancestor.callee, references, importSources));
|
|
58
|
+
})) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (node.value.type !== 'ObjectExpression') {
|
|
62
|
+
// If the value is a CSS object, safe to assume we're at a CSS selector
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
var cssSelector = getCssSelector(node);
|
|
66
|
+
if (cssSelector === null) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
var tokens = cssSelector.split(/[, ]+/);
|
|
70
|
+
if (!tokens.every(function (token) {
|
|
71
|
+
return token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&');
|
|
72
|
+
})) {
|
|
73
|
+
context.report({
|
|
74
|
+
messageId: 'no-nested-selectors',
|
|
75
|
+
node: node.key
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
var _default = exports.default = rule;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -11,14 +11,13 @@ export default {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
15
16
|
excludeReactComponents: true
|
|
16
17
|
}],
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
|
|
21
|
-
}],
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
22
21
|
'@compiled/no-suppress-xcss': 'warn',
|
|
23
22
|
'@compiled/no-js-xcss': 'warn',
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': ['warn', {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -11,14 +11,13 @@ export default {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
15
16
|
excludeReactComponents: true
|
|
16
17
|
}],
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
|
|
21
|
-
}],
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
22
21
|
'@compiled/no-suppress-xcss': 'warn',
|
|
23
22
|
'@compiled/no-js-xcss': 'warn',
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': ['warn', {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { analyze } from 'eslint-scope';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import { isStyledComponents, isEmotion } from '
|
|
3
|
+
import { isStyledComponents, isEmotion } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
4
|
import ESTraverse from 'estraverse';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -3,29 +3,6 @@ import { getRuleUrl } from './utils/create-rule';
|
|
|
3
3
|
/** External rules must be scoped, have a display name, and external urls. */
|
|
4
4
|
|
|
5
5
|
const importSources = ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components'];
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Same as importSources, but excludes `styled-components` because the type-checking
|
|
9
|
-
* for `styled-components` does not support the `no-styled-tagged-template-expression`
|
|
10
|
-
* lint output for this:
|
|
11
|
-
*
|
|
12
|
-
* export const Container = styled(Section)`
|
|
13
|
-
* max-height: ${gridSize * 46}px;
|
|
14
|
-
* overflow: auto;
|
|
15
|
-
* `;
|
|
16
|
-
*
|
|
17
|
-
* export const ErrorStateContainer = styled(Container)`
|
|
18
|
-
* margin: ${
|
|
19
|
-
* (props: any) =>
|
|
20
|
-
* props.canManageAutomations // Use negative margin to reduce whitespace when the Footer component is shown
|
|
21
|
-
* ? `${gridSize * -4}px ${gridSize * 2}px`
|
|
22
|
-
* : `0 ${gridSize * 2}px`
|
|
23
|
-
* };
|
|
24
|
-
* `;
|
|
25
|
-
*/
|
|
26
|
-
const noStyledTaggedTemplateExpressionImportSources = ['@compiled/react', '@atlaskit/css',
|
|
27
|
-
// doesn't do anything because @atlaskit/css doesn't expose a styled API
|
|
28
|
-
'@emotion/core', '@emotion/react', '@emotion/styled'];
|
|
29
6
|
export const externalRules = [{
|
|
30
7
|
name: '@atlaskit/design-system/consistent-css-prop-usage',
|
|
31
8
|
displayName: 'consistent-css-prop-usage',
|
|
@@ -78,10 +55,7 @@ export const externalRules = [{
|
|
|
78
55
|
url: getRuleUrl('no-styled-tagged-template-expression'),
|
|
79
56
|
externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage',
|
|
80
57
|
recommended: true,
|
|
81
|
-
severity: 'warn'
|
|
82
|
-
pluginConfig: {
|
|
83
|
-
importSources: noStyledTaggedTemplateExpressionImportSources
|
|
84
|
-
}
|
|
58
|
+
severity: 'warn'
|
|
85
59
|
}
|
|
86
60
|
}, {
|
|
87
61
|
name: '@compiled/no-suppress-xcss',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::c50c5112f3633542ef17c291cd9d88a8>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import convertPropsSyntax from './convert-props-syntax';
|
|
@@ -8,10 +8,12 @@ import localCxXcss from './local-cx-xcss';
|
|
|
8
8
|
import noClassnameProp from './no-classname-prop';
|
|
9
9
|
import noContainerQueries from './no-container-queries';
|
|
10
10
|
import noImportantStyles from './no-important-styles';
|
|
11
|
+
import noNestedSelectors from './no-nested-selectors';
|
|
11
12
|
export default {
|
|
12
13
|
'convert-props-syntax': convertPropsSyntax,
|
|
13
14
|
'local-cx-xcss': localCxXcss,
|
|
14
15
|
'no-classname-prop': noClassnameProp,
|
|
15
16
|
'no-container-queries': noContainerQueries,
|
|
16
|
-
'no-important-styles': noImportantStyles
|
|
17
|
+
'no-important-styles': noImportantStyles,
|
|
18
|
+
'no-nested-selectors': noNestedSelectors
|
|
17
19
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
-
import { CSS_IN_JS_IMPORTS, isCxFunction } from '
|
|
2
|
+
import { CSS_IN_JS_IMPORTS, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
|
|
3
3
|
const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
|
|
4
4
|
function getParentJSXAttribute(node) {
|
|
5
5
|
let parent = node.parent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import estraverse from 'estraverse';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '
|
|
3
|
+
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
4
|
const schema = [{
|
|
5
5
|
type: 'object',
|
|
6
6
|
properties: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import estraverse from 'estraverse';
|
|
2
2
|
import { createLintRule } from '../utils/create-rule';
|
|
3
|
-
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '
|
|
3
|
+
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '@atlaskit/eslint-utils/is-supported-import';
|
|
4
4
|
const schema = [{
|
|
5
5
|
type: 'object',
|
|
6
6
|
properties: {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { isStyled, isCss, isKeyframes, isCssMap, isXcss, getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
const schema = [{
|
|
4
|
+
type: 'object',
|
|
5
|
+
properties: {
|
|
6
|
+
importSources: {
|
|
7
|
+
type: 'array',
|
|
8
|
+
items: {
|
|
9
|
+
type: 'string'
|
|
10
|
+
},
|
|
11
|
+
uniqueItems: true
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}];
|
|
15
|
+
const getCssSelector = node => {
|
|
16
|
+
if (node.key.type === 'Literal' && typeof node.key.value === 'string') {
|
|
17
|
+
return node.key.value;
|
|
18
|
+
}
|
|
19
|
+
if (node.key.type === 'Identifier' && typeof node.key.name === 'string') {
|
|
20
|
+
return node.key.name;
|
|
21
|
+
}
|
|
22
|
+
if (node.key.type === 'TemplateLiteral') {
|
|
23
|
+
return node.key.quasis.map(quasi => quasi.value.raw).join(' ');
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
export const rule = createLintRule({
|
|
28
|
+
meta: {
|
|
29
|
+
name: 'no-nested-selectors',
|
|
30
|
+
docs: {
|
|
31
|
+
description: 'Prevents usage of nested selectors within css styling',
|
|
32
|
+
recommended: true,
|
|
33
|
+
severity: 'warn'
|
|
34
|
+
},
|
|
35
|
+
messages: {
|
|
36
|
+
'no-nested-selectors': 'Please avoid setting styles for child elements or elements that require context from other elements.'
|
|
37
|
+
},
|
|
38
|
+
type: 'problem',
|
|
39
|
+
schema
|
|
40
|
+
},
|
|
41
|
+
create(context) {
|
|
42
|
+
const importSources = getImportSources(context);
|
|
43
|
+
return {
|
|
44
|
+
'CallExpression Property': node => {
|
|
45
|
+
const {
|
|
46
|
+
references
|
|
47
|
+
} = context.getScope();
|
|
48
|
+
const ancestors = context.getAncestors();
|
|
49
|
+
if (ancestors.every(ancestor => ancestor.type !== 'CallExpression' || !(ancestor !== null && ancestor !== void 0 && ancestor.callee) || !(isCss(ancestor.callee, references, importSources) || isStyled(ancestor.callee, references, importSources) || isKeyframes(ancestor.callee, references, importSources) || isCssMap(ancestor.callee, references, importSources) || isXcss(ancestor.callee, references, importSources)))) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (node.value.type !== 'ObjectExpression') {
|
|
53
|
+
// If the value is a CSS object, safe to assume we're at a CSS selector
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const cssSelector = getCssSelector(node);
|
|
57
|
+
if (cssSelector === null) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const tokens = cssSelector.split(/[, ]+/);
|
|
61
|
+
if (!tokens.every(token => token.length === 0 || token.startsWith('&') || token.startsWith(':') || token.includes('+') || token.includes('~') || token.endsWith('&'))) {
|
|
62
|
+
context.report({
|
|
63
|
+
messageId: 'no-nested-selectors',
|
|
64
|
+
node: node.key
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
export default rule;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::7d08e77b09892b3650a472341ec77df3>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -11,14 +11,13 @@ export default {
|
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
12
|
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
13
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
14
|
+
'@atlaskit/ui-styling-standard/no-nested-selectors': 'warn',
|
|
14
15
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
15
16
|
excludeReactComponents: true
|
|
16
17
|
}],
|
|
17
18
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
|
|
18
19
|
'@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
|
|
19
|
-
'@atlaskit/design-system/no-styled-tagged-template-expression':
|
|
20
|
-
importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
|
|
21
|
-
}],
|
|
20
|
+
'@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
|
|
22
21
|
'@compiled/no-suppress-xcss': 'warn',
|
|
23
22
|
'@compiled/no-js-xcss': 'warn',
|
|
24
23
|
'@atlaskit/design-system/no-empty-styled-expression': ['warn', {
|