@atlaskit/eslint-plugin-design-system 9.2.3 → 9.2.4

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 (49) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/rules/consistent-css-prop-usage/index.js +1 -1
  3. package/dist/cjs/rules/no-css-tagged-template-expression/index.js +1 -1
  4. package/dist/cjs/rules/no-empty-styled-expression/index.js +1 -1
  5. package/dist/cjs/rules/no-exported-css/index.js +1 -1
  6. package/dist/cjs/rules/no-exported-keyframes/index.js +1 -1
  7. package/dist/cjs/rules/no-invalid-css-map/index.js +1 -1
  8. package/dist/cjs/rules/no-keyframes-tagged-template-expression/index.js +1 -1
  9. package/dist/cjs/rules/no-styled-tagged-template-expression/index.js +1 -1
  10. package/dist/cjs/rules/utils/create-no-exported-rule/main.js +1 -1
  11. package/dist/cjs/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
  12. package/dist/es2019/rules/consistent-css-prop-usage/index.js +1 -1
  13. package/dist/es2019/rules/no-css-tagged-template-expression/index.js +1 -1
  14. package/dist/es2019/rules/no-empty-styled-expression/index.js +1 -1
  15. package/dist/es2019/rules/no-exported-css/index.js +1 -1
  16. package/dist/es2019/rules/no-exported-keyframes/index.js +1 -1
  17. package/dist/es2019/rules/no-invalid-css-map/index.js +1 -1
  18. package/dist/es2019/rules/no-keyframes-tagged-template-expression/index.js +1 -1
  19. package/dist/es2019/rules/no-styled-tagged-template-expression/index.js +1 -1
  20. package/dist/es2019/rules/utils/create-no-exported-rule/main.js +1 -1
  21. package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
  22. package/dist/esm/rules/consistent-css-prop-usage/index.js +1 -1
  23. package/dist/esm/rules/no-css-tagged-template-expression/index.js +1 -1
  24. package/dist/esm/rules/no-empty-styled-expression/index.js +1 -1
  25. package/dist/esm/rules/no-exported-css/index.js +1 -1
  26. package/dist/esm/rules/no-exported-keyframes/index.js +1 -1
  27. package/dist/esm/rules/no-invalid-css-map/index.js +1 -1
  28. package/dist/esm/rules/no-keyframes-tagged-template-expression/index.js +1 -1
  29. package/dist/esm/rules/no-styled-tagged-template-expression/index.js +1 -1
  30. package/dist/esm/rules/utils/create-no-exported-rule/main.js +1 -1
  31. package/dist/esm/rules/utils/create-no-tagged-template-expression-rule/index.js +1 -1
  32. package/dist/types/rules/consistent-css-prop-usage/types.d.ts +1 -1
  33. package/dist/types/rules/utils/create-no-exported-rule/check-if-supported-export.d.ts +1 -1
  34. package/dist/types/rules/utils/create-no-exported-rule/is-styled-component.d.ts +1 -1
  35. package/dist/types/rules/utils/create-no-exported-rule/main.d.ts +1 -1
  36. package/dist/types/rules/utils/create-no-tagged-template-expression-rule/index.d.ts +1 -1
  37. package/dist/types/rules/utils/get-first-supported-import.d.ts +1 -1
  38. package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +1 -1
  39. package/dist/types-ts4.5/rules/utils/create-no-exported-rule/check-if-supported-export.d.ts +1 -1
  40. package/dist/types-ts4.5/rules/utils/create-no-exported-rule/is-styled-component.d.ts +1 -1
  41. package/dist/types-ts4.5/rules/utils/create-no-exported-rule/main.d.ts +1 -1
  42. package/dist/types-ts4.5/rules/utils/create-no-tagged-template-expression-rule/index.d.ts +1 -1
  43. package/dist/types-ts4.5/rules/utils/get-first-supported-import.d.ts +1 -1
  44. package/package.json +2 -1
  45. package/dist/cjs/rules/utils/is-supported-import.js +0 -160
  46. package/dist/es2019/rules/utils/is-supported-import.js +0 -150
  47. package/dist/esm/rules/utils/is-supported-import.js +0 -154
  48. package/dist/types/rules/utils/is-supported-import.d.ts +0 -46
  49. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +0 -46
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 9.2.4
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
+
3
10
  ## 9.2.3
4
11
 
5
12
  ### Patch Changes
@@ -12,11 +12,11 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
12
12
  var _eslintCodemodUtils = require("eslint-codemod-utils");
13
13
  var _estraverse = _interopRequireDefault(require("estraverse"));
14
14
  var _assign = _interopRequireDefault(require("lodash/assign"));
15
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
15
16
  var _astNodes = require("../../ast-nodes");
16
17
  var _createRule = require("../utils/create-rule");
17
18
  var _getFirstSupportedImport = require("../utils/get-first-supported-import");
18
19
  var _getImportNodeBySource = require("../utils/get-import-node-by-source");
19
- var _isSupportedImport = require("../utils/is-supported-import");
20
20
  // eslint-disable-next-line import/no-extraneous-dependencies
21
21
 
