@atlaskit/eslint-plugin-ui-styling-standard 0.20.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +2 -5
  3. package/dist/cjs/index.codegen.js +45 -10
  4. package/dist/cjs/index.js +22 -1
  5. package/dist/cjs/presets/all-flat.codegen.js +53 -0
  6. package/dist/cjs/presets/all.codegen.js +2 -9
  7. package/dist/cjs/presets/recommended-flat.codegen.js +53 -0
  8. package/dist/cjs/presets/recommended.codegen.js +2 -9
  9. package/dist/cjs/rules/enforce-style-prop/index.js +45 -17
  10. package/dist/cjs/rules/external-rules.js +0 -38
  11. package/dist/cjs/rules/index.codegen.js +4 -3
  12. package/dist/es2019/index.codegen.js +50 -6
  13. package/dist/es2019/index.js +1 -1
  14. package/dist/es2019/presets/all-flat.codegen.js +44 -0
  15. package/dist/es2019/presets/all.codegen.js +2 -9
  16. package/dist/es2019/presets/recommended-flat.codegen.js +44 -0
  17. package/dist/es2019/presets/recommended.codegen.js +2 -9
  18. package/dist/es2019/rules/enforce-style-prop/index.js +45 -17
  19. package/dist/es2019/rules/external-rules.js +0 -38
  20. package/dist/es2019/rules/index.codegen.js +2 -2
  21. package/dist/esm/index.codegen.js +46 -6
  22. package/dist/esm/index.js +1 -1
  23. package/dist/esm/presets/all-flat.codegen.js +44 -0
  24. package/dist/esm/presets/all.codegen.js +2 -9
  25. package/dist/esm/presets/recommended-flat.codegen.js +44 -0
  26. package/dist/esm/presets/recommended.codegen.js +2 -9
  27. package/dist/esm/rules/enforce-style-prop/index.js +45 -17
  28. package/dist/esm/rules/external-rules.js +0 -38
  29. package/dist/esm/rules/index.codegen.js +2 -2
  30. package/dist/types/index.codegen.d.ts +370 -81
  31. package/dist/types/index.d.ts +1 -1
  32. package/dist/types/presets/all-flat.codegen.d.ts +44 -0
  33. package/dist/types/presets/all.codegen.d.ts +33 -40
  34. package/dist/types/presets/recommended-flat.codegen.d.ts +44 -0
  35. package/dist/types/presets/recommended.codegen.d.ts +33 -40
  36. package/dist/types/rules/index.codegen.d.ts +1 -2
  37. package/dist/types-ts4.5/index.codegen.d.ts +550 -81
  38. package/dist/types-ts4.5/index.d.ts +1 -1
  39. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +65 -0
  40. package/dist/types-ts4.5/presets/all.codegen.d.ts +57 -40
  41. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +65 -0
  42. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +57 -40
  43. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -2
  44. package/package.json +11 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/eslint-plugin-ui-styling-standard
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#162439](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/162439)
8
+ [`d4e7809eb2373`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d4e7809eb2373) -
9
+ Remove Compiled rules from plugin, please use @compiled/eslint-plugin directly
10
+
11
+ ### Patch Changes
12
+
13
+ - [#157624](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157624)
14
+ [`1734bd61b5d9e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1734bd61b5d9e) -
15
+ Fix enforce-style-prop from erroring on type assertion, eg. '{…} as React.CSSProperties' which is
16
+ a common pattern
17
+
18
+ ## 0.21.0
19
+
20
+ ### Minor Changes
21
+
22
+ - [#157735](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/157735)
23
+ [`0138fda541246`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0138fda541246) -
24
+ Adding flat config presets to @atlaskit/eslint-plugin-ui-styling-standard
25
+
3
26
  ## 0.20.1
4
27
 
5
28
  ### Patch Changes
package/README.md CHANGED
@@ -20,8 +20,8 @@ module.exports = {
20
20
  ```
21
21
 
22
22
  We don't recommended maintaining your own configuration. If you do not use our config you will need
23
- to specify individual rules and configuration. Add the plugin to your `.eslintrc.js` file and enable
24
- individual rules as you're ready to adopt.
23
+ to specify individual rules and configuration. Add the plugin to your `eslint.config.cjs` file and
24
+ enable individual rules as you're ready to adopt.
25
25
 
26
26
  ```diff
27
27
  module.exports = {
@@ -63,10 +63,7 @@ module.exports = {
63
63
  | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
64
64
  | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
65
65
  | <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 | |
66
- | <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 | | |
67
- | <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 | | |
68
66
  | <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 | | |
69
67
  | <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 | | |
70
- | <a href="https://atlassian.design/components/eslint-plugin-ui-styling-standard/jsx-pragma/usage">@compiled/jsx-pragma</a> | Ensures that the Compiled JSX pragma is set when using Compiled | Yes | | |
71
68
 
72
69
  <!-- END_RULE_TABLE_CODEGEN -->
@@ -4,23 +4,58 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.configs = void 0;
7
+ exports.plugin = exports.meta = exports.default = exports.configs = void 0;
8
8
  Object.defineProperty(exports, "rules", {
9
9
  enumerable: true,
10
10
  get: function get() {
11
- return _index.default;
11
+ return _index.rules;
12
12
  }
13
13
  });
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+ var _allFlat = _interopRequireDefault(require("./presets/all-flat.codegen"));
14
16
  var _all = _interopRequireDefault(require("./presets/all.codegen"));
17
+ var _recommendedFlat = _interopRequireDefault(require("./presets/recommended-flat.codegen"));
15
18
  var _recommended = _interopRequireDefault(require("./presets/recommended.codegen"));
16
- var _index = _interopRequireDefault(require("./rules/index.codegen"));
17
- /**
19
+ var _index = require("./rules/index.codegen");
20
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
18
22
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
19
- * @codegen <<SignedSource::aff3fad2b8534fad07ba5f0f1b981a55>>
23
+ * @codegen <<SignedSource::0b2a9d2f41301e40371dbce6d69039df>>
20
24
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
21
25
  */
22
-
23
- var configs = exports.configs = {
24
- all: _all.default,
25
- recommended: _recommended.default
26
- };
26
+ // this uses require because not all node versions this package supports use the same import assertions/attributes
27
+ // eslint-disable-next-line import/no-extraneous-dependencies
28
+ var pkgJson = require('@atlaskit/eslint-plugin-ui-styling-standard/package.json');
29
+ var version = pkgJson.version,
30
+ name = pkgJson.name;
31
+ var plugin = exports.plugin = {
32
+ meta: {
33
+ name: name,
34
+ version: version
35
+ },
36
+ rules: _index.rules,
37
+ // flat configs need to be done like this so they can get a reference to the plugin.
38
+ // see here: https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
39
+ // they cannot use `Object.assign` because it will not work with the getter
40
+ configs: {
41
+ all: _all.default,
42
+ 'flat/all': _objectSpread(_objectSpread({}, _allFlat.default), {}, {
43
+ plugins: _objectSpread(_objectSpread({}, _allFlat.default.plugins), {}, {
44
+ get '@atlaskit/ui-styling-standard'() {
45
+ return plugin;
46
+ }
47
+ })
48
+ }),
49
+ recommended: _recommended.default,
50
+ 'flat/recommended': _objectSpread(_objectSpread({}, _recommendedFlat.default), {}, {
51
+ plugins: _objectSpread(_objectSpread({}, _recommendedFlat.default.plugins), {}, {
52
+ get '@atlaskit/ui-styling-standard'() {
53
+ return plugin;
54
+ }
55
+ })
56
+ })
57
+ }
58
+ };
59
+ var configs = exports.configs = plugin.configs,
60
+ meta = exports.meta = plugin.meta;
61
+ var _default = exports.default = plugin;
package/dist/cjs/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -9,10 +10,30 @@ Object.defineProperty(exports, "configs", {
9
10
  return _index.configs;
10
11
  }
11
12
  });
13
+ Object.defineProperty(exports, "default", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _index.default;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "meta", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _index.meta;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "plugin", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _index.plugin;
29
+ }
30
+ });
12
31
  Object.defineProperty(exports, "rules", {
13
32
  enumerable: true,
14
33
  get: function get() {
15
34
  return _index.rules;
16
35
  }
17
36
  });
18
- var _index = require("./index.codegen");
37
+ var _index = _interopRequireWildcard(require("./index.codegen"));
38
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
39
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/eslint-plugin-design-system"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ /**
12
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
13
+ * @codegen <<SignedSource::4595bc1a07f9da4186e2df84cea56831>>
14
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
15
+ */
16
+ var _default = exports.default = {
17
+ plugins: {
18
+ // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
19
+ '@atlaskit/design-system': atlaskitDesignSystemPlugin
20
+ },
21
+ rules: {
22
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
23
+ '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
24
+ '@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
25
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
26
+ '@atlaskit/ui-styling-standard/no-array-arguments': 'error',
27
+ '@atlaskit/ui-styling-standard/no-classname-prop': 'error',
28
+ '@atlaskit/ui-styling-standard/no-container-queries': 'error',
29
+ '@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
30
+ '@atlaskit/ui-styling-standard/no-exported-styles': 'error',
31
+ '@atlaskit/ui-styling-standard/no-global-styles': 'error',
32
+ '@atlaskit/ui-styling-standard/no-important-styles': 'error',
33
+ '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
34
+ '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
35
+ '@atlaskit/ui-styling-standard/no-styled': 'error',
36
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
37
+ '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
38
+ '@atlaskit/ui-styling-standard/use-compiled': 'error',
39
+ '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
40
+ excludeReactComponents: true,
41
+ shouldAlwaysCheckXcss: true
42
+ }],
43
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
44
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
45
+ '@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
46
+ '@atlaskit/design-system/no-empty-styled-expression': ['error', {
47
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
48
+ }],
49
+ '@atlaskit/design-system/no-invalid-css-map': ['error', {
50
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
51
+ }]
52
+ }
53
+ };
@@ -6,11 +6,11 @@ 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::11d1ce4c1740cea37e5de3ccba44a8f5>>
9
+ * @codegen <<SignedSource::884e28457d7860b1abca070fca8ab853>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
12
  var _default = exports.default = {
13
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
13
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
14
14
  rules: {
15
15
  '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
16
16
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
@@ -36,18 +36,11 @@ var _default = exports.default = {
36
36
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
37
37
  '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
38
38
  '@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
39
- '@compiled/no-suppress-xcss': 'error',
40
- '@compiled/no-js-xcss': 'error',
41
39
  '@atlaskit/design-system/no-empty-styled-expression': ['error', {
42
40
  importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
43
41
  }],
44
42
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
45
43
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
46
- }],
47
- '@compiled/jsx-pragma': ['error', {
48
- runtime: 'classic',
49
- onlyRunIfImportingCompiled: true,
50
- importSources: ['@atlaskit/css']
51
44
  }]
52
45
  }
53
46
  };
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var atlaskitDesignSystemPlugin = _interopRequireWildcard(require("@atlaskit/eslint-plugin-design-system"));
9
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
10
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
11
+ /**
12
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
13
+ * @codegen <<SignedSource::4595bc1a07f9da4186e2df84cea56831>>
14
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
15
+ */
16
+ var _default = exports.default = {
17
+ plugins: {
18
+ // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
19
+ '@atlaskit/design-system': atlaskitDesignSystemPlugin
20
+ },
21
+ rules: {
22
+ '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
23
+ '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
24
+ '@atlaskit/ui-styling-standard/enforce-style-prop': 'error',
25
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'error',
26
+ '@atlaskit/ui-styling-standard/no-array-arguments': 'error',
27
+ '@atlaskit/ui-styling-standard/no-classname-prop': 'error',
28
+ '@atlaskit/ui-styling-standard/no-container-queries': 'error',
29
+ '@atlaskit/ui-styling-standard/no-dynamic-styles': 'error',
30
+ '@atlaskit/ui-styling-standard/no-exported-styles': 'error',
31
+ '@atlaskit/ui-styling-standard/no-global-styles': 'error',
32
+ '@atlaskit/ui-styling-standard/no-important-styles': 'error',
33
+ '@atlaskit/ui-styling-standard/no-imported-style-values': 'error',
34
+ '@atlaskit/ui-styling-standard/no-nested-selectors': 'error',
35
+ '@atlaskit/ui-styling-standard/no-styled': 'error',
36
+ '@atlaskit/ui-styling-standard/no-unsafe-selectors': 'error',
37
+ '@atlaskit/ui-styling-standard/no-unsafe-values': 'error',
38
+ '@atlaskit/ui-styling-standard/use-compiled': 'error',
39
+ '@atlaskit/design-system/consistent-css-prop-usage': ['error', {
40
+ excludeReactComponents: true,
41
+ shouldAlwaysCheckXcss: true
42
+ }],
43
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
44
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
45
+ '@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
46
+ '@atlaskit/design-system/no-empty-styled-expression': ['error', {
47
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
48
+ }],
49
+ '@atlaskit/design-system/no-invalid-css-map': ['error', {
50
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
51
+ }]
52
+ }
53
+ };
@@ -6,11 +6,11 @@ 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::11d1ce4c1740cea37e5de3ccba44a8f5>>
9
+ * @codegen <<SignedSource::884e28457d7860b1abca070fca8ab853>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
11
11
  */
12
12
  var _default = exports.default = {
13
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
13
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system'],
14
14
  rules: {
15
15
  '@atlaskit/ui-styling-standard/atlaskit-theme': 'error',
16
16
  '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
@@ -36,18 +36,11 @@ var _default = exports.default = {
36
36
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
37
37
  '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
38
38
  '@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
39
- '@compiled/no-suppress-xcss': 'error',
40
- '@compiled/no-js-xcss': 'error',
41
39
  '@atlaskit/design-system/no-empty-styled-expression': ['error', {
42
40
  importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
43
41
  }],
44
42
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
45
43
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
46
- }],
47
- '@compiled/jsx-pragma': ['error', {
48
- runtime: 'classic',
49
- onlyRunIfImportingCompiled: true,
50
- importSources: ['@atlaskit/css']
51
44
  }]
52
45
  }
53
46
  };
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.rule = exports.default = void 0;
7
7
  var _eslintCodemodUtils = require("eslint-codemod-utils");
8
- var _createRule = require("../utils/create-rule");
9
8
  var _allowedFunctionCalls = require("@atlaskit/eslint-utils/allowed-function-calls");
10
9
  var _findVariable3 = require("@atlaskit/eslint-utils/find-variable");
10
+ var _createRule = require("../utils/create-rule");
11
11
  var isParameter = function isParameter(context, identifier) {
12
12
  var _findVariable;
13
13
  var definitions = (_findVariable = (0, _findVariable3.findVariable)({
@@ -21,7 +21,7 @@ var isParameter = function isParameter(context, identifier) {
21
21
  return result.type === 'Parameter';
22
22
  };
23
23
  var isIdentifierAllowed = function isIdentifierAllowed(context, identifier) {
24
- var _parent;
24
+ var _variable$identifiers;
25
25
  var variable = (0, _findVariable3.findVariable)({
26
26
  sourceCode: context.getSourceCode(),
27
27
  identifier: identifier
@@ -31,30 +31,44 @@ var isIdentifierAllowed = function isIdentifierAllowed(context, identifier) {
31
31
  }
32
32
  var variableDefinition = variable.defs[0].node;
33
33
 
34
+ // console.log('@@variableDefinition', variableDefinition);
35
+
34
36
  // If identifier is a RestElement, report warning
35
- if (((_parent = variable.identifiers[0].parent) === null || _parent === void 0 ? void 0 : _parent.type) === 'RestElement') {
37
+ if (((_variable$identifiers = variable.identifiers[0]) === null || _variable$identifiers === void 0 || (_variable$identifiers = _variable$identifiers.parent) === null || _variable$identifiers === void 0 ? void 0 : _variable$identifiers.type) === 'RestElement') {
36
38
  return false;
37
39
  }
38
40
 
39
41
  // Checking if identifier has been destructured from props within function
40
42
  if (variableDefinition.type === 'VariableDeclarator') {
41
- var _variableDefinition$i, _variableDefinition$i2;
43
+ var _init, _init2, _init3, _init4;
42
44
  // If it's a let variable, ignore
43
45
  if (variableDefinition.parent.kind === 'let') {
44
46
  return true;
45
47
  }
48
+
49
+ // Allow for `const { width } = props as Props` (etc)
50
+ var init = variableDefinition.init;
51
+ if (((_init = init) === null || _init === void 0 ? void 0 : _init.type) === 'TSAsExpression') {
52
+ init = init.expression;
53
+ }
54
+
46
55
  // If it's initialised by a call expression, ignore
47
- if (((_variableDefinition$i = variableDefinition.init) === null || _variableDefinition$i === void 0 ? void 0 : _variableDefinition$i.type) === 'CallExpression') {
56
+ if (((_init2 = init) === null || _init2 === void 0 ? void 0 : _init2.type) === 'CallExpression') {
48
57
  return true;
49
58
  }
50
59
  // Destructured from member expression
51
60
  // e.g. const width = props.width
52
- if (((_variableDefinition$i2 = variableDefinition.init) === null || _variableDefinition$i2 === void 0 ? void 0 : _variableDefinition$i2.type) === 'MemberExpression') {
53
- return isParameter(context, variableDefinition.init.object);
61
+ if (((_init3 = init) === null || _init3 === void 0 ? void 0 : _init3.type) === 'MemberExpression') {
62
+ return isParameter(context, init.object);
63
+ }
64
+ // Destructured from an asserted
65
+ // e.g. const width = props.width
66
+ if (((_init4 = init) === null || _init4 === void 0 ? void 0 : _init4.type) === 'MemberExpression') {
67
+ return isParameter(context, init.object);
54
68
  }
55
69
  // Destructured from object pattern
56
70
  // e.g. const { width } = props
57
- return isParameter(context, variableDefinition.init);
71
+ return isParameter(context, init);
58
72
  }
59
73
  // If identifier has not been deconstructed from parameter or is a RestElement, report warning
60
74
  return isParameter(context, identifier);
@@ -127,26 +141,40 @@ var rule = exports.rule = (0, _createRule.createLintRule)({
127
141
  create: function create(context) {
128
142
  return {
129
143
  'JSXAttribute[name.name="style"] > JSXExpressionContainer': function JSXAttributeNameNameStyleJSXExpressionContainer(node) {
144
+ var _node$expression$expr;
130
145
  if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXExpressionContainer')) {
131
146
  return;
132
147
  }
148
+
133
149
  // we've reached an attribute named style
134
150
 
135
- if (node.expression.type === 'ObjectExpression') {
136
- node.expression.properties.forEach(function (value) {
137
- if (!isPropertyValueAllowed(value, context)) {
138
- context.report({
139
- node: value,
140
- messageId: 'enforce-style-prop'
141
- });
142
- }
143
- });
151
+ var expression;
152
+ if (
153
+ // @ts-expect-error -- TSAsExpression is not valid in estree
154
+ node.expression.type === 'TSAsExpression' &&
155
+ // @ts-expect-error -- TSAsExpression is not valid in estree
156
+ ((_node$expression$expr = node.expression.expression) === null || _node$expression$expr === void 0 ? void 0 : _node$expression$expr.type) === 'ObjectExpression') {
157
+ // This is a `style={{ … } as React.CSSProperties}` scenario
158
+ // @ts-expect-error -- TSAsExpression is not valid in estree
159
+ expression = node.expression.expression;
160
+ } else if (node.expression.type === 'ObjectExpression') {
161
+ // Typical `style={{ … }}` scenario
162
+ expression = node.expression;
144
163
  } else {
145
164
  context.report({
146
165
  node: node,
147
166
  messageId: 'enforce-style-prop'
148
167
  });
168
+ return;
149
169
  }
170
+ expression.properties.forEach(function (value) {
171
+ if (!isPropertyValueAllowed(value, context)) {
172
+ context.report({
173
+ node: value,
174
+ messageId: 'enforce-style-prop'
175
+ });
176
+ }
177
+ });
150
178
  }
151
179
  };
152
180
  }
@@ -66,28 +66,6 @@ var externalRules = exports.externalRules = [{
66
66
  recommended: true,
67
67
  severity: 'error'
68
68
  }
69
- }, {
70
- name: '@compiled/no-suppress-xcss',
71
- displayName: 'no-suppress-xcss',
72
- isExternal: true,
73
- docs: {
74
- description: 'Disallows supressing type violations when using the xcss prop.',
75
- url: (0, _createRule.getRuleUrl)('no-suppress-xcss'),
76
- externalUrl: 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-suppress-xcss',
77
- recommended: true,
78
- severity: 'error'
79
- }
80
- }, {
81
- name: '@compiled/no-js-xcss',
82
- displayName: 'no-js-xcss',
83
- isExternal: true,
84
- docs: {
85
- description: 'Disallows using xcss prop inside JavaScript files.',
86
- url: (0, _createRule.getRuleUrl)('no-js-xcss'),
87
- externalUrl: 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss',
88
- recommended: true,
89
- severity: 'error'
90
- }
91
69
  }, {
92
70
  name: '@atlaskit/design-system/no-empty-styled-expression',
93
71
  displayName: 'no-empty-styled-expression',
@@ -116,20 +94,4 @@ var externalRules = exports.externalRules = [{
116
94
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
117
95
  }
118
96
  }
119
- }, {
120
- name: '@compiled/jsx-pragma',
121
- displayName: 'jsx-pragma',
122
- isExternal: true,
123
- docs: {
124
- description: 'Ensures that the Compiled JSX pragma is set when using Compiled',
125
- url: (0, _createRule.getRuleUrl)('jsx-pragma'),
126
- externalUrl: 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/jsx-pragma',
127
- recommended: true,
128
- severity: 'error',
129
- pluginConfig: {
130
- runtime: 'classic',
131
- onlyRunIfImportingCompiled: true,
132
- importSources: ['@atlaskit/css']
133
- }
134
- }
135
97
  }];
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
7
+ exports.rules = void 0;
8
8
  var _atlaskitTheme = _interopRequireDefault(require("./atlaskit-theme"));
9
9
  var _convertPropsSyntax = _interopRequireDefault(require("./convert-props-syntax"));
10
10
  var _enforceStyleProp = _interopRequireDefault(require("./enforce-style-prop"));
@@ -24,10 +24,11 @@ var _noUnsafeValues = _interopRequireDefault(require("./no-unsafe-values"));
24
24
  var _useCompiled = _interopRequireDefault(require("./use-compiled"));
25
25
  /**
26
26
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
27
- * @codegen <<SignedSource::6ad0de2d4bdac726387f27681ad9fcf4>>
27
+ * @codegen <<SignedSource::71ba23a2a1467988c4fae8c2756447f9>>
28
28
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
29
29
  */
30
- var _default = exports.default = {
30
+
31
+ var rules = exports.rules = {
31
32
  'atlaskit-theme': _atlaskitTheme.default,
32
33
  'convert-props-syntax': _convertPropsSyntax.default,
33
34
  'enforce-style-prop': _enforceStyleProp.default,
@@ -1,12 +1,56 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::aff3fad2b8534fad07ba5f0f1b981a55>>
3
+ * @codegen <<SignedSource::0b2a9d2f41301e40371dbce6d69039df>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
+ import allFlat from './presets/all-flat.codegen';
6
7
  import all from './presets/all.codegen';
8
+ import recommendedFlat from './presets/recommended-flat.codegen';
7
9
  import recommended from './presets/recommended.codegen';
8
- export { default as rules } from './rules/index.codegen';
9
- export const configs = {
10
- all,
11
- recommended
12
- };
10
+ import { rules } from './rules/index.codegen';
11
+
12
+ // this uses require because not all node versions this package supports use the same import assertions/attributes
13
+ // eslint-disable-next-line import/no-extraneous-dependencies
14
+ const pkgJson = require('@atlaskit/eslint-plugin-ui-styling-standard/package.json');
15
+ const {
16
+ version,
17
+ name
18
+ } = pkgJson;
19
+ export const plugin = {
20
+ meta: {
21
+ name,
22
+ version
23
+ },
24
+ rules,
25
+ // flat configs need to be done like this so they can get a reference to the plugin.
26
+ // see here: https://eslint.org/docs/latest/extend/plugins#configs-in-plugins
27
+ // they cannot use `Object.assign` because it will not work with the getter
28
+ configs: {
29
+ all,
30
+ 'flat/all': {
31
+ ...allFlat,
32
+ plugins: {
33
+ ...allFlat.plugins,
34
+ get '@atlaskit/ui-styling-standard'() {
35
+ return plugin;
36
+ }
37
+ }
38
+ },
39
+ recommended,
40
+ 'flat/recommended': {
41
+ ...recommendedFlat,
42
+ plugins: {
43
+ ...recommendedFlat.plugins,
44
+ get '@atlaskit/ui-styling-standard'() {
45
+ return plugin;
46
+ }
47
+ }
48
+ }
49
+ }
50
+ };
51
+ export { rules } from './rules/index.codegen';
52
+ export const {
53
+ configs,
54
+ meta
55
+ } = plugin;
56
+ export default plugin;
@@ -1 +1 @@
1
- export { configs, rules } from './index.codegen';
1
+ export { meta, rules, plugin, configs, default } from './index.codegen';