@atlaskit/eslint-plugin-ui-styling-standard 0.7.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## 0.7.1
4
11
 
5
12
  ### Patch Changes
@@ -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); }
@@ -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;
@@ -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: {
@@ -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
  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,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;
@@ -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
  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: {
@@ -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,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;
@@ -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
  var schema = [{
5
5
  type: 'object',
6
6
  properties: {
@@ -1,6 +1,6 @@
1
1
  import estraverse from 'estraverse';
2
2
  import { createLintRule } from '../utils/create-rule';
3
- import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '../utils/is-supported-import';
3
+ import { isCss, getImportSources, isStyled, isKeyframes, isCssMap, isXcss } from '@atlaskit/eslint-utils/is-supported-import';
4
4
  var schema = [{
5
5
  type: 'object',
6
6
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
6
  "license": "Apache-2.0",
@@ -36,6 +36,7 @@
36
36
  ".": "./src/index.tsx"
37
37
  },
38
38
  "dependencies": {
39
+ "@atlaskit/eslint-utils": "^1.0.0",
39
40
  "@babel/runtime": "^7.0.0",
40
41
  "@typescript-eslint/utils": "^5.48.1",
41
42
  "eslint-codemod-utils": "^1.8.6",
@@ -8,7 +8,10 @@ import type {
8
8
  ObjectExpression,
9
9
  } from 'estree-jsx';
10
10
  import { createLintRule } from '../utils/create-rule';
11
- import { isStyledComponents, isEmotion } from '../utils/is-supported-import';
11
+ import {
12
+ isStyledComponents,
13
+ isEmotion,
14
+ } from '@atlaskit/eslint-utils/is-supported-import';
12
15
  import type { Rule, Scope, SourceCode } from 'eslint';
13
16
  import ESTraverse from 'estraverse';
14
17
 
@@ -2,7 +2,10 @@ import type { Rule } from 'eslint';
2
2
  import type { JSXAttribute } from 'estree-jsx';
3
3
 
4
4
  import { createLintRule } from '../utils/create-rule';
5
- import { CSS_IN_JS_IMPORTS, isCxFunction } from '../utils/is-supported-import';
5
+ import {
6
+ CSS_IN_JS_IMPORTS,
7
+ isCxFunction,
8
+ } from '@atlaskit/eslint-utils/is-supported-import';
6
9
 
7
10
  const IMPORT_SOURCES = [
8
11
  CSS_IN_JS_IMPORTS.compiled,
@@ -8,7 +8,7 @@ import {
8
8
  isKeyframes,
9
9
  isCssMap,
10
10
  isXcss,
11
- } from '../utils/is-supported-import';
11
+ } from '@atlaskit/eslint-utils/is-supported-import';
12
12
  import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
13
13
 
14
14
  const schema: JSONSchema4 = [
@@ -8,7 +8,7 @@ import {
8
8
  isKeyframes,
9
9
  isCssMap,
10
10
  isXcss,
11
- } from '../utils/is-supported-import';
11
+ } from '@atlaskit/eslint-utils/is-supported-import';
12
12
  import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
13
13
 
14
14
  const schema: JSONSchema4 = [
package/tsconfig.app.json CHANGED
@@ -33,6 +33,9 @@
33
33
  "outDir": "../../../tsDist/@atlaskit__eslint-plugin-ui-styling-standard/app"
34
34
  },
35
35
  "references": [
36
+ {
37
+ "path": "../eslint-utils/tsconfig.app.json"
38
+ },
36
39
  {
37
40
  "path": "../codegen/tsconfig.app.json"
38
41
  }
@@ -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/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/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/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 {};
@@ -1 +0,0 @@
1
- This contains utility functions copied over from `packages/design-system/eslint-plugin/src/rules/utils/` until we move the relevant eslint rules over to `packages/design-system/eslint-plugin-ui-styling-standard`.
@@ -1,227 +0,0 @@
1
- // This should be kept in sync with
2
- // packages/design-system/eslint-plugin/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
- import type { Rule, Scope } from 'eslint';
10
- import type { CallExpression } from 'estree';
11
-
12
- type Definition = Scope.Definition;
13
- type Callee = CallExpression['callee'];
14
- type Reference = Scope.Reference;
15
-
16
- export const 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
- } as const;
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
- export type ImportSource = string;
29
-
30
- export type SupportedNameChecker = (
31
- nodeToCheck: Callee,
32
- referencesInScope: Reference[],
33
- importSources: ImportSource[],
34
- ) => boolean;
35
-
36
- /**
37
- * By default all known import sources are checked against.
38
- */
39
- export const DEFAULT_IMPORT_SOURCES: ImportSource[] =
40
- Object.values(CSS_IN_JS_IMPORTS);
41
-
42
- const getIdentifierNode = (node: Callee) => {
43
- let identifierNode = node.type === 'Identifier' ? node : undefined;
44
- if (!identifierNode) {
45
- // Handles styled.div`` case
46
- if (node.type === 'MemberExpression' && node.object.type === 'Identifier') {
47
- identifierNode = node.object;
48
- }
49
-
50
- // Handles styled(Component)`` case
51
- if (node.type === 'CallExpression' && node.callee.type === 'Identifier') {
52
- identifierNode = node.callee;
53
- }
54
- }
55
- return identifierNode;
56
- };
57
-
58
- /**
59
- * Given the ESLint rule context, extract and parse the value of the importSources rule option.
60
- * The importSources option is used to override which libraries an ESLint rule applies to.
61
- *
62
- * @param context The rule context.
63
- * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
64
- * on the rule options configuration.
65
- */
66
- export const getImportSources = (context: Rule.RuleContext): ImportSource[] => {
67
- const options = context.options;
68
- if (!options.length) {
69
- return DEFAULT_IMPORT_SOURCES;
70
- }
71
-
72
- if (options[0].importSources && Array.isArray(options[0].importSources)) {
73
- return options[0].importSources;
74
- }
75
-
76
- return DEFAULT_IMPORT_SOURCES;
77
- };
78
-
79
- const isSupportedImportWrapper = (
80
- functionName: string,
81
- defaultFromImportSources: ImportSource[] = [],
82
- ): SupportedNameChecker => {
83
- const checkDefinitionHasImport = (
84
- def: Definition,
85
- importSources: ImportSource[],
86
- ) => {
87
- if (def.type !== 'ImportBinding') {
88
- return false;
89
- }
90
-
91
- if (
92
- !def.parent ||
93
- !importSources.includes(def.parent.source.value as ImportSource)
94
- ) {
95
- return false;
96
- }
97
-
98
- // Matches the imported name from a named import
99
- // import { functionName, functioName as otherName } from 'import-source';
100
- const isNamedImport =
101
- def.node.type === 'ImportSpecifier' &&
102
- def.node.imported.name === functionName;
103
-
104
- // Must explicitly match the local name from a default import
105
- // import functionName from 'import-source';
106
- const isDefaultImportMatchingLocal =
107
- def.node.type === 'ImportDefaultSpecifier' &&
108
- def.node.local.name === functionName;
109
-
110
- // Can match any local name from a default import
111
- // import anything from 'import-source'
112
- const isKnownDefaultImport =
113
- def.node.type === 'ImportDefaultSpecifier' &&
114
- defaultFromImportSources.includes(
115
- def.parent.source.value as ImportSource,
116
- );
117
-
118
- return (
119
- isNamedImport || isDefaultImportMatchingLocal || isKnownDefaultImport
120
- );
121
- };
122
-
123
- /**
124
- * Checks whether:
125
- *
126
- * 1. A function name `nodeToCheck` matches the name of the function we
127
- * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
128
- * 2. Whether `nodeToCheck` originates from one of the libraries listed
129
- * in `importSources`.
130
- *
131
- * @param nodeToCheck The function callee we are checking (e.g. The `css` in `css()`).
132
- * @param referencesInScope List of references that are in scope. We'll use this
133
- * to check where the function callee is imported from.
134
- * @param importSources List of libraries that we want to ensure `nodeToCheck`
135
- * comes from.
136
- *
137
- * @returns Whether the above conditions are true.
138
- */
139
- const isSupportedImport = (
140
- nodeToCheck: Callee,
141
- referencesInScope: Reference[],
142
- importSources: ImportSource[],
143
- ): boolean => {
144
- const identifierNode = getIdentifierNode(nodeToCheck);
145
-
146
- return (
147
- identifierNode?.type === 'Identifier' &&
148
- referencesInScope.some(
149
- (reference) =>
150
- reference.identifier === identifierNode &&
151
- reference.resolved?.defs.some((def) =>
152
- checkDefinitionHasImport(def, importSources),
153
- ),
154
- )
155
- );
156
- };
157
-
158
- return isSupportedImport;
159
- };
160
-
161
- // Unused functions have been commented out until we implement corresponding
162
- // eslint rules which use them
163
- //
164
- export const isCss = isSupportedImportWrapper('css');
165
- export const isCxFunction = isSupportedImportWrapper('cx');
166
- export const isCssMap = isSupportedImportWrapper('cssMap');
167
- export const isKeyframes = isSupportedImportWrapper('keyframes');
168
- // `styled` is also the explicit default of `styled-components` and `@emotion/styled`, so we also match on default imports generally
169
- export const isStyled = isSupportedImportWrapper('styled', [
170
- 'styled-components',
171
- '@emotion/styled',
172
- ]);
173
- export const isXcss = isSupportedImportWrapper('xcss');
174
-
175
- export const isImportedFrom =
176
- (moduleName: string, exactMatch = true) =>
177
- (
178
- nodeToCheck: Callee,
179
- referencesInScope: Reference[],
180
- /**
181
- * If we strictly have specific import sources in the config scope, pass them to make this more performant.
182
- * Pass `null` if you don't care if its configured or not.
183
- */
184
- importSources: ImportSource[] | null = null,
185
- ): boolean => {
186
- if (
187
- importSources &&
188
- !importSources.some(
189
- (importSource) =>
190
- importSource === moduleName ||
191
- (!exactMatch && importSource.startsWith(moduleName)),
192
- )
193
- ) {
194
- // Don't go through the trouble of checking the import sources does not include this
195
- // We'll assume this is skipped elsewhere.
196
- return false;
197
- }
198
-
199
- const identifierNode = getIdentifierNode(nodeToCheck);
200
-
201
- return (
202
- identifierNode?.type === 'Identifier' &&
203
- referencesInScope.some(
204
- (reference) =>
205
- reference.identifier === identifierNode &&
206
- reference.resolved?.defs.some((def) => {
207
- return (
208
- def.type === 'ImportBinding' &&
209
- (def.parent?.source.value === moduleName ||
210
- (!exactMatch &&
211
- String(def.parent?.source.value)?.startsWith(moduleName)))
212
- );
213
- }),
214
- )
215
- );
216
- };
217
-
218
- /**
219
- * Determine if this node is specifically from a `'styled-components'` import.
220
- * This is because `styled-components@3.4` APIs are not consistent with Emotion and Compiled,
221
- * we need to handle them differently in a few scenarios.
222
- *
223
- * This can be cleaned up when `'styled-components'` is no longer a valid ImportSource.
224
- */
225
- export const isStyledComponents = isImportedFrom('styled-components');
226
- export const isCompiled = isImportedFrom('@compiled/', false);
227
- export const isEmotion = isImportedFrom('@emotion/', false);