@atlaskit/eslint-plugin-ui-styling-standard 0.7.0 → 0.7.2

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +17 -16
  3. package/constellation/index/overview.mdx +17 -16
  4. package/constellation/no-container-queries/usage.mdx +50 -0
  5. package/dist/cjs/presets/all.codegen.js +2 -1
  6. package/dist/cjs/presets/recommended.codegen.js +2 -1
  7. package/dist/cjs/rules/convert-props-syntax/index.js +1 -1
  8. package/dist/cjs/rules/index.codegen.js +3 -1
  9. package/dist/cjs/rules/local-cx-xcss/index.js +1 -1
  10. package/dist/cjs/rules/no-container-queries/index.js +76 -0
  11. package/dist/cjs/rules/no-important-styles/index.js +1 -1
  12. package/dist/es2019/presets/all.codegen.js +2 -1
  13. package/dist/es2019/presets/recommended.codegen.js +2 -1
  14. package/dist/es2019/rules/convert-props-syntax/index.js +1 -1
  15. package/dist/es2019/rules/index.codegen.js +3 -1
  16. package/dist/es2019/rules/local-cx-xcss/index.js +1 -1
  17. package/dist/es2019/rules/no-container-queries/index.js +70 -0
  18. package/dist/es2019/rules/no-important-styles/index.js +1 -1
  19. package/dist/esm/presets/all.codegen.js +2 -1
  20. package/dist/esm/presets/recommended.codegen.js +2 -1
  21. package/dist/esm/rules/convert-props-syntax/index.js +1 -1
  22. package/dist/esm/rules/index.codegen.js +3 -1
  23. package/dist/esm/rules/local-cx-xcss/index.js +1 -1
  24. package/dist/esm/rules/no-container-queries/index.js +69 -0
  25. package/dist/esm/rules/no-important-styles/index.js +1 -1
  26. package/dist/types/index.codegen.d.ts +2 -0
  27. package/dist/types/presets/all.codegen.d.ts +2 -1
  28. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  29. package/dist/types/rules/index.codegen.d.ts +1 -0
  30. package/dist/types/rules/no-container-queries/index.d.ts +2 -0
  31. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  32. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  33. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  34. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  35. package/dist/types-ts4.5/rules/no-container-queries/index.d.ts +2 -0
  36. package/package.json +3 -2
  37. package/src/presets/all.codegen.tsx +2 -1
  38. package/src/presets/recommended.codegen.tsx +2 -1
  39. package/src/rules/convert-props-syntax/index.tsx +4 -1
  40. package/src/rules/index.codegen.tsx +3 -1
  41. package/src/rules/local-cx-xcss/index.tsx +4 -1
  42. package/src/rules/no-container-queries/README.md +48 -0
  43. package/src/rules/no-container-queries/__tests__/rule.test.tsx +142 -0
  44. package/src/rules/no-container-queries/index.tsx +100 -0
  45. package/src/rules/no-important-styles/index.tsx +1 -1
  46. package/tsconfig.app.json +3 -0
  47. package/dist/cjs/rules/utils/is-supported-import.js +0 -160
  48. package/dist/es2019/rules/utils/is-supported-import.js +0 -150
  49. package/dist/esm/rules/utils/is-supported-import.js +0 -154
  50. package/dist/types/rules/utils/is-supported-import.d.ts +0 -46
  51. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +0 -46
  52. package/src/rules/utils/README.md +0 -1
  53. package/src/rules/utils/is-supported-import.tsx +0 -227
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+ - Updated dependencies
9
+
10
+ ## 0.7.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [#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
15
+
3
16
  ## 0.7.0
4
17
 
5
18
  ### 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 | 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.x 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 `styled-components`. | 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-important-styles/README.md">no-important-styles</a> | Disallows important style declarations | Yes | | |
20
- | <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 | |
21
- | <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 | |
22
- | <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 | |
23
- | <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 | |
24
- | <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 | | |
25
- | <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 | | |
26
- | <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 | | |
27
- | <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 | | |
28
- | <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 | | |
29
- | <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 | | |
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 | 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.x 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 `styled-components`. | 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-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
18
- | <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 | |
19
- | <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 | |
20
- | <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 | |
21
- | <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 | |
22
- | <a href="no-suppress-xcss/usage">@compiled/no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop. | Yes | | |
23
- | <a href="no-js-xcss/usage">@compiled/no-js-xcss</a> | Disallows using xcss prop inside JavaScript files. | Yes | | |
24
- | <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 | | |
25
- | <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 | | |
26
- | <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 | | |
27
- | <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 | | |
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::c4a9648d888d86d752ea2b3442d395ba>>
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::c4a9648d888d86d752ea2b3442d395ba>>
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
@@ -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("../utils/is-supported-import");
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,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::7c8793f6c12f32e915fd9b4dc7a6edef>>
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
  };
@@ -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("../utils/is-supported-import");
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;
@@ -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("@atlaskit/eslint-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;
@@ -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("../utils/is-supported-import");
10
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
11
11
  var schema = [{
12
12
  type: 'object',
13
13
  properties: {
@@ -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::c4a9648d888d86d752ea2b3442d395ba>>
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::c4a9648d888d86d752ea2b3442d395ba>>
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
  import { analyze } from 'eslint-scope';
2
2
  import { createLintRule } from '../utils/create-rule';
3
- import { isStyledComponents, isEmotion } from '../utils/is-supported-import';
3
+ import { isStyledComponents, isEmotion } from '@atlaskit/eslint-utils/is-supported-import';
4
4
  import ESTraverse from 'estraverse';
5
5
 
6
6
  /**
@@ -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::7c8793f6c12f32e915fd9b4dc7a6edef>>
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
  };
@@ -1,5 +1,5 @@
1
1
  import { createLintRule } from '../utils/create-rule';
2
- import { CSS_IN_JS_IMPORTS, isCxFunction } from '../utils/is-supported-import';
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;
@@ -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 '@atlaskit/eslint-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
  import estraverse from 'estraverse';
2
2
  import { createLintRule } from '../utils/create-rule';
3
- import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '../utils/is-supported-import';
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
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
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::c4a9648d888d86d752ea2b3442d395ba>>
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
@@ -3,7 +3,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
3
3
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
4
  import { analyze } from 'eslint-scope';
5
5
  import { createLintRule } from '../utils/create-rule';
6
- import { isStyledComponents, isEmotion } from '../utils/is-supported-import';
6
+ import { isStyledComponents, isEmotion } from '@atlaskit/eslint-utils/is-supported-import';
7
7
  import ESTraverse from 'estraverse';
8
8
 
9
9
  /**
@@ -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::7c8793f6c12f32e915fd9b4dc7a6edef>>
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
  };
@@ -1,5 +1,5 @@
1
1
  import { createLintRule } from '../utils/create-rule';
2
- import { CSS_IN_JS_IMPORTS, isCxFunction } from '../utils/is-supported-import';
2
+ import { CSS_IN_JS_IMPORTS, isCxFunction } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
4
4
  function getParentJSXAttribute(node) {
5
5
  var parent = node.parent;