22
22
  var isDOMElementName = function isDOMElementName(elementName) {
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
7
8
  var _createNoTaggedTemplateExpressionRule = require("../utils/create-no-tagged-template-expression-rule");
8
9
  var _createRule = require("../utils/create-rule");
9
- var _isSupportedImport = require("../utils/is-supported-import");
10
10
  var rule = (0, _createRule.createLintRule)({
11
11
  meta: {
12
12
  name: 'no-css-tagged-template-expression',
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
9
10
  var _createRule = require("../utils/create-rule");
10
- var _isSupportedImport = require("../utils/is-supported-import");
11
11
  var isEmptyStyledExpression = function isEmptyStyledExpression(node) {
12
12
  var _node$arguments = (0, _slicedToArray2.default)(node.arguments, 1),
13
13
  firstArg = _node$arguments[0];
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
7
8
  var _main = require("../utils/create-no-exported-rule/main");
8
9
  var _createRule = require("../utils/create-rule");
9
- var _isSupportedImport = require("../utils/is-supported-import");
10
10
  var noExportedCssRule = (0, _createRule.createLintRule)({
11
11
  meta: {
12
12
  name: 'no-exported-css',
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
7
8
  var _main = require("../utils/create-no-exported-rule/main");
8
9
  var _createRule = require("../utils/create-rule");
9
- var _isSupportedImport = require("../utils/is-supported-import");
10
10
  var noExportedKeyframesRule = (0, _createRule.createLintRule)({
11
11
  meta: {
12
12
  name: 'no-exported-keyframes',
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
7
8
  var _checkIfSupportedExport = require("../utils/create-no-exported-rule/check-if-supported-export");
8
9
  var _createRule = require("../utils/create-rule");
9
- var _isSupportedImport = require("../utils/is-supported-import");
10
10
  var _utils = require("./utils");
11
11
  var IMPORT_SOURCES = [_isSupportedImport.CSS_IN_JS_IMPORTS.compiled, _isSupportedImport.CSS_IN_JS_IMPORTS.atlaskitCss];
12
12
  var reportIfExported = function reportIfExported(node, context) {
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
7
8
  var _createNoTaggedTemplateExpressionRule = require("../utils/create-no-tagged-template-expression-rule");
8
9
  var _createRule = require("../utils/create-rule");
9
- var _isSupportedImport = require("../utils/is-supported-import");
10
10
  var rule = (0, _createRule.createLintRule)({
11
11
  meta: {
12
12
  name: 'no-keyframes-tagged-template-expression',
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
7
8
  var _createNoTaggedTemplateExpressionRule = require("../utils/create-no-tagged-template-expression-rule");
8
9
  var _createRule = require("../utils/create-rule");
9
- var _isSupportedImport = require("../utils/is-supported-import");
10
10
  var rule = (0, _createRule.createLintRule)({
11
11
  meta: {
12
12
  name: 'no-styled-tagged-template-expression',
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createNoExportedRule = void 0;
7
- var _isSupportedImport = require("../is-supported-import");
7
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
8
8
  var _checkIfSupportedExport = require("./check-if-supported-export");
9
9
  /**
10
10
  * Creates a new ESLint rule for banning exporting certain function calls, e.g.
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.noTaggedTemplateExpressionRuleSchema = exports.createNoTaggedTemplateExpressionRule = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _esquery = _interopRequireDefault(require("esquery"));
10
- var _isSupportedImport = require("../is-supported-import");
10
+ var _isSupportedImport = require("@atlaskit/eslint-utils/is-supported-import");
11
11
  var _generate = require("./generate");
12
12
  var _getTaggedTemplateExpressionOffset = require("./get-tagged-template-expression-offset");
13
13
  var _toArguments = require("./to-arguments");
@@ -3,11 +3,11 @@
3
3
  import { getIdentifierInParentScope, insertAtStartOfFile, insertImportDeclaration, isNodeOfType } from 'eslint-codemod-utils';
4
4
  import estraverse from 'estraverse';
5
5
  import assign from 'lodash/assign';
6
+ import { CSS_IN_JS_IMPORTS } from '@atlaskit/eslint-utils/is-supported-import';
6
7
  import { Import } from '../../ast-nodes';
7
8
  import { createLintRule } from '../utils/create-rule';
8
9
  import { getFirstSupportedImport } from '../utils/get-first-supported-import';
9
10
  import { getModuleOfIdentifier } from '../utils/get-import-node-by-source';
10
- import { CSS_IN_JS_IMPORTS } from '../utils/is-supported-import';
11
11
  const isDOMElementName = elementName => elementName.charAt(0) !== elementName.charAt(0).toUpperCase() && elementName.charAt(0) === elementName.charAt(0).toLowerCase();
12
12
  function isCssCallExpression(node, cssFunctions) {
13
13
  cssFunctions = [...cssFunctions, 'cssMap'];
@@ -1,6 +1,6 @@
1
+ import { isCss } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoTaggedTemplateExpressionRule, noTaggedTemplateExpressionRuleSchema } from '../utils/create-no-tagged-template-expression-rule';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isCss } from '../utils/is-supported-import';
4
4
  const rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-css-tagged-template-expression',
@@ -1,5 +1,5 @@
1
+ import { getImportSources, isStyled } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createLintRule } from '../utils/create-rule';
2
- import { getImportSources, isStyled } from '../utils/is-supported-import';
3
3
  const isEmptyStyledExpression = node => {
4
4
  const [firstArg] = node.arguments;
5
5
  if (node.arguments.length === 0) {
@@ -1,6 +1,6 @@
1
+ import { isCss } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoExportedRule } from '../utils/create-no-exported-rule/main';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isCss } from '../utils/is-supported-import';
4
4
  const noExportedCssRule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-exported-css',
@@ -1,6 +1,6 @@
1
+ import { isKeyframes } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoExportedRule } from '../utils/create-no-exported-rule/main';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isKeyframes } from '../utils/is-supported-import';
4
4
  const noExportedKeyframesRule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-exported-keyframes',
@@ -1,6 +1,6 @@
1
+ import { CSS_IN_JS_IMPORTS, isCssMap } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { checkIfSupportedExport } from '../utils/create-no-exported-rule/check-if-supported-export';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { CSS_IN_JS_IMPORTS, isCssMap } from '../utils/is-supported-import';
4
4
  import { CssMapObjectChecker, getCssMapObject } from './utils';
5
5
  const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
6
6
  const reportIfExported = (node, context) => {
@@ -1,6 +1,6 @@
1
+ import { isKeyframes } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoTaggedTemplateExpressionRule, noTaggedTemplateExpressionRuleSchema } from '../utils/create-no-tagged-template-expression-rule';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isKeyframes } from '../utils/is-supported-import';
4
4
  const rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-keyframes-tagged-template-expression',
@@ -1,6 +1,6 @@
1
+ import { isStyled } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoTaggedTemplateExpressionRule, noTaggedTemplateExpressionRuleSchema } from '../utils/create-no-tagged-template-expression-rule';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isStyled } from '../utils/is-supported-import';
4
4
  const rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-styled-tagged-template-expression',
@@ -1,4 +1,4 @@
1
- import { getImportSources } from '../is-supported-import';
1
+ import { getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
2
2
  import { checkIfSupportedExport } from './check-if-supported-export';
3
3
  /**
4
4
  * Creates a new ESLint rule for banning exporting certain function calls, e.g.
@@ -2,7 +2,7 @@
2
2
  // eslint-disable-next-line import/no-extraneous-dependencies
3
3
 
4
4
  import esquery from 'esquery';
5
- import { getImportSources, isEmotion, isStyledComponents } from '../is-supported-import';
5
+ import { getImportSources, isEmotion, isStyledComponents } from '@atlaskit/eslint-utils/is-supported-import';
6
6
  import { generate } from './generate';
7
7
  import { getTaggedTemplateExpressionOffset } from './get-tagged-template-expression-offset';
8
8
  import { toArguments } from './to-arguments';
@@ -7,11 +7,11 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
7
7
  import { getIdentifierInParentScope, insertAtStartOfFile, insertImportDeclaration, isNodeOfType } from 'eslint-codemod-utils';
8
8
  import estraverse from 'estraverse';
9
9
  import assign from 'lodash/assign';
10
+ import { CSS_IN_JS_IMPORTS } from '@atlaskit/eslint-utils/is-supported-import';
10
11
  import { Import } from '../../ast-nodes';
11
12
  import { createLintRule } from '../utils/create-rule';
12
13
  import { getFirstSupportedImport } from '../utils/get-first-supported-import';
13
14
  import { getModuleOfIdentifier } from '../utils/get-import-node-by-source';
14
- import { CSS_IN_JS_IMPORTS } from '../utils/is-supported-import';
15
15
  var isDOMElementName = function isDOMElementName(elementName) {
16
16
  return elementName.charAt(0) !== elementName.charAt(0).toUpperCase() && elementName.charAt(0) === elementName.charAt(0).toLowerCase();
17
17
  };
@@ -1,6 +1,6 @@
1
+ import { isCss } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoTaggedTemplateExpressionRule, noTaggedTemplateExpressionRuleSchema } from '../utils/create-no-tagged-template-expression-rule';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isCss } from '../utils/is-supported-import';
4
4
  var rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-css-tagged-template-expression',
@@ -1,6 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { getImportSources, isStyled } from '@atlaskit/eslint-utils/is-supported-import';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { getImportSources, isStyled } from '../utils/is-supported-import';
4
4
  var isEmptyStyledExpression = function isEmptyStyledExpression(node) {
5
5
  var _node$arguments = _slicedToArray(node.arguments, 1),
6
6
  firstArg = _node$arguments[0];
@@ -1,6 +1,6 @@
1
+ import { isCss } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoExportedRule } from '../utils/create-no-exported-rule/main';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isCss } from '../utils/is-supported-import';
4
4
  var noExportedCssRule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-exported-css',
@@ -1,6 +1,6 @@
1
+ import { isKeyframes } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoExportedRule } from '../utils/create-no-exported-rule/main';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isKeyframes } from '../utils/is-supported-import';
4
4
  var noExportedKeyframesRule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-exported-keyframes',
@@ -1,6 +1,6 @@
1
+ import { CSS_IN_JS_IMPORTS, isCssMap } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { checkIfSupportedExport } from '../utils/create-no-exported-rule/check-if-supported-export';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { CSS_IN_JS_IMPORTS, isCssMap } from '../utils/is-supported-import';
4
4
  import { CssMapObjectChecker, getCssMapObject } from './utils';
5
5
  var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
6
6
  var reportIfExported = function reportIfExported(node, context) {
@@ -1,6 +1,6 @@
1
+ import { isKeyframes } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoTaggedTemplateExpressionRule, noTaggedTemplateExpressionRuleSchema } from '../utils/create-no-tagged-template-expression-rule';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isKeyframes } from '../utils/is-supported-import';
4
4
  var rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-keyframes-tagged-template-expression',
@@ -1,6 +1,6 @@
1
+ import { isStyled } from '@atlaskit/eslint-utils/is-supported-import';
1
2
  import { createNoTaggedTemplateExpressionRule, noTaggedTemplateExpressionRuleSchema } from '../utils/create-no-tagged-template-expression-rule';
2
3
  import { createLintRule } from '../utils/create-rule';
3
- import { isStyled } from '../utils/is-supported-import';
4
4
  var rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-styled-tagged-template-expression',
@@ -1,4 +1,4 @@
1
- import { getImportSources } from '../is-supported-import';
1
+ import { getImportSources } from '@atlaskit/eslint-utils/is-supported-import';
2
2
  import { checkIfSupportedExport } from './check-if-supported-export';
3
3
  /**
4
4
  * Creates a new ESLint rule for banning exporting certain function calls, e.g.
@@ -3,7 +3,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies
4
4
 
5
5
  import esquery from 'esquery';
6
- import { getImportSources, isEmotion, isStyledComponents } from '../is-supported-import';
6
+ import { getImportSources, isEmotion, isStyledComponents } from '@atlaskit/eslint-utils/is-supported-import';
7
7
  import { generate } from './generate';
8
8
  import { getTaggedTemplateExpressionOffset } from './get-tagged-template-expression-offset';
9
9
  import { toArguments } from './to-arguments';
@@ -1,4 +1,4 @@
1
- import type { ImportSource } from '../utils/is-supported-import';
1
+ import type { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
2
2
  export type RuleConfig = {
3
3
  cssFunctions: string[];
4
4
  stylesPlacement: 'top' | 'bottom';
@@ -1,5 +1,5 @@
1
1
  import type { Rule, Scope as ScopeNamespace } from 'eslint';
2
- import { ImportSource } from '../is-supported-import';
2
+ import { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  type Node = Rule.Node;
4
4
  type RuleContext = Rule.RuleContext;
5
5
  type Scope = ScopeNamespace.Scope;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import type { ImportSource } from '../is-supported-import';
2
+ import type { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  type Node = Rule.Node;
4
4
  type RuleContext = Rule.RuleContext;
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { type SupportedNameChecker } from '../is-supported-import';
2
+ import { type SupportedNameChecker } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  type RuleModule = Rule.RuleModule;
4
4
  /**
5
5
  * Creates a new ESLint rule for banning exporting certain function calls, e.g.
@@ -1,6 +1,6 @@
1
1
  import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
2
2
  import type { Rule } from 'eslint';
3
- import { SupportedNameChecker } from '../is-supported-import';
3
+ import { SupportedNameChecker } from '@atlaskit/eslint-utils/is-supported-import';
4
4
  type RuleModule = Rule.RuleModule;
5
5
  export declare const noTaggedTemplateExpressionRuleSchema: JSONSchema4;
6
6
  export declare const createNoTaggedTemplateExpressionRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
@@ -1,6 +1,6 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { ImportDeclaration } from 'eslint-codemod-utils';
3
- import { ImportSource } from './is-supported-import';
3
+ import { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
4
4
  type RuleContext = Rule.RuleContext;
5
5
  /**
6
6
  * Get the first import declaration in the file that matches any of the packages
@@ -1,4 +1,4 @@
1
- import type { ImportSource } from '../utils/is-supported-import';
1
+ import type { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
2
2
  export type RuleConfig = {
3
3
  cssFunctions: string[];
4
4
  stylesPlacement: 'top' | 'bottom';
@@ -1,5 +1,5 @@
1
1
  import type { Rule, Scope as ScopeNamespace } from 'eslint';
2
- import { ImportSource } from '../is-supported-import';
2
+ import { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  type Node = Rule.Node;
4
4
  type RuleContext = Rule.RuleContext;
5
5
  type Scope = ScopeNamespace.Scope;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import type { ImportSource } from '../is-supported-import';
2
+ import type { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  type Node = Rule.Node;
4
4
  type RuleContext = Rule.RuleContext;
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { type SupportedNameChecker } from '../is-supported-import';
2
+ import { type SupportedNameChecker } from '@atlaskit/eslint-utils/is-supported-import';
3
3
  type RuleModule = Rule.RuleModule;
4
4
  /**
5
5
  * Creates a new ESLint rule for banning exporting certain function calls, e.g.
@@ -1,6 +1,6 @@
1
1
  import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
2
2
  import type { Rule } from 'eslint';
3
- import { SupportedNameChecker } from '../is-supported-import';
3
+ import { SupportedNameChecker } from '@atlaskit/eslint-utils/is-supported-import';
4
4
  type RuleModule = Rule.RuleModule;
5
5
  export declare const noTaggedTemplateExpressionRuleSchema: JSONSchema4;
6
6
  export declare const createNoTaggedTemplateExpressionRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
@@ -1,6 +1,6 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { ImportDeclaration } from 'eslint-codemod-utils';
3
- import { ImportSource } from './is-supported-import';
3
+ import { ImportSource } from '@atlaskit/eslint-utils/is-supported-import';
4
4
  type RuleContext = Rule.RuleContext;
5
5
  /**
6
6
  * Get the first import declaration in the file that matches any of the packages
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "9.2.3",
4
+ "version": "9.2.4",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -37,6 +37,7 @@
37
37
  ".": "./src/index.tsx"
38
38
  },
39
39
  "dependencies": {
40
+ "@atlaskit/eslint-utils": "^1.0.0",
40
41
  "@atlaskit/tokens": "*",
41
42
  "@babel/runtime": "^7.0.0",
42
43
  "@typescript-eslint/utils": "^5.48.1",
@@ -1,160 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isXcss = exports.isStyledComponents = exports.isStyled = exports.isKeyframes = exports.isImportedFrom = exports.isEmotion = exports.isCxFunction = exports.isCssMap = exports.isCss = exports.isCompiled = exports.getImportSources = exports.DEFAULT_IMPORT_SOURCES = exports.CSS_IN_JS_IMPORTS = void 0;
7
- // This should be kept in sync with
8
- // packages/design-system/eslint-plugin-ui-styling-standard/src/rules/utils/is-supported-import.tsx
9
- // whenever possible.
10
- //
11
- // TODO: would having an @atlassian/eslint-plugin-design-system-common
12
- // package be useful?
13
-
14
- // eslint-disable-next-line import/no-extraneous-dependencies
15
-
16
- var CSS_IN_JS_IMPORTS = exports.CSS_IN_JS_IMPORTS = {
17
- compiled: '@compiled/react',
18
- emotionReact: '@emotion/react',
19
- emotionCore: '@emotion/core',
20
- emotionStyled: '@emotion/styled',
21
- styledComponents: 'styled-components',
22
- atlaskitCss: '@atlaskit/css',
23
- atlaskitPrimitives: '@atlaskit/primitives'
24
- };
25
-
26
- // A CSS-in-JS library an import of a valid css, cx, cssMap, etc.
27
- // function might originate from, e.g. @compiled/react, @emotion/core.
28
-
29
- /**
30
- * By default all known import sources are checked against.
31
- */
32
- var DEFAULT_IMPORT_SOURCES = exports.DEFAULT_IMPORT_SOURCES = Object.values(CSS_IN_JS_IMPORTS);
33
- var getIdentifierNode = function getIdentifierNode(node) {
34
- var identifierNode = node.type === 'Identifier' ? node : undefined;
35
- if (!identifierNode) {
36
- // Handles styled.div`` case
37
- if (node.type === 'MemberExpression' && node.object.type === 'Identifier') {
38
- identifierNode = node.object;
39
- }
40
-
41
- // Handles styled(Component)`` case
42
- if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {
43
- identifierNode = node.callee;
44
- }
45
- }
46
- return identifierNode;
47
- };
48
-
49
- /**
50
- * Given the ESLint rule context, extract and parse the value of the importSources rule option.
51
- * The importSources option is used to override which libraries an ESLint rule applies to.
52
- *
53
- * @param context The rule context.
54
- * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
55
- * on the rule options configuration.
56
- */
57
- var getImportSources = exports.getImportSources = function getImportSources(context) {
58
- var options = context.options;
59
- if (!options.length) {
60
- return DEFAULT_IMPORT_SOURCES;
61
- }
62
- if (options[0].importSources && Array.isArray(options[0].importSources)) {
63
- return options[0].importSources;
64
- }
65
- return DEFAULT_IMPORT_SOURCES;
66
- };
67
- var isSupportedImportWrapper = function isSupportedImportWrapper(functionName) {
68
- var defaultFromImportSources = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
69
- var checkDefinitionHasImport = function checkDefinitionHasImport(def, importSources) {
70
- if (def.type !== 'ImportBinding') {
71
- return false;
72
- }
73
- if (!def.parent || !importSources.includes(def.parent.source.value)) {
74
- return false;
75
- }
76
-
77
- // Matches the imported name from a named import
78
- // import { functionName, functioName as otherName } from 'import-source';
79
- var isNamedImport = def.node.type === 'ImportSpecifier' && def.node.imported.name === functionName;
80
-
81
- // Must explicitly match the local name from a default import
82
- // import functionName from 'import-source';
83
- var isDefaultImportMatchingLocal = def.node.type === 'ImportDefaultSpecifier' && def.node.local.name === functionName;
84
-
85
- // Can match any local name from a default import
86
- // import anything from 'import-source'
87
- var isKnownDefaultImport = def.node.type === 'ImportDefaultSpecifier' && defaultFromImportSources.includes(def.parent.source.value);
88
- return isNamedImport || isDefaultImportMatchingLocal || isKnownDefaultImport;
89
- };
90
-
91
- /**
92
- * Checks whether:
93
- *
94
- * 1. A function name `nodeToCheck` matches the name of the function we
95
- * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
96
- * 2. Whether `nodeToCheck` originates from one of the libraries listed
97
- * in `importSources`.
98
- *
99
- * @param nodeToCheck The function callee we are checking (e.g. The `css` in `css()`).
100
- * @param referencesInScope List of references that are in scope. We'll use this
101
- * to check where the function callee is imported from.
102
- * @param importSources List of libraries that we want to ensure `nodeToCheck`
103
- * comes from.
104
- *
105
- * @returns Whether the above conditions are true.
106
- */
107
- var isSupportedImport = function isSupportedImport(nodeToCheck, referencesInScope, importSources) {
108
- var identifierNode = getIdentifierNode(nodeToCheck);
109
- return (identifierNode === null || identifierNode === void 0 ? void 0 : identifierNode.type) === 'Identifier' && referencesInScope.some(function (reference) {
110
- var _reference$resolved;
111
- return reference.identifier === identifierNode && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(function (def) {
112
- return checkDefinitionHasImport(def, importSources);
113
- }));
114
- });
115
- };
116
- return isSupportedImport;
117
- };
118
-
119
- // Unused functions have been commented out until we implement corresponding
120
- // eslint rules which use them
121
- //
122
- var isCss = exports.isCss = isSupportedImportWrapper('css');
123
- var isCxFunction = exports.isCxFunction = isSupportedImportWrapper('cx');
124
- var isCssMap = exports.isCssMap = isSupportedImportWrapper('cssMap');
125
- var isKeyframes = exports.isKeyframes = isSupportedImportWrapper('keyframes');
126
- // `styled` is also the explicit default of `styled-components` and `@emotion/styled`, so we also match on default imports generally
127
- var isStyled = exports.isStyled = isSupportedImportWrapper('styled', ['styled-components', '@emotion/styled']);
128
- var isXcss = exports.isXcss = isSupportedImportWrapper('xcss');
129
- var isImportedFrom = exports.isImportedFrom = function isImportedFrom(moduleName) {
130
- var exactMatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
131
- return function (nodeToCheck, referencesInScope) {
132
- var importSources = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
133
- if (importSources && !importSources.some(function (importSource) {
134
- return importSource === moduleName || !exactMatch && importSource.startsWith(moduleName);
135
- })) {
136
- // Don't go through the trouble of checking the import sources does not include this
137
- // We'll assume this is skipped elsewhere.
138
- return false;
139
- }
140
- var identifierNode = getIdentifierNode(nodeToCheck);
141
- return (identifierNode === null || identifierNode === void 0 ? void 0 : identifierNode.type) === 'Identifier' && referencesInScope.some(function (reference) {
142
- var _reference$resolved2;
143
- return reference.identifier === identifierNode && ((_reference$resolved2 = reference.resolved) === null || _reference$resolved2 === void 0 ? void 0 : _reference$resolved2.defs.some(function (def) {
144
- var _def$parent, _String, _def$parent2;
145
- return def.type === 'ImportBinding' && (((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.source.value) === moduleName || !exactMatch && ((_String = String((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value)) === null || _String === void 0 ? void 0 : _String.startsWith(moduleName)));
146
- }));
147
- });
148
- };
149
- };
150
-
151
- /**
152
- * Determine if this node is specifically from a `'styled-components'` import.
153
- * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
154
- * we need to handle them differently in a few scenarios.
155
- *
156
- * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
157
- */
158
- var isStyledComponents = exports.isStyledComponents = isImportedFrom('styled-components');
159
- var isCompiled = exports.isCompiled = isImportedFrom('@compiled/', false);
160
- var isEmotion = exports.isEmotion = isImportedFrom('@emotion/', false);
@@ -1,150 +0,0 @@
1
- // This should be kept in sync with
2
- // packages/design-system/eslint-plugin-ui-styling-standard/src/rules/utils/is-supported-import.tsx
3
- // whenever possible.
4
- //
5
- // TODO: would having an @atlassian/eslint-plugin-design-system-common
6
- // package be useful?
7
-
8
- // eslint-disable-next-line import/no-extraneous-dependencies
9
-
10
- export const CSS_IN_JS_IMPORTS = {
11
- compiled: '@compiled/react',
12
- emotionReact: '@emotion/react',
13
- emotionCore: '@emotion/core',
14
- emotionStyled: '@emotion/styled',
15
- styledComponents: 'styled-components',
16
- atlaskitCss: '@atlaskit/css',
17
- atlaskitPrimitives: '@atlaskit/primitives'
18
- };
19
-
20
- // A CSS-in-JS library an import of a valid css, cx, cssMap, etc.
21
- // function might originate from, e.g. @compiled/react, @emotion/core.
22
-
23
- /**
24
- * By default all known import sources are checked against.
25
- */
26
- export const DEFAULT_IMPORT_SOURCES = Object.values(CSS_IN_JS_IMPORTS);
27
- const getIdentifierNode = node => {
28
- let identifierNode = node.type === 'Identifier' ? node : undefined;
29
- if (!identifierNode) {
30
- // Handles styled.div`` case
31
- if (node.type === 'MemberExpression' && node.object.type === 'Identifier') {
32
- identifierNode = node.object;
33
- }
34
-
35
- // Handles styled(Component)`` case
36
- if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {
37
- identifierNode = node.callee;
38
- }
39
- }
40
- return identifierNode;
41
- };
42
-
43
- /**
44
- * Given the ESLint rule context, extract and parse the value of the importSources rule option.
45
- * The importSources option is used to override which libraries an ESLint rule applies to.
46
- *
47
- * @param context The rule context.
48
- * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
49
- * on the rule options configuration.
50
- */
51
- export const getImportSources = context => {
52
- const options = context.options;
53
- if (!options.length) {
54
- return DEFAULT_IMPORT_SOURCES;
55
- }
56
- if (options[0].importSources && Array.isArray(options[0].importSources)) {
57
- return options[0].importSources;
58
- }
59
- return DEFAULT_IMPORT_SOURCES;
60
- };
61
- const isSupportedImportWrapper = (functionName, defaultFromImportSources = []) => {
62
- const checkDefinitionHasImport = (def, importSources) => {
63
- if (def.type !== 'ImportBinding') {
64
- return false;
65
- }
66
- if (!def.parent || !importSources.includes(def.parent.source.value)) {
67
- return false;
68
- }
69
-
70
- // Matches the imported name from a named import
71
- // import { functionName, functioName as otherName } from 'import-source';
72
- const isNamedImport = def.node.type === 'ImportSpecifier' && def.node.imported.name === functionName;
73
-
74
- // Must explicitly match the local name from a default import
75
- // import functionName from 'import-source';
76
- const isDefaultImportMatchingLocal = def.node.type === 'ImportDefaultSpecifier' && def.node.local.name === functionName;
77
-
78
- // Can match any local name from a default import
79
- // import anything from 'import-source'
80
- const isKnownDefaultImport = def.node.type === 'ImportDefaultSpecifier' && defaultFromImportSources.includes(def.parent.source.value);
81
- return isNamedImport || isDefaultImportMatchingLocal || isKnownDefaultImport;
82
- };
83
-
84
- /**
85
- * Checks whether:
86
- *
87
- * 1. A function name `nodeToCheck` matches the name of the function we
88
- * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
89
- * 2. Whether `nodeToCheck` originates from one of the libraries listed
90
- * in `importSources`.
91
- *
92
- * @param nodeToCheck The function callee we are checking (e.g. The `css` in `css()`).
93
- * @param referencesInScope List of references that are in scope. We'll use this
94
- * to check where the function callee is imported from.
95
- * @param importSources List of libraries that we want to ensure `nodeToCheck`
96
- * comes from.
97
- *
98
- * @returns Whether the above conditions are true.
99
- */
100
- const isSupportedImport = (nodeToCheck, referencesInScope, importSources) => {
101
- const identifierNode = getIdentifierNode(nodeToCheck);
102
- return (identifierNode === null || identifierNode === void 0 ? void 0 : identifierNode.type) === 'Identifier' && referencesInScope.some(reference => {
103
- var _reference$resolved;
104
- return reference.identifier === identifierNode && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(def => checkDefinitionHasImport(def, importSources)));
105
- });
106
- };
107
- return isSupportedImport;
108
- };
109
-
110
- // Unused functions have been commented out until we implement corresponding
111
- // eslint rules which use them
112
- //
113
- export const isCss = isSupportedImportWrapper('css');
114
- export const isCxFunction = isSupportedImportWrapper('cx');
115
- export const isCssMap = isSupportedImportWrapper('cssMap');
116
- export const isKeyframes = isSupportedImportWrapper('keyframes');
117
- // `styled` is also the explicit default of `styled-components` and `@emotion/styled`, so we also match on default imports generally
118
- export const isStyled = isSupportedImportWrapper('styled', ['styled-components', '@emotion/styled']);
119
- export const isXcss = isSupportedImportWrapper('xcss');
120
- export const isImportedFrom = (moduleName, exactMatch = true) => (nodeToCheck, referencesInScope,
121
- /**
122
- * If we strictly have specific import sources in the config scope, pass them to make this more performant.
123
- * Pass `null` if you don't care if its configured or not.
124
- */
125
- importSources = null) => {
126
- if (importSources && !importSources.some(importSource => importSource === moduleName || !exactMatch && importSource.startsWith(moduleName))) {
127
- // Don't go through the trouble of checking the import sources does not include this
128
- // We'll assume this is skipped elsewhere.
129
- return false;
130
- }
131
- const identifierNode = getIdentifierNode(nodeToCheck);
132
- return (identifierNode === null || identifierNode === void 0 ? void 0 : identifierNode.type) === 'Identifier' && referencesInScope.some(reference => {
133
- var _reference$resolved2;
134
- return reference.identifier === identifierNode && ((_reference$resolved2 = reference.resolved) === null || _reference$resolved2 === void 0 ? void 0 : _reference$resolved2.defs.some(def => {
135
- var _def$parent, _String, _def$parent2;
136
- return def.type === 'ImportBinding' && (((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.source.value) === moduleName || !exactMatch && ((_String = String((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value)) === null || _String === void 0 ? void 0 : _String.startsWith(moduleName)));
137
- }));
138
- });
139
- };
140
-
141
- /**
142
- * Determine if this node is specifically from a `'styled-components'` import.
143
- * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
144
- * we need to handle them differently in a few scenarios.
145
- *
146
- * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
147
- */
148
- export const isStyledComponents = isImportedFrom('styled-components');
149
- export const isCompiled = isImportedFrom('@compiled/', false);
150
- export const isEmotion = isImportedFrom('@emotion/', false);
@@ -1,154 +0,0 @@
1
- // This should be kept in sync with
2
- // packages/design-system/eslint-plugin-ui-styling-standard/src/rules/utils/is-supported-import.tsx
3
- // whenever possible.
4
- //
5
- // TODO: would having an @atlassian/eslint-plugin-design-system-common
6
- // package be useful?
7
-
8
- // eslint-disable-next-line import/no-extraneous-dependencies
9
-
10
- export var CSS_IN_JS_IMPORTS = {
11
- compiled: '@compiled/react',
12
- emotionReact: '@emotion/react',
13
- emotionCore: '@emotion/core',
14
- emotionStyled: '@emotion/styled',
15
- styledComponents: 'styled-components',
16
- atlaskitCss: '@atlaskit/css',
17
- atlaskitPrimitives: '@atlaskit/primitives'
18
- };
19
-
20
- // A CSS-in-JS library an import of a valid css, cx, cssMap, etc.
21
- // function might originate from, e.g. @compiled/react, @emotion/core.
22
-
23
- /**
24
- * By default all known import sources are checked against.
25
- */
26
- export var DEFAULT_IMPORT_SOURCES = Object.values(CSS_IN_JS_IMPORTS);
27
- var getIdentifierNode = function getIdentifierNode(node) {
28
- var identifierNode = node.type === 'Identifier' ? node : undefined;
29
- if (!identifierNode) {
30
- // Handles styled.div`` case
31
- if (node.type === 'MemberExpression' && node.object.type === 'Identifier') {
32
- identifierNode = node.object;
33
- }
34
-
35
- // Handles styled(Component)`` case
36
- if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {
37
- identifierNode = node.callee;
38
- }
39
- }
40
- return identifierNode;
41
- };
42
-
43
- /**
44
- * Given the ESLint rule context, extract and parse the value of the importSources rule option.
45
- * The importSources option is used to override which libraries an ESLint rule applies to.
46
- *
47
- * @param context The rule context.
48
- * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
49
- * on the rule options configuration.
50
- */
51
- export var getImportSources = function getImportSources(context) {
52
- var options = context.options;
53
- if (!options.length) {
54
- return DEFAULT_IMPORT_SOURCES;
55
- }
56
- if (options[0].importSources && Array.isArray(options[0].importSources)) {
57
- return options[0].importSources;
58
- }
59
- return DEFAULT_IMPORT_SOURCES;
60
- };
61
- var isSupportedImportWrapper = function isSupportedImportWrapper(functionName) {
62
- var defaultFromImportSources = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
63
- var checkDefinitionHasImport = function checkDefinitionHasImport(def, importSources) {
64
- if (def.type !== 'ImportBinding') {
65
- return false;
66
- }
67
- if (!def.parent || !importSources.includes(def.parent.source.value)) {
68
- return false;
69
- }
70
-
71
- // Matches the imported name from a named import
72
- // import { functionName, functioName as otherName } from 'import-source';
73
- var isNamedImport = def.node.type === 'ImportSpecifier' && def.node.imported.name === functionName;
74
-
75
- // Must explicitly match the local name from a default import
76
- // import functionName from 'import-source';
77
- var isDefaultImportMatchingLocal = def.node.type === 'ImportDefaultSpecifier' && def.node.local.name === functionName;
78
-
79
- // Can match any local name from a default import
80
- // import anything from 'import-source'
81
- var isKnownDefaultImport = def.node.type === 'ImportDefaultSpecifier' && defaultFromImportSources.includes(def.parent.source.value);
82
- return isNamedImport || isDefaultImportMatchingLocal || isKnownDefaultImport;
83
- };
84
-
85
- /**
86
- * Checks whether:
87
- *
88
- * 1. A function name `nodeToCheck` matches the name of the function we
89
- * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
90
- * 2. Whether `nodeToCheck` originates from one of the libraries listed
91
- * in `importSources`.
92
- *
93
- * @param nodeToCheck The function callee we are checking (e.g. The `css` in `css()`).
94
- * @param referencesInScope List of references that are in scope. We'll use this
95
- * to check where the function callee is imported from.
96
- * @param importSources List of libraries that we want to ensure `nodeToCheck`
97
- * comes from.
98
- *
99
- * @returns Whether the above conditions are true.
100
- */
101
- var isSupportedImport = function isSupportedImport(nodeToCheck, referencesInScope, importSources) {
102
- var identifierNode = getIdentifierNode(nodeToCheck);
103
- return (identifierNode === null || identifierNode === void 0 ? void 0 : identifierNode.type) === 'Identifier' && referencesInScope.some(function (reference) {
104
- var _reference$resolved;
105
- return reference.identifier === identifierNode && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(function (def) {
106
- return checkDefinitionHasImport(def, importSources);
107
- }));
108
- });
109
- };
110
- return isSupportedImport;
111
- };
112
-
113
- // Unused functions have been commented out until we implement corresponding
114
- // eslint rules which use them
115
- //
116
- export var isCss = isSupportedImportWrapper('css');
117
- export var isCxFunction = isSupportedImportWrapper('cx');
118
- export var isCssMap = isSupportedImportWrapper('cssMap');
119
- export var isKeyframes = isSupportedImportWrapper('keyframes');
120
- // `styled` is also the explicit default of `styled-components` and `@emotion/styled`, so we also match on default imports generally
121
- export var isStyled = isSupportedImportWrapper('styled', ['styled-components', '@emotion/styled']);
122
- export var isXcss = isSupportedImportWrapper('xcss');
123
- export var isImportedFrom = function isImportedFrom(moduleName) {
124
- var exactMatch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
125
- return function (nodeToCheck, referencesInScope) {
126
- var importSources = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
127
- if (importSources && !importSources.some(function (importSource) {
128
- return importSource === moduleName || !exactMatch && importSource.startsWith(moduleName);
129
- })) {
130
- // Don't go through the trouble of checking the import sources does not include this
131
- // We'll assume this is skipped elsewhere.
132
- return false;
133
- }
134
- var identifierNode = getIdentifierNode(nodeToCheck);
135
- return (identifierNode === null || identifierNode === void 0 ? void 0 : identifierNode.type) === 'Identifier' && referencesInScope.some(function (reference) {
136
- var _reference$resolved2;
137
- return reference.identifier === identifierNode && ((_reference$resolved2 = reference.resolved) === null || _reference$resolved2 === void 0 ? void 0 : _reference$resolved2.defs.some(function (def) {
138
- var _def$parent, _String, _def$parent2;
139
- return def.type === 'ImportBinding' && (((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.source.value) === moduleName || !exactMatch && ((_String = String((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value)) === null || _String === void 0 ? void 0 : _String.startsWith(moduleName)));
140
- }));
141
- });
142
- };
143
- };
144
-
145
- /**
146
- * Determine if this node is specifically from a `'styled-components'` import.
147
- * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
148
- * we need to handle them differently in a few scenarios.
149
- *
150
- * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
151
- */
152
- export var isStyledComponents = isImportedFrom('styled-components');
153
- export var isCompiled = isImportedFrom('@compiled/', false);
154
- export var isEmotion = isImportedFrom('@emotion/', false);
@@ -1,46 +0,0 @@
1
- import type { Rule, Scope } from 'eslint';
2
- import type { CallExpression } from 'estree';
3
- type Callee = CallExpression['callee'];
4
- type Reference = Scope.Reference;
5
- export declare const CSS_IN_JS_IMPORTS: {
6
- readonly compiled: "@compiled/react";
7
- readonly emotionReact: "@emotion/react";
8
- readonly emotionCore: "@emotion/core";
9
- readonly emotionStyled: "@emotion/styled";
10
- readonly styledComponents: "styled-components";
11
- readonly atlaskitCss: "@atlaskit/css";
12
- readonly atlaskitPrimitives: "@atlaskit/primitives";
13
- };
14
- export type ImportSource = string;
15
- export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
16
- /**
17
- * By default all known import sources are checked against.
18
- */
19
- export declare const DEFAULT_IMPORT_SOURCES: ImportSource[];
20
- /**
21
- * Given the ESLint rule context, extract and parse the value of the importSources rule option.
22
- * The importSources option is used to override which libraries an ESLint rule applies to.
23
- *
24
- * @param context The rule context.
25
- * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
26
- * on the rule options configuration.
27
- */
28
- export declare const getImportSources: (context: Rule.RuleContext) => ImportSource[];
29
- export declare const isCss: SupportedNameChecker;
30
- export declare const isCxFunction: SupportedNameChecker;
31
- export declare const isCssMap: SupportedNameChecker;
32
- export declare const isKeyframes: SupportedNameChecker;
33
- export declare const isStyled: SupportedNameChecker;
34
- export declare const isXcss: SupportedNameChecker;
35
- export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean) => (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
36
- /**
37
- * Determine if this node is specifically from a `'styled-components'` import.
38
- * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
39
- * we need to handle them differently in a few scenarios.
40
- *
41
- * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
42
- */
43
- export declare const isStyledComponents: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
44
- export declare const isCompiled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
45
- export declare const isEmotion: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
46
- export {};
@@ -1,46 +0,0 @@
1
- import type { Rule, Scope } from 'eslint';
2
- import type { CallExpression } from 'estree';
3
- type Callee = CallExpression['callee'];
4
- type Reference = Scope.Reference;
5
- export declare const CSS_IN_JS_IMPORTS: {
6
- readonly compiled: "@compiled/react";
7
- readonly emotionReact: "@emotion/react";
8
- readonly emotionCore: "@emotion/core";
9
- readonly emotionStyled: "@emotion/styled";
10
- readonly styledComponents: "styled-components";
11
- readonly atlaskitCss: "@atlaskit/css";
12
- readonly atlaskitPrimitives: "@atlaskit/primitives";
13
- };
14
- export type ImportSource = string;
15
- export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
16
- /**
17
- * By default all known import sources are checked against.
18
- */
19
- export declare const DEFAULT_IMPORT_SOURCES: ImportSource[];
20
- /**
21
- * Given the ESLint rule context, extract and parse the value of the importSources rule option.
22
- * The importSources option is used to override which libraries an ESLint rule applies to.
23
- *
24
- * @param context The rule context.
25
- * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
26
- * on the rule options configuration.
27
- */
28
- export declare const getImportSources: (context: Rule.RuleContext) => ImportSource[];
29
- export declare const isCss: SupportedNameChecker;
30
- export declare const isCxFunction: SupportedNameChecker;
31
- export declare const isCssMap: SupportedNameChecker;
32
- export declare const isKeyframes: SupportedNameChecker;
33
- export declare const isStyled: SupportedNameChecker;
34
- export declare const isXcss: SupportedNameChecker;
35
- export declare const isImportedFrom: (moduleName: string, exactMatch?: boolean) => (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
36
- /**
37
- * Determine if this node is specifically from a `'styled-components'` import.
38
- * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
39
- * we need to handle them differently in a few scenarios.
40
- *
41
- * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
42
- */
43
- export declare const isStyledComponents: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
44
- export declare const isCompiled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
45
- export declare const isEmotion: (nodeToCheck: Callee, referencesInScope: Reference[], importSources?: ImportSource[] | null) => boolean;
46
- export {};