@atlaskit/eslint-plugin-ui-styling-standard 0.7.0 → 0.7.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 +6 -0
- package/README.md +17 -16
- package/constellation/index/overview.mdx +17 -16
- package/constellation/no-container-queries/usage.mdx +50 -0
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-container-queries/index.js +76 -0
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-container-queries/index.js +70 -0
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-container-queries/index.js +69 -0
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-container-queries/index.d.ts +2 -0
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-container-queries/index.d.ts +2 -0
- package/package.json +2 -2
- package/src/presets/all.codegen.tsx +2 -1
- package/src/presets/recommended.codegen.tsx +2 -1
- package/src/rules/index.codegen.tsx +3 -1
- package/src/rules/no-container-queries/README.md +48 -0
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +142 -0
- package/src/rules/no-container-queries/index.tsx +100 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#84413](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/84413) [`2860b53c90d9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2860b53c90d9) - Added eslint rule to block @container queries in css styling
|
|
8
|
+
|
|
3
9
|
## 0.7.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -11,21 +11,22 @@ Not intended for use outside the Atlassian frontend repository.
|
|
|
11
11
|
<!-- START_RULE_TABLE_CODEGEN -->
|
|
12
12
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
|
|
13
13
|
|
|
14
|
-
| Rule | Description
|
|
15
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
16
|
-
| <a href="./src/rules/convert-props-syntax/README.md">convert-props-syntax</a> | Convert props syntax that is unsupported by
|
|
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.
|
|
18
|
-
| <a href="./src/rules/no-classname-prop/README.md">no-classname-prop</a> | Disallows usage of the `className` prop in JSX
|
|
19
|
-
| <a href="./src/rules/no-
|
|
20
|
-
| <a href="
|
|
21
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/
|
|
22
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
23
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
24
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
25
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
26
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
27
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
28
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-exported-
|
|
29
|
-
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-
|
|
14
|
+
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
15
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
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
|
+
| <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
|
+
| <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> | Disallows important style declarations | Yes | | |
|
|
20
|
+
| <a href="./src/rules/no-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
21
|
+
| <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
|
+
| <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
|
+
| <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 | |
|
|
24
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
25
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-suppress-xcss/usage">@compiled/no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop. | Yes | | |
|
|
26
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-js-xcss/usage">@compiled/no-js-xcss</a> | Disallows using xcss prop inside JavaScript files. | Yes | | |
|
|
27
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
|
|
28
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-exported-css/usage">@atlaskit/design-system/no-exported-css</a> | Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
|
|
29
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-exported-keyframes/usage">@atlaskit/design-system/no-exported-keyframes</a> | Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
|
|
30
|
+
| <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-invalid-css-map/usage">@atlaskit/design-system/no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
|
|
30
31
|
|
|
31
32
|
<!-- END_RULE_TABLE_CODEGEN -->
|
|
@@ -9,22 +9,23 @@ but more are planned to support the standard over time.
|
|
|
9
9
|
<!-- START_RULE_TABLE_CODEGEN -->
|
|
10
10
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
|
|
11
11
|
|
|
12
|
-
| Rule | Description
|
|
13
|
-
| --------------------------------------------------------------------------------------------------------------------------- |
|
|
14
|
-
| <a href="convert-props-syntax/usage">convert-props-syntax</a> | Convert props syntax that is unsupported by
|
|
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.
|
|
16
|
-
| <a href="no-classname-prop/usage">no-classname-prop</a> | Disallows usage of the `className` prop in JSX
|
|
17
|
-
| <a href="no-
|
|
18
|
-
| <a href="
|
|
19
|
-
| <a href="
|
|
20
|
-
| <a href="no-
|
|
21
|
-
| <a href="no-
|
|
22
|
-
| <a href="no-
|
|
23
|
-
| <a href="no-
|
|
24
|
-
| <a href="no-
|
|
25
|
-
| <a href="no-
|
|
26
|
-
| <a href="no-exported-
|
|
27
|
-
| <a href="no-
|
|
12
|
+
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
13
|
+
| --------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
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
|
+
| <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
|
+
| <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> | Disallows important style declarations | Yes | | |
|
|
18
|
+
| <a href="no-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
19
|
+
| <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
|
+
| <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
|
+
| <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 | |
|
|
22
|
+
| <a href="no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
|
|
23
|
+
| <a href="no-suppress-xcss/usage">@compiled/no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop. | Yes | | |
|
|
24
|
+
| <a href="no-js-xcss/usage">@compiled/no-js-xcss</a> | Disallows using xcss prop inside JavaScript files. | Yes | | |
|
|
25
|
+
| <a href="no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
|
|
26
|
+
| <a href="no-exported-css/usage">@atlaskit/design-system/no-exported-css</a> | Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
|
|
27
|
+
| <a href="no-exported-keyframes/usage">@atlaskit/design-system/no-exported-keyframes</a> | Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
|
|
28
|
+
| <a href="no-invalid-css-map/usage">@atlaskit/design-system/no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
|
|
28
29
|
|
|
29
30
|
<!-- END_RULE_TABLE_CODEGEN -->
|
|
30
31
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# no-container-queries
|
|
2
|
+
|
|
3
|
+
This rule prevents the usage of the `@container` query in style declarations.
|
|
4
|
+
|
|
5
|
+
Container queries break the rules of scope and aren’t guaranteed to be deterministic or type safe and isn’t fully supported across our frontend tech stacks.
|
|
6
|
+
|
|
7
|
+
We suggest you explore the use alternatives such as client JavaScript-based APIs or media queries.
|
|
8
|
+
|
|
9
|
+
## Examples
|
|
10
|
+
|
|
11
|
+
### Incorrect
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { css } from '@compiled/react';
|
|
15
|
+
|
|
16
|
+
const styles = css({
|
|
17
|
+
'@container (width > 400px)': {
|
|
18
|
+
h2: {
|
|
19
|
+
fontSize: '1.5rem',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Correct
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { css } from '@compiled/react';
|
|
29
|
+
|
|
30
|
+
const containerStyles = css({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
flexDirection: 'column',
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
### importSources
|
|
39
|
+
|
|
40
|
+
By default, this rule will check `css` usages from:
|
|
41
|
+
|
|
42
|
+
- `@atlaskit/css`
|
|
43
|
+
- `@atlaskit/primitives`
|
|
44
|
+
- `@compiled/react`
|
|
45
|
+
- `@emotion/react`
|
|
46
|
+
- `@emotion/core`
|
|
47
|
+
- `@emotion/styled`
|
|
48
|
+
- `styled-components`
|
|
49
|
+
|
|
50
|
+
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::2e134e292f949b29bfd0b29d128e684a>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -15,6 +15,7 @@ var _default = exports.default = {
|
|
|
15
15
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
16
16
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
17
17
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
18
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
18
19
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
19
20
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
20
21
|
excludeReactComponents: true
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -15,6 +15,7 @@ var _default = exports.default = {
|
|
|
15
15
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
16
16
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
17
17
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
18
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
18
19
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
19
20
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
20
21
|
excludeReactComponents: true
|
|
@@ -8,15 +8,17 @@ exports.default = void 0;
|
|
|
8
8
|
var _convertPropsSyntax = _interopRequireDefault(require("./convert-props-syntax"));
|
|
9
9
|
var _localCxXcss = _interopRequireDefault(require("./local-cx-xcss"));
|
|
10
10
|
var _noClassnameProp = _interopRequireDefault(require("./no-classname-prop"));
|
|
11
|
+
var _noContainerQueries = _interopRequireDefault(require("./no-container-queries"));
|
|
11
12
|
var _noImportantStyles = _interopRequireDefault(require("./no-important-styles"));
|
|
12
13
|
/**
|
|
13
14
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
14
|
-
* @codegen <<SignedSource::
|
|
15
|
+
* @codegen <<SignedSource::3504ce124f49b7eca8abafb5a0bd6884>>
|
|
15
16
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
16
17
|
*/
|
|
17
18
|
var _default = exports.default = {
|
|
18
19
|
'convert-props-syntax': _convertPropsSyntax.default,
|
|
19
20
|
'local-cx-xcss': _localCxXcss.default,
|
|
20
21
|
'no-classname-prop': _noClassnameProp.default,
|
|
22
|
+
'no-container-queries': _noContainerQueries.default,
|
|
21
23
|
'no-important-styles': _noImportantStyles.default
|
|
22
24
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.rule = exports.default = void 0;
|
|
8
|
+
var _estraverse = _interopRequireDefault(require("estraverse"));
|
|
9
|
+
var _createRule = require("../utils/create-rule");
|
|
10
|
+
var _isSupportedImport = require("../utils/is-supported-import");
|
|
11
|
+
var schema = [{
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
importSources: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
items: {
|
|
17
|
+
type: 'string'
|
|
18
|
+
},
|
|
19
|
+
uniqueItems: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
var rule = exports.rule = (0, _createRule.createLintRule)({
|
|
24
|
+
meta: {
|
|
25
|
+
name: 'no-container-queries',
|
|
26
|
+
docs: {
|
|
27
|
+
description: 'Prevents usage of @container query within css styling',
|
|
28
|
+
recommended: true,
|
|
29
|
+
severity: 'warn'
|
|
30
|
+
},
|
|
31
|
+
messages: {
|
|
32
|
+
'no-container-queries': 'We block @container queries as they break scope and are not type-safe. We suggest alternatives such as JS-based APIs or @media queries.'
|
|
33
|
+
},
|
|
34
|
+
type: 'problem',
|
|
35
|
+
schema: schema
|
|
36
|
+
},
|
|
37
|
+
create: function create(context) {
|
|
38
|
+
var importSources = (0, _isSupportedImport.getImportSources)(context);
|
|
39
|
+
return {
|
|
40
|
+
CallExpression: function CallExpression(node) {
|
|
41
|
+
var _context$getScope = context.getScope(),
|
|
42
|
+
references = _context$getScope.references;
|
|
43
|
+
if ((0, _isSupportedImport.isCss)(node.callee, references, importSources) || (0, _isSupportedImport.isStyled)(node.callee, references, importSources) || (0, _isSupportedImport.isKeyframes)(node.callee, references, importSources) || (0, _isSupportedImport.isCssMap)(node.callee, references, importSources) || (0, _isSupportedImport.isXcss)(node.callee, references, importSources)) {
|
|
44
|
+
_estraverse.default.traverse(node, {
|
|
45
|
+
enter: function enter(node) {
|
|
46
|
+
var _node$key$value, _node$key$quasis$;
|
|
47
|
+
if (node.type !== 'Property') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (node.key.type !== 'Literal' && node.key.type !== 'TemplateLiteral') {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (node.key.type === 'Literal' && (_node$key$value = node.key.value) !== null && _node$key$value !== void 0 && _node$key$value.toString().match(/@container/)) {
|
|
54
|
+
context.report({
|
|
55
|
+
node: node.key,
|
|
56
|
+
messageId: 'no-container-queries'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (node.key.type === 'TemplateLiteral' && (_node$key$quasis$ = node.key.quasis[0]) !== null && _node$key$quasis$ !== void 0 && _node$key$quasis$.value.raw.match(/@container/)) {
|
|
60
|
+
context.report({
|
|
61
|
+
node: node.key,
|
|
62
|
+
messageId: 'no-container-queries'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
68
|
+
*/
|
|
69
|
+
fallback: 'iteration'
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -9,6 +9,7 @@ export default {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
14
15
|
excludeReactComponents: true
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -9,6 +9,7 @@ export default {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
14
15
|
excludeReactComponents: true
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::3504ce124f49b7eca8abafb5a0bd6884>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import convertPropsSyntax from './convert-props-syntax';
|
|
7
7
|
import localCxXcss from './local-cx-xcss';
|
|
8
8
|
import noClassnameProp from './no-classname-prop';
|
|
9
|
+
import noContainerQueries from './no-container-queries';
|
|
9
10
|
import noImportantStyles from './no-important-styles';
|
|
10
11
|
export default {
|
|
11
12
|
'convert-props-syntax': convertPropsSyntax,
|
|
12
13
|
'local-cx-xcss': localCxXcss,
|
|
13
14
|
'no-classname-prop': noClassnameProp,
|
|
15
|
+
'no-container-queries': noContainerQueries,
|
|
14
16
|
'no-important-styles': noImportantStyles
|
|
15
17
|
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import estraverse from 'estraverse';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '../utils/is-supported-import';
|
|
4
|
+
const schema = [{
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
importSources: {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: {
|
|
10
|
+
type: 'string'
|
|
11
|
+
},
|
|
12
|
+
uniqueItems: true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}];
|
|
16
|
+
export const rule = createLintRule({
|
|
17
|
+
meta: {
|
|
18
|
+
name: 'no-container-queries',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Prevents usage of @container query within css styling',
|
|
21
|
+
recommended: true,
|
|
22
|
+
severity: 'warn'
|
|
23
|
+
},
|
|
24
|
+
messages: {
|
|
25
|
+
'no-container-queries': 'We block @container queries as they break scope and are not type-safe. We suggest alternatives such as JS-based APIs or @media queries.'
|
|
26
|
+
},
|
|
27
|
+
type: 'problem',
|
|
28
|
+
schema
|
|
29
|
+
},
|
|
30
|
+
create(context) {
|
|
31
|
+
const importSources = getImportSources(context);
|
|
32
|
+
return {
|
|
33
|
+
CallExpression(node) {
|
|
34
|
+
const {
|
|
35
|
+
references
|
|
36
|
+
} = context.getScope();
|
|
37
|
+
if (isCss(node.callee, references, importSources) || isStyled(node.callee, references, importSources) || isKeyframes(node.callee, references, importSources) || isCssMap(node.callee, references, importSources) || isXcss(node.callee, references, importSources)) {
|
|
38
|
+
estraverse.traverse(node, {
|
|
39
|
+
enter(node) {
|
|
40
|
+
var _node$key$value, _node$key$quasis$;
|
|
41
|
+
if (node.type !== 'Property') {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (node.key.type !== 'Literal' && node.key.type !== 'TemplateLiteral') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (node.key.type === 'Literal' && (_node$key$value = node.key.value) !== null && _node$key$value !== void 0 && _node$key$value.toString().match(/@container/)) {
|
|
48
|
+
context.report({
|
|
49
|
+
node: node.key,
|
|
50
|
+
messageId: 'no-container-queries'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (node.key.type === 'TemplateLiteral' && (_node$key$quasis$ = node.key.quasis[0]) !== null && _node$key$quasis$ !== void 0 && _node$key$quasis$.value.raw.match(/@container/)) {
|
|
54
|
+
context.report({
|
|
55
|
+
node: node.key,
|
|
56
|
+
messageId: 'no-container-queries'
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
62
|
+
*/
|
|
63
|
+
fallback: 'iteration'
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -9,6 +9,7 @@ export default {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
14
15
|
excludeReactComponents: true
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -9,6 +9,7 @@ export default {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
|
|
14
15
|
excludeReactComponents: true
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::3504ce124f49b7eca8abafb5a0bd6884>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import convertPropsSyntax from './convert-props-syntax';
|
|
7
7
|
import localCxXcss from './local-cx-xcss';
|
|
8
8
|
import noClassnameProp from './no-classname-prop';
|
|
9
|
+
import noContainerQueries from './no-container-queries';
|
|
9
10
|
import noImportantStyles from './no-important-styles';
|
|
10
11
|
export default {
|
|
11
12
|
'convert-props-syntax': convertPropsSyntax,
|
|
12
13
|
'local-cx-xcss': localCxXcss,
|
|
13
14
|
'no-classname-prop': noClassnameProp,
|
|
15
|
+
'no-container-queries': noContainerQueries,
|
|
14
16
|
'no-important-styles': noImportantStyles
|
|
15
17
|
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import estraverse from 'estraverse';
|
|
2
|
+
import { createLintRule } from '../utils/create-rule';
|
|
3
|
+
import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '../utils/is-supported-import';
|
|
4
|
+
var schema = [{
|
|
5
|
+
type: 'object',
|
|
6
|
+
properties: {
|
|
7
|
+
importSources: {
|
|
8
|
+
type: 'array',
|
|
9
|
+
items: {
|
|
10
|
+
type: 'string'
|
|
11
|
+
},
|
|
12
|
+
uniqueItems: true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}];
|
|
16
|
+
export var rule = createLintRule({
|
|
17
|
+
meta: {
|
|
18
|
+
name: 'no-container-queries',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Prevents usage of @container query within css styling',
|
|
21
|
+
recommended: true,
|
|
22
|
+
severity: 'warn'
|
|
23
|
+
},
|
|
24
|
+
messages: {
|
|
25
|
+
'no-container-queries': 'We block @container queries as they break scope and are not type-safe. We suggest alternatives such as JS-based APIs or @media queries.'
|
|
26
|
+
},
|
|
27
|
+
type: 'problem',
|
|
28
|
+
schema: schema
|
|
29
|
+
},
|
|
30
|
+
create: function create(context) {
|
|
31
|
+
var importSources = getImportSources(context);
|
|
32
|
+
return {
|
|
33
|
+
CallExpression: function CallExpression(node) {
|
|
34
|
+
var _context$getScope = context.getScope(),
|
|
35
|
+
references = _context$getScope.references;
|
|
36
|
+
if (isCss(node.callee, references, importSources) || isStyled(node.callee, references, importSources) || isKeyframes(node.callee, references, importSources) || isCssMap(node.callee, references, importSources) || isXcss(node.callee, references, importSources)) {
|
|
37
|
+
estraverse.traverse(node, {
|
|
38
|
+
enter: function enter(node) {
|
|
39
|
+
var _node$key$value, _node$key$quasis$;
|
|
40
|
+
if (node.type !== 'Property') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (node.key.type !== 'Literal' && node.key.type !== 'TemplateLiteral') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (node.key.type === 'Literal' && (_node$key$value = node.key.value) !== null && _node$key$value !== void 0 && _node$key$value.toString().match(/@container/)) {
|
|
47
|
+
context.report({
|
|
48
|
+
node: node.key,
|
|
49
|
+
messageId: 'no-container-queries'
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (node.key.type === 'TemplateLiteral' && (_node$key$quasis$ = node.key.quasis[0]) !== null && _node$key$quasis$ !== void 0 && _node$key$quasis$.value.raw.match(/@container/)) {
|
|
53
|
+
context.report({
|
|
54
|
+
node: node.key,
|
|
55
|
+
messageId: 'no-container-queries'
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
61
|
+
*/
|
|
62
|
+
fallback: 'iteration'
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
export default rule;
|
|
@@ -6,6 +6,7 @@ export declare const configs: {
|
|
|
6
6
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
7
7
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
8
8
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
9
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
9
10
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
10
11
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
11
12
|
excludeReactComponents: boolean;
|
|
@@ -37,6 +38,7 @@ export declare const configs: {
|
|
|
37
38
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
38
39
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
39
40
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
41
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
40
42
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
41
43
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
42
44
|
excludeReactComponents: boolean;
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
14
15
|
excludeReactComponents: boolean;
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
14
15
|
excludeReactComponents: boolean;
|
|
@@ -2,6 +2,7 @@ declare const _default: {
|
|
|
2
2
|
'convert-props-syntax': import("eslint").Rule.RuleModule;
|
|
3
3
|
'local-cx-xcss': import("eslint").Rule.RuleModule;
|
|
4
4
|
'no-classname-prop': import("eslint").Rule.RuleModule;
|
|
5
|
+
'no-container-queries': import("eslint").Rule.RuleModule;
|
|
5
6
|
'no-important-styles': import("eslint").Rule.RuleModule;
|
|
6
7
|
};
|
|
7
8
|
export default _default;
|
|
@@ -6,6 +6,7 @@ export declare const configs: {
|
|
|
6
6
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
7
7
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
8
8
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
9
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
9
10
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
10
11
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
11
12
|
excludeReactComponents: boolean;
|
|
@@ -37,6 +38,7 @@ export declare const configs: {
|
|
|
37
38
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
38
39
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
39
40
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
41
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
40
42
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
41
43
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
42
44
|
excludeReactComponents: boolean;
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
14
15
|
excludeReactComponents: boolean;
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
declare const _default: {
|
|
@@ -9,6 +9,7 @@ declare const _default: {
|
|
|
9
9
|
'@atlaskit/ui-styling-standard/convert-props-syntax': string;
|
|
10
10
|
'@atlaskit/ui-styling-standard/local-cx-xcss': string;
|
|
11
11
|
'@atlaskit/ui-styling-standard/no-classname-prop': string;
|
|
12
|
+
'@atlaskit/ui-styling-standard/no-container-queries': string;
|
|
12
13
|
'@atlaskit/ui-styling-standard/no-important-styles': string;
|
|
13
14
|
'@atlaskit/design-system/consistent-css-prop-usage': (string | {
|
|
14
15
|
excludeReactComponents: boolean;
|
|
@@ -2,6 +2,7 @@ declare const _default: {
|
|
|
2
2
|
'convert-props-syntax': import("eslint").Rule.RuleModule;
|
|
3
3
|
'local-cx-xcss': import("eslint").Rule.RuleModule;
|
|
4
4
|
'no-classname-prop': import("eslint").Rule.RuleModule;
|
|
5
|
+
'no-container-queries': import("eslint").Rule.RuleModule;
|
|
5
6
|
'no-important-styles': import("eslint").Rule.RuleModule;
|
|
6
7
|
};
|
|
7
8
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-ui-styling-standard",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"author": "Atlassian Pty Ltd",
|
|
5
5
|
"description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
47
|
-
"@atlaskit/eslint-plugin-design-system": "^9.
|
|
47
|
+
"@atlaskit/eslint-plugin-design-system": "^9.2.0",
|
|
48
48
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
49
49
|
"@atlassian/codegen": "*",
|
|
50
50
|
"@compiled/eslint-plugin": "^0.13.6",
|
|
@@ -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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -13,6 +13,7 @@ export default {
|
|
|
13
13
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
14
14
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
15
15
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
16
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
16
17
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
17
18
|
'@atlaskit/design-system/consistent-css-prop-usage': [
|
|
18
19
|
'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::2e134e292f949b29bfd0b29d128e684a>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
export default {
|
|
@@ -13,6 +13,7 @@ export default {
|
|
|
13
13
|
'@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
|
|
14
14
|
'@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
|
|
15
15
|
'@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
|
|
16
|
+
'@atlaskit/ui-styling-standard/no-container-queries': 'warn',
|
|
16
17
|
'@atlaskit/ui-styling-standard/no-important-styles': 'warn',
|
|
17
18
|
'@atlaskit/design-system/consistent-css-prop-usage': [
|
|
18
19
|
'warn',
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::3504ce124f49b7eca8abafb5a0bd6884>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
5
5
|
*/
|
|
6
6
|
import convertPropsSyntax from './convert-props-syntax';
|
|
7
7
|
import localCxXcss from './local-cx-xcss';
|
|
8
8
|
import noClassnameProp from './no-classname-prop';
|
|
9
|
+
import noContainerQueries from './no-container-queries';
|
|
9
10
|
import noImportantStyles from './no-important-styles';
|
|
10
11
|
|
|
11
12
|
export default {
|
|
12
13
|
'convert-props-syntax': convertPropsSyntax,
|
|
13
14
|
'local-cx-xcss': localCxXcss,
|
|
14
15
|
'no-classname-prop': noClassnameProp,
|
|
16
|
+
'no-container-queries': noContainerQueries,
|
|
15
17
|
'no-important-styles': noImportantStyles,
|
|
16
18
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
This rule prevents the usage of the `@container` query in style declarations.
|
|
2
|
+
|
|
3
|
+
Container queries break the rules of scope and aren’t guaranteed to be deterministic or type safe and isn’t fully supported across our frontend tech stacks.
|
|
4
|
+
|
|
5
|
+
We suggest you explore the use alternatives such as client JavaScript-based APIs or media queries.
|
|
6
|
+
|
|
7
|
+
## Examples
|
|
8
|
+
|
|
9
|
+
### Incorrect
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { css } from '@compiled/react';
|
|
13
|
+
|
|
14
|
+
const styles = css({
|
|
15
|
+
'@container (width > 400px)': {
|
|
16
|
+
h2: {
|
|
17
|
+
fontSize: '1.5rem',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Correct
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
import { css } from '@compiled/react';
|
|
27
|
+
|
|
28
|
+
const containerStyles = css({
|
|
29
|
+
display: 'flex',
|
|
30
|
+
flexDirection: 'column',
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Options
|
|
35
|
+
|
|
36
|
+
### importSources
|
|
37
|
+
|
|
38
|
+
By default, this rule will check `css` usages from:
|
|
39
|
+
|
|
40
|
+
- `@atlaskit/css`
|
|
41
|
+
- `@atlaskit/primitives`
|
|
42
|
+
- `@compiled/react`
|
|
43
|
+
- `@emotion/react`
|
|
44
|
+
- `@emotion/core`
|
|
45
|
+
- `@emotion/styled`
|
|
46
|
+
- `styled-components`
|
|
47
|
+
|
|
48
|
+
To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
2
|
+
import rule from '../index';
|
|
3
|
+
|
|
4
|
+
typescriptEslintTester.run(
|
|
5
|
+
'no-container-queries',
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
rule,
|
|
8
|
+
{
|
|
9
|
+
valid: [
|
|
10
|
+
{
|
|
11
|
+
name: 'Basic valid test',
|
|
12
|
+
code: `
|
|
13
|
+
import { css } from '@compiled/react';
|
|
14
|
+
const containerStyles = css({
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
});
|
|
18
|
+
`,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'Custom import sources (subtractive)',
|
|
22
|
+
code: `
|
|
23
|
+
import { css } from '@compiled/react';
|
|
24
|
+
const styles = css({
|
|
25
|
+
'@container (width > 400px)': {
|
|
26
|
+
h2: {
|
|
27
|
+
fontSize: '1.5rem',
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
`,
|
|
32
|
+
options: [
|
|
33
|
+
{
|
|
34
|
+
importSources: [],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
invalid: [
|
|
40
|
+
{
|
|
41
|
+
name: 'Basic test for @container',
|
|
42
|
+
code: `
|
|
43
|
+
import { css } from '@compiled/react';
|
|
44
|
+
|
|
45
|
+
const styles = css({
|
|
46
|
+
'@container (width > 400px)': {
|
|
47
|
+
h2: {
|
|
48
|
+
fontSize: '1.5rem',
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
`,
|
|
53
|
+
errors: [{ messageId: 'no-container-queries' }],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: '@container template literal in styled div',
|
|
57
|
+
code: `
|
|
58
|
+
import { styled } from '@compiled/react';
|
|
59
|
+
|
|
60
|
+
const Component = styled.div({
|
|
61
|
+
[\`@container cardContainer (max-width: \${(CARD_MIN_WIDTH + CARD_MARGIN) * 2}px)\`]: {
|
|
62
|
+
ul: {
|
|
63
|
+
gridTemplateColumns: '1fr 1fr',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
[\`@container cardContainer (max-width: \${CARD_MIN_WIDTH}px)\`]: {
|
|
67
|
+
ul: {
|
|
68
|
+
gridTemplateColumns: '1fr',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
`,
|
|
73
|
+
errors: [
|
|
74
|
+
{ messageId: 'no-container-queries' },
|
|
75
|
+
{ messageId: 'no-container-queries' },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: '@container in styled div under feature flag',
|
|
80
|
+
code: `
|
|
81
|
+
import { styled } from "@compiled/react";
|
|
82
|
+
const Container = styled.div(
|
|
83
|
+
{
|
|
84
|
+
display: 'flex',
|
|
85
|
+
flexDirection: 'column',
|
|
86
|
+
position: 'relative',
|
|
87
|
+
zIndex: '0',
|
|
88
|
+
'&:empty': {
|
|
89
|
+
display: 'none',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
() =>
|
|
93
|
+
ff('a-feature-flag') && {
|
|
94
|
+
[\`@container cardContainer (max-width: \${DISPLAYING_FIELDS_MIN_CARD_WIDTH}px)\`]: {
|
|
95
|
+
width: 0,
|
|
96
|
+
overflow: 'hidden',
|
|
97
|
+
visibility: 'hidden',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
`,
|
|
102
|
+
errors: [{ messageId: 'no-container-queries' }],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: '@container in a styled div with TS type parameter',
|
|
106
|
+
code: `
|
|
107
|
+
import { styled } from "@compiled/react";
|
|
108
|
+
|
|
109
|
+
const Component = styled.div<{
|
|
110
|
+
flexGrow?: number;
|
|
111
|
+
}>({
|
|
112
|
+
flexGrow: 1,
|
|
113
|
+
flexBasis: 0,
|
|
114
|
+
"@container AdminCenterPage (min-width: 840px)": {
|
|
115
|
+
flexGrow: (props) => props.flexGrow || 1
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
`,
|
|
119
|
+
errors: [{ messageId: 'no-container-queries' }],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: '@container in template literal within styled div with TS type parameter',
|
|
123
|
+
code: `
|
|
124
|
+
import { styled } from "@compiled/react";
|
|
125
|
+
const Container = styled.div<{
|
|
126
|
+
paddingBottom: number;
|
|
127
|
+
}>({
|
|
128
|
+
display: 'flex',
|
|
129
|
+
flexDirection: 'column',
|
|
130
|
+
boxSizing: 'border-box',
|
|
131
|
+
|
|
132
|
+
[\`@container cardContainer (max-width: \${DISPLAYING_FIELDS_MIN_CARD_WIDTH}px)\`]: {
|
|
133
|
+
paddingLeft: '10px',
|
|
134
|
+
paddingRight: 0,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
`,
|
|
138
|
+
errors: [{ messageId: 'no-container-queries' }],
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import estraverse from 'estraverse';
|
|
2
|
+
|
|
3
|
+
import { createLintRule } from '../utils/create-rule';
|
|
4
|
+
import {
|
|
5
|
+
isCss,
|
|
6
|
+
getImportSources,
|
|
7
|
+
isStyled,
|
|
8
|
+
isKeyframes,
|
|
9
|
+
isCssMap,
|
|
10
|
+
isXcss,
|
|
11
|
+
} from '../utils/is-supported-import';
|
|
12
|
+
import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
|
|
13
|
+
|
|
14
|
+
const schema: JSONSchema4 = [
|
|
15
|
+
{
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
importSources: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
items: { type: 'string' },
|
|
21
|
+
uniqueItems: true,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export const rule = createLintRule({
|
|
28
|
+
meta: {
|
|
29
|
+
name: 'no-container-queries',
|
|
30
|
+
docs: {
|
|
31
|
+
description: 'Prevents usage of @container query within css styling',
|
|
32
|
+
recommended: true,
|
|
33
|
+
severity: 'warn',
|
|
34
|
+
},
|
|
35
|
+
messages: {
|
|
36
|
+
'no-container-queries':
|
|
37
|
+
'We block @container queries as they break scope and are not type-safe. We suggest alternatives such as JS-based APIs or @media queries.',
|
|
38
|
+
},
|
|
39
|
+
type: 'problem',
|
|
40
|
+
schema,
|
|
41
|
+
},
|
|
42
|
+
create(context) {
|
|
43
|
+
const importSources = getImportSources(context);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
CallExpression(node) {
|
|
47
|
+
const { references } = context.getScope();
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
isCss(node.callee, references, importSources) ||
|
|
51
|
+
isStyled(node.callee, references, importSources) ||
|
|
52
|
+
isKeyframes(node.callee, references, importSources) ||
|
|
53
|
+
isCssMap(node.callee, references, importSources) ||
|
|
54
|
+
isXcss(node.callee, references, importSources)
|
|
55
|
+
) {
|
|
56
|
+
estraverse.traverse(node, {
|
|
57
|
+
enter(node) {
|
|
58
|
+
if (node.type !== 'Property') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (
|
|
63
|
+
node.key.type !== 'Literal' &&
|
|
64
|
+
node.key.type !== 'TemplateLiteral'
|
|
65
|
+
) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
node.key.type === 'Literal' &&
|
|
71
|
+
node.key.value?.toString().match(/@container/)
|
|
72
|
+
) {
|
|
73
|
+
context.report({
|
|
74
|
+
node: node.key,
|
|
75
|
+
messageId: 'no-container-queries',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
node.key.type === 'TemplateLiteral' &&
|
|
81
|
+
node.key.quasis[0]?.value.raw.match(/@container/)
|
|
82
|
+
) {
|
|
83
|
+
context.report({
|
|
84
|
+
node: node.key,
|
|
85
|
+
messageId: 'no-container-queries',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* This is needed to handle unknown node types. Otherwise an error is thrown.
|
|
91
|
+
*/
|
|
92
|
+
fallback: 'iteration',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
export default rule;
|