@atlaskit/eslint-plugin-design-system 8.23.3 → 8.23.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 (54) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -0
  3. package/constellation/index/usage.mdx +39 -0
  4. package/dist/cjs/ast-nodes/index.js +7 -0
  5. package/dist/cjs/ast-nodes/object.js +84 -0
  6. package/dist/cjs/presets/all.codegen.js +2 -1
  7. package/dist/cjs/presets/recommended.codegen.js +2 -1
  8. package/dist/cjs/rules/index.codegen.js +3 -1
  9. package/dist/cjs/rules/local-cx-xcss/index.js +51 -0
  10. package/dist/cjs/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +3 -1
  11. package/dist/cjs/rules/no-css-tagged-template-expression/index.js +2 -2
  12. package/dist/cjs/rules/utils/is-supported-import.js +61 -0
  13. package/dist/es2019/ast-nodes/index.js +1 -0
  14. package/dist/es2019/ast-nodes/object.js +79 -0
  15. package/dist/es2019/presets/all.codegen.js +2 -1
  16. package/dist/es2019/presets/recommended.codegen.js +2 -1
  17. package/dist/es2019/rules/index.codegen.js +3 -1
  18. package/dist/es2019/rules/local-cx-xcss/index.js +45 -0
  19. package/dist/es2019/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +3 -1
  20. package/dist/es2019/rules/no-css-tagged-template-expression/index.js +2 -2
  21. package/dist/es2019/rules/utils/is-supported-import.js +52 -0
  22. package/dist/esm/ast-nodes/index.js +1 -0
  23. package/dist/esm/ast-nodes/object.js +79 -0
  24. package/dist/esm/presets/all.codegen.js +2 -1
  25. package/dist/esm/presets/recommended.codegen.js +2 -1
  26. package/dist/esm/rules/index.codegen.js +3 -1
  27. package/dist/esm/rules/local-cx-xcss/index.js +45 -0
  28. package/dist/esm/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +3 -1
  29. package/dist/esm/rules/no-css-tagged-template-expression/index.js +2 -2
  30. package/dist/esm/rules/utils/is-supported-import.js +54 -0
  31. package/dist/types/ast-nodes/index.d.ts +1 -0
  32. package/dist/types/ast-nodes/object.d.ts +39 -0
  33. package/dist/types/index.codegen.d.ts +2 -0
  34. package/dist/types/presets/all.codegen.d.ts +2 -1
  35. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  36. package/dist/types/rules/index.codegen.d.ts +1 -0
  37. package/dist/types/rules/local-cx-xcss/index.d.ts +3 -0
  38. package/dist/types/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.d.ts +3 -4
  39. package/dist/types/rules/utils/is-supported-import.d.ts +16 -0
  40. package/dist/types-ts4.5/ast-nodes/index.d.ts +1 -0
  41. package/dist/types-ts4.5/ast-nodes/object.d.ts +39 -0
  42. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  43. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  44. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  45. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  46. package/dist/types-ts4.5/rules/local-cx-xcss/index.d.ts +3 -0
  47. package/dist/types-ts4.5/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.d.ts +3 -4
  48. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +16 -0
  49. package/package.json +1 -1
  50. package/dist/cjs/rules/no-css-tagged-template-expression/is-supported-import.js +0 -29
  51. package/dist/es2019/rules/no-css-tagged-template-expression/is-supported-import.js +0 -21
  52. package/dist/esm/rules/no-css-tagged-template-expression/is-supported-import.js +0 -23
  53. package/dist/types/rules/no-css-tagged-template-expression/is-supported-import.d.ts +0 -12
  54. package/dist/types-ts4.5/rules/no-css-tagged-template-expression/is-supported-import.d.ts +0 -12
@@ -0,0 +1,52 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+
3
+ export const CSS_IN_JS_IMPORTS = {
4
+ compiled: '@compiled/react',
5
+ emotionReact: '@emotion/react',
6
+ emotionCore: '@emotion/core',
7
+ styledComponents: 'styled-components',
8
+ atlaskitCss: '@atlaskit/css'
9
+ };
10
+
11
+ // List of CSS-in-JS libraries an import of a valid css, cx, cssMap, etc.
12
+ // function might originate from, e.g. @compiled/react, @emotion/core.
13
+ const isSupportedImportWrapper = functionName => {
14
+ // This will need to be extended to support default imports once we start
15
+ // checking cases like `import css from '@emotion/css'`
16
+ const checkDefinitionHasImport = (def, importSources) => {
17
+ var _def$parent, _def$parent2;
18
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && def.node.imported.name === functionName && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && importSources.includes((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value);
19
+ };
20
+
21
+ /**
22
+ * Checks whether:
23
+ *
24
+ * 1. a function name `nodeToCheck` matches the name of the function we
25
+ * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
26
+ * 2. whether `nodeToCheck` originates from one of the libraries listed
27
+ * in `importSources`.
28
+ *
29
+ * @param nodeToCheck the function callee we are checking (e.g. the `css` in `css()`)
30
+ * @param referencesInScope list of references that are in scope. We'll use this
31
+ * to check where the function callee is imported from.
32
+ * @param importSources list of libraries that we want to ensure `nodeToCheck`
33
+ * comes from
34
+ *
35
+ * @returns whether the above conditions are true
36
+ */
37
+ const isSupportedImport = (nodeToCheck, referencesInScope, importSources) => {
38
+ return nodeToCheck.type === 'Identifier' && referencesInScope.some(reference => {
39
+ var _reference$resolved;
40
+ return reference.identifier === nodeToCheck && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(def => checkDefinitionHasImport(def, importSources)));
41
+ });
42
+ };
43
+ return isSupportedImport;
44
+ };
45
+
46
+ // Unused functions have been commented out until we implement corresponding
47
+ // eslint rules which use them
48
+ //
49
+ export const isCss = isSupportedImportWrapper('css');
50
+ export const isCxFunction = isSupportedImportWrapper('cx');
51
+ // export const isCssMap = isLibraryImportWrapper('cssMap');
52
+ // export const isKeyframes = isLibraryImportWrapper('keyframes');
@@ -2,4 +2,5 @@ export { FunctionCall } from './function-call';
2
2
  export { Import } from './import';
3
3
  export { JSXAttribute } from './jsx-attribute';
4
4
  export { JSXElement } from './jsx-element';
5
+ export { Object } from './object';
5
6
  export { Root } from './root';
@@ -0,0 +1,79 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { identifier, isNodeOfType, literal, property } from 'eslint-codemod-utils';
4
+ var ASTObjectExpression = {
5
+ /**
6
+ * Returns `true` if an object contains a property with the specified name, `false` otherwise.
7
+ */
8
+ hasProperty: function hasProperty(node, name) {
9
+ return !!ASTObjectExpression.getProperty(node, name);
10
+ },
11
+ /**
12
+ * Returns a key-value pair like: `padding: '8px'` from: `{ padding: '8px' }`
13
+ */
14
+ getEntryByPropertyName: function getEntryByPropertyName(node, name) {
15
+ return node.properties.find(function (property) {
16
+ if (!isNodeOfType(property, 'Property')) {
17
+ return false;
18
+ }
19
+ if (!isNodeOfType(property.key, 'Identifier')) {
20
+ return false;
21
+ }
22
+ return property.key.name === name;
23
+ });
24
+ },
25
+ deleteEntry: function deleteEntry(node, name, fixer) {
26
+ var entry = ASTObjectExpression.getEntryByPropertyName(node, name);
27
+ if (!entry) {
28
+ return [];
29
+ }
30
+ return [fixer.remove(entry)];
31
+ },
32
+ /**
33
+ * Returns a only the property @type {Property['key']} like: `padding` from: `{ padding: '8px' }`
34
+ */
35
+ getProperty: function getProperty(node, name) {
36
+ var _ASTObjectExpression$;
37
+ return (_ASTObjectExpression$ = ASTObjectExpression.getEntryByPropertyName(node, name)) === null || _ASTObjectExpression$ === void 0 ? void 0 : _ASTObjectExpression$.key;
38
+ },
39
+ /**
40
+ * Returns a only the property @type {Property['value']} like: `'8px` from: `{ padding: '8px' }`
41
+ *
42
+ * Values can be basically anything, so be careful with this
43
+ */
44
+ getValueByPropertyName: function getValueByPropertyName(node, name) {
45
+ var _ASTObjectExpression$2;
46
+ return (_ASTObjectExpression$2 = ASTObjectExpression.getEntryByPropertyName(node, name)) === null || _ASTObjectExpression$2 === void 0 ? void 0 : _ASTObjectExpression$2.value;
47
+ },
48
+ containsSpreadProps: function containsSpreadProps(node) {
49
+ return node.properties.some(function (property) {
50
+ return isNodeOfType(property, 'SpreadElement');
51
+ });
52
+ },
53
+ updateValue: function updateValue(node, propertyName, newValue, fixer) {
54
+ var value = ASTObjectExpression.getValueByPropertyName(node, propertyName);
55
+ if (value === undefined) {
56
+ throw new Error("Object.updateValue: Could not get value of property ".concat(propertyName));
57
+ }
58
+ return fixer.replaceText(value, newValue);
59
+ },
60
+ /**
61
+ * Appends a key-value pair to the end of an object. For example:
62
+ * ```
63
+ * ast.Object.appendEntry(
64
+ * node, // { padding: 'space.100' }
65
+ * key, // 'margin',
66
+ * value, // 'space.200'
67
+ * fixer,
68
+ * )
69
+ * ```
70
+ * Will result in `{ padding: 'space.100', margin: 'space.200'}`
71
+ */
72
+ appendEntry: function appendEntry(node, key, value, fixer) {
73
+ return fixer.insertTextAfter(node.properties[node.properties.length - 1], "".concat(property({
74
+ key: identifier(key),
75
+ value: literal(value)
76
+ }).toString(), ", "));
77
+ }
78
+ };
79
+ export { ASTObjectExpression as Object };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::d1a459e1ea71650f65b2890dc86cc398>>
3
+ * @codegen <<SignedSource::5026ba2cb55b3c1bcacbfe7fb7728a6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  export default {
@@ -10,6 +10,7 @@ export default {
10
10
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
11
11
  '@atlaskit/design-system/ensure-design-token-usage/preview': 'warn',
12
12
  '@atlaskit/design-system/icon-label': 'warn',
13
+ '@atlaskit/design-system/local-cx-xcss': 'error',
13
14
  '@atlaskit/design-system/no-banned-imports': 'error',
14
15
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
15
16
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::3b93cfbbe0ea14514b9600509632394b>>
3
+ * @codegen <<SignedSource::839224bfab98c1ddf6018dec5320968e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  export default {
@@ -9,6 +9,7 @@ export default {
9
9
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
10
10
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
11
11
  '@atlaskit/design-system/icon-label': 'warn',
12
+ '@atlaskit/design-system/local-cx-xcss': 'error',
12
13
  '@atlaskit/design-system/no-banned-imports': 'error',
13
14
  '@atlaskit/design-system/no-deprecated-apis': 'error',
14
15
  '@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::14cdfdcbd8b999ee097a1a5b245d7117>>
3
+ * @codegen <<SignedSource::a67afc33adf50db651edb1cf12e16ef3>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import consistentCssPropUsage from './consistent-css-prop-usage';
7
7
  import ensureDesignTokenUsage from './ensure-design-token-usage';
8
8
  import ensureDesignTokenUsagePreview from './ensure-design-token-usage-preview';
9
9
  import iconLabel from './icon-label';
10
+ import localCxXcss from './local-cx-xcss';
10
11
  import noBannedImports from './no-banned-imports';
11
12
  import noCssTaggedTemplateExpression from './no-css-tagged-template-expression';
12
13
  import noDeprecatedApis from './no-deprecated-apis';
@@ -30,6 +31,7 @@ export default {
30
31
  'ensure-design-token-usage': ensureDesignTokenUsage,
31
32
  'ensure-design-token-usage/preview': ensureDesignTokenUsagePreview,
32
33
  'icon-label': iconLabel,
34
+ 'local-cx-xcss': localCxXcss,
33
35
  'no-banned-imports': noBannedImports,
34
36
  'no-css-tagged-template-expression': noCssTaggedTemplateExpression,
35
37
  'no-deprecated-apis': noDeprecatedApis,
@@ -0,0 +1,45 @@
1
+ import { createLintRule } from '../utils/create-rule';
2
+ import { CSS_IN_JS_IMPORTS, isCxFunction } from '../utils/is-supported-import';
3
+ var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
4
+ function getParentJSXAttribute(node) {
5
+ var parent = node.parent;
6
+ while (parent && parent.type !== 'JSXAttribute') {
7
+ parent = parent.parent;
8
+ }
9
+ if (parent && parent.type === 'JSXAttribute') {
10
+ return parent;
11
+ }
12
+ return null;
13
+ }
14
+ export var rule = createLintRule({
15
+ meta: {
16
+ name: 'local-cx-xcss',
17
+ docs: {
18
+ description: 'Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element.',
19
+ recommended: true,
20
+ severity: 'error'
21
+ },
22
+ messages: {
23
+ 'local-cx-xcss': 'The cx function should only be declared inside the xcss prop to simplify tracking styles that are applied to a jsx element.'
24
+ },
25
+ type: 'problem'
26
+ },
27
+ create: function create(context) {
28
+ return {
29
+ 'CallExpression[callee.name="cx"]': function CallExpressionCalleeNameCx(node) {
30
+ if (node.type === 'CallExpression' && isCxFunction(node.callee, context.getScope().references, IMPORT_SOURCES)) {
31
+ var parentJSXAttribute = getParentJSXAttribute(node);
32
+ var propName = parentJSXAttribute === null || parentJSXAttribute === void 0 ? void 0 : parentJSXAttribute.name.name.toString();
33
+ if (propName && /[xX]css$/.test(propName)) {
34
+ return;
35
+ }
36
+ context.report({
37
+ node: node,
38
+ messageId: 'local-cx-xcss'
39
+ });
40
+ }
41
+ }
42
+ };
43
+ }
44
+ });
45
+ export default rule;
@@ -2,16 +2,18 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
2
  // Original source from Compiled https://github.com/atlassian-labs/compiled/blob/master/packages/eslint-plugin/src/utils/create-no-tagged-template-expression-rule/index.ts
3
3
  // eslint-disable-next-line import/no-extraneous-dependencies
4
4
 
5
+ import { CSS_IN_JS_IMPORTS } from '../../utils/is-supported-import';
5
6
  import { generate } from './generate';
6
7
  import { getTaggedTemplateExpressionOffset } from './get-tagged-template-expression-offset';
7
8
  import { toArguments } from './to-arguments';
9
+ var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.emotionReact, CSS_IN_JS_IMPORTS.emotionCore, CSS_IN_JS_IMPORTS.styledComponents];
8
10
  export var createNoTaggedTemplateExpressionRule = function createNoTaggedTemplateExpressionRule(isUsage, messageId) {
9
11
  return function (context) {
10
12
  return {
11
13
  TaggedTemplateExpression: function TaggedTemplateExpression(node) {
12
14
  var _context$getScope = context.getScope(),
13
15
  references = _context$getScope.references;
14
- if (!isUsage(node.tag, references)) {
16
+ if (!isUsage(node.tag, references, IMPORT_SOURCES)) {
15
17
  return;
16
18
  }
17
19
  context.report({
@@ -1,6 +1,6 @@
1
1
  import { createLintRule } from '../utils/create-rule';
2
+ import { isCss } from '../utils/is-supported-import';
2
3
  import { createNoTaggedTemplateExpressionRule } from './create-no-tagged-template-expression-rule';
3
- import { isSupportedImport } from './is-supported-import';
4
4
  var rule = createLintRule({
5
5
  meta: {
6
6
  name: 'no-css-tagged-template-expression',
@@ -15,6 +15,6 @@ var rule = createLintRule({
15
15
  unexpectedTaggedTemplate: 'Unexpected `css` tagged template expression'
16
16
  }
17
17
  },
18
- create: createNoTaggedTemplateExpressionRule(isSupportedImport('css'), 'unexpectedTaggedTemplate')
18
+ create: createNoTaggedTemplateExpressionRule(isCss, 'unexpectedTaggedTemplate')
19
19
  });
20
20
  export default rule;
@@ -0,0 +1,54 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+
3
+ export var CSS_IN_JS_IMPORTS = {
4
+ compiled: '@compiled/react',
5
+ emotionReact: '@emotion/react',
6
+ emotionCore: '@emotion/core',
7
+ styledComponents: 'styled-components',
8
+ atlaskitCss: '@atlaskit/css'
9
+ };
10
+
11
+ // List of CSS-in-JS libraries an import of a valid css, cx, cssMap, etc.
12
+ // function might originate from, e.g. @compiled/react, @emotion/core.
13
+ var isSupportedImportWrapper = function isSupportedImportWrapper(functionName) {
14
+ // This will need to be extended to support default imports once we start
15
+ // checking cases like `import css from '@emotion/css'`
16
+ var checkDefinitionHasImport = function checkDefinitionHasImport(def, importSources) {
17
+ var _def$parent, _def$parent2;
18
+ return def.node.type === 'ImportSpecifier' && def.node.imported.type === 'Identifier' && def.node.imported.name === functionName && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.type) === 'ImportDeclaration' && importSources.includes((_def$parent2 = def.parent) === null || _def$parent2 === void 0 ? void 0 : _def$parent2.source.value);
19
+ };
20
+
21
+ /**
22
+ * Checks whether:
23
+ *
24
+ * 1. a function name `nodeToCheck` matches the name of the function we
25
+ * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
26
+ * 2. whether `nodeToCheck` originates from one of the libraries listed
27
+ * in `importSources`.
28
+ *
29
+ * @param nodeToCheck the function callee we are checking (e.g. the `css` in `css()`)
30
+ * @param referencesInScope list of references that are in scope. We'll use this
31
+ * to check where the function callee is imported from.
32
+ * @param importSources list of libraries that we want to ensure `nodeToCheck`
33
+ * comes from
34
+ *
35
+ * @returns whether the above conditions are true
36
+ */
37
+ var isSupportedImport = function isSupportedImport(nodeToCheck, referencesInScope, importSources) {
38
+ return nodeToCheck.type === 'Identifier' && referencesInScope.some(function (reference) {
39
+ var _reference$resolved;
40
+ return reference.identifier === nodeToCheck && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(function (def) {
41
+ return checkDefinitionHasImport(def, importSources);
42
+ }));
43
+ });
44
+ };
45
+ return isSupportedImport;
46
+ };
47
+
48
+ // Unused functions have been commented out until we implement corresponding
49
+ // eslint rules which use them
50
+ //
51
+ export var isCss = isSupportedImportWrapper('css');
52
+ export var isCxFunction = isSupportedImportWrapper('cx');
53
+ // export const isCssMap = isLibraryImportWrapper('cssMap');
54
+ // export const isKeyframes = isLibraryImportWrapper('keyframes');
@@ -2,4 +2,5 @@ export { FunctionCall } from './function-call';
2
2
  export { Import } from './import';
3
3
  export { JSXAttribute } from './jsx-attribute';
4
4
  export { JSXElement } from './jsx-element';
5
+ export { Object } from './object';
5
6
  export { Root } from './root';
@@ -0,0 +1,39 @@
1
+ import type { Rule } from 'eslint';
2
+ import { ObjectExpression, Property } from 'eslint-codemod-utils';
3
+ declare const ASTObjectExpression: {
4
+ /**
5
+ * Returns `true` if an object contains a property with the specified name, `false` otherwise.
6
+ */
7
+ hasProperty(node: ObjectExpression, name: string): boolean;
8
+ /**
9
+ * Returns a key-value pair like: `padding: '8px'` from: `{ padding: '8px' }`
10
+ */
11
+ getEntryByPropertyName(node: ObjectExpression, name: string): Property | undefined;
12
+ deleteEntry(node: ObjectExpression, name: string, fixer: Rule.RuleFixer): Rule.Fix[];
13
+ /**
14
+ * Returns a only the property @type {Property['key']} like: `padding` from: `{ padding: '8px' }`
15
+ */
16
+ getProperty(node: ObjectExpression, name: string): Property['key'] | undefined;
17
+ /**
18
+ * Returns a only the property @type {Property['value']} like: `'8px` from: `{ padding: '8px' }`
19
+ *
20
+ * Values can be basically anything, so be careful with this
21
+ */
22
+ getValueByPropertyName(node: ObjectExpression, name: string): Property['value'] | undefined;
23
+ containsSpreadProps(node: ObjectExpression): boolean;
24
+ updateValue(node: ObjectExpression, propertyName: string, newValue: string, fixer: Rule.RuleFixer): Rule.Fix;
25
+ /**
26
+ * Appends a key-value pair to the end of an object. For example:
27
+ * ```
28
+ * ast.Object.appendEntry(
29
+ * node, // { padding: 'space.100' }
30
+ * key, // 'margin',
31
+ * value, // 'space.200'
32
+ * fixer,
33
+ * )
34
+ * ```
35
+ * Will result in `{ padding: 'space.100', margin: 'space.200'}`
36
+ */
37
+ appendEntry(node: ObjectExpression, key: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
38
+ };
39
+ export { ASTObjectExpression as Object };
@@ -7,6 +7,7 @@ export declare const configs: {
7
7
  '@atlaskit/design-system/ensure-design-token-usage': string;
8
8
  '@atlaskit/design-system/ensure-design-token-usage/preview': string;
9
9
  '@atlaskit/design-system/icon-label': string;
10
+ '@atlaskit/design-system/local-cx-xcss': string;
10
11
  '@atlaskit/design-system/no-banned-imports': string;
11
12
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
12
13
  '@atlaskit/design-system/no-deprecated-apis': string;
@@ -33,6 +34,7 @@ export declare const configs: {
33
34
  '@atlaskit/design-system/consistent-css-prop-usage': string;
34
35
  '@atlaskit/design-system/ensure-design-token-usage': string;
35
36
  '@atlaskit/design-system/icon-label': string;
37
+ '@atlaskit/design-system/local-cx-xcss': string;
36
38
  '@atlaskit/design-system/no-banned-imports': string;
37
39
  '@atlaskit/design-system/no-deprecated-apis': string;
38
40
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::d1a459e1ea71650f65b2890dc86cc398>>
3
+ * @codegen <<SignedSource::5026ba2cb55b3c1bcacbfe7fb7728a6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  '@atlaskit/design-system/ensure-design-token-usage': string;
11
11
  '@atlaskit/design-system/ensure-design-token-usage/preview': string;
12
12
  '@atlaskit/design-system/icon-label': string;
13
+ '@atlaskit/design-system/local-cx-xcss': string;
13
14
  '@atlaskit/design-system/no-banned-imports': string;
14
15
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
15
16
  '@atlaskit/design-system/no-deprecated-apis': string;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::3b93cfbbe0ea14514b9600509632394b>>
3
+ * @codegen <<SignedSource::839224bfab98c1ddf6018dec5320968e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  '@atlaskit/design-system/consistent-css-prop-usage': string;
10
10
  '@atlaskit/design-system/ensure-design-token-usage': string;
11
11
  '@atlaskit/design-system/icon-label': string;
12
+ '@atlaskit/design-system/local-cx-xcss': string;
12
13
  '@atlaskit/design-system/no-banned-imports': string;
13
14
  '@atlaskit/design-system/no-deprecated-apis': string;
14
15
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
@@ -3,6 +3,7 @@ declare const _default: {
3
3
  'ensure-design-token-usage': import("eslint").Rule.RuleModule;
4
4
  'ensure-design-token-usage/preview': import("eslint").Rule.RuleModule;
5
5
  'icon-label': import("eslint").Rule.RuleModule;
6
+ 'local-cx-xcss': import("eslint").Rule.RuleModule;
6
7
  'no-banned-imports': import("eslint").Rule.RuleModule;
7
8
  'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
8
9
  'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, [{
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -1,6 +1,5 @@
1
- import type { Rule, Scope } from 'eslint';
2
- type Node = Rule.Node;
3
- type Reference = Scope.Reference;
1
+ import type { Rule } from 'eslint';
2
+ import { SupportedNameChecker } from '../../utils/is-supported-import';
4
3
  type RuleModule = Rule.RuleModule;
5
- export declare const createNoTaggedTemplateExpressionRule: (isUsage: (node: Node, references: Reference[]) => boolean, messageId: string) => RuleModule['create'];
4
+ export declare const createNoTaggedTemplateExpressionRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
6
5
  export {};
@@ -0,0 +1,16 @@
1
+ import type { 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
+ compiled: string;
7
+ emotionReact: string;
8
+ emotionCore: string;
9
+ styledComponents: string;
10
+ atlaskitCss: string;
11
+ };
12
+ type ValidImportSources = string[];
13
+ export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ValidImportSources) => boolean;
14
+ export declare const isCss: SupportedNameChecker;
15
+ export declare const isCxFunction: SupportedNameChecker;
16
+ export {};
@@ -2,4 +2,5 @@ export { FunctionCall } from './function-call';
2
2
  export { Import } from './import';
3
3
  export { JSXAttribute } from './jsx-attribute';
4
4
  export { JSXElement } from './jsx-element';
5
+ export { Object } from './object';
5
6
  export { Root } from './root';
@@ -0,0 +1,39 @@
1
+ import type { Rule } from 'eslint';
2
+ import { ObjectExpression, Property } from 'eslint-codemod-utils';
3
+ declare const ASTObjectExpression: {
4
+ /**
5
+ * Returns `true` if an object contains a property with the specified name, `false` otherwise.
6
+ */
7
+ hasProperty(node: ObjectExpression, name: string): boolean;
8
+ /**
9
+ * Returns a key-value pair like: `padding: '8px'` from: `{ padding: '8px' }`
10
+ */
11
+ getEntryByPropertyName(node: ObjectExpression, name: string): Property | undefined;
12
+ deleteEntry(node: ObjectExpression, name: string, fixer: Rule.RuleFixer): Rule.Fix[];
13
+ /**
14
+ * Returns a only the property @type {Property['key']} like: `padding` from: `{ padding: '8px' }`
15
+ */
16
+ getProperty(node: ObjectExpression, name: string): Property['key'] | undefined;
17
+ /**
18
+ * Returns a only the property @type {Property['value']} like: `'8px` from: `{ padding: '8px' }`
19
+ *
20
+ * Values can be basically anything, so be careful with this
21
+ */
22
+ getValueByPropertyName(node: ObjectExpression, name: string): Property['value'] | undefined;
23
+ containsSpreadProps(node: ObjectExpression): boolean;
24
+ updateValue(node: ObjectExpression, propertyName: string, newValue: string, fixer: Rule.RuleFixer): Rule.Fix;
25
+ /**
26
+ * Appends a key-value pair to the end of an object. For example:
27
+ * ```
28
+ * ast.Object.appendEntry(
29
+ * node, // { padding: 'space.100' }
30
+ * key, // 'margin',
31
+ * value, // 'space.200'
32
+ * fixer,
33
+ * )
34
+ * ```
35
+ * Will result in `{ padding: 'space.100', margin: 'space.200'}`
36
+ */
37
+ appendEntry(node: ObjectExpression, key: string, value: string, fixer: Rule.RuleFixer): Rule.Fix;
38
+ };
39
+ export { ASTObjectExpression as Object };
@@ -7,6 +7,7 @@ export declare const configs: {
7
7
  '@atlaskit/design-system/ensure-design-token-usage': string;
8
8
  '@atlaskit/design-system/ensure-design-token-usage/preview': string;
9
9
  '@atlaskit/design-system/icon-label': string;
10
+ '@atlaskit/design-system/local-cx-xcss': string;
10
11
  '@atlaskit/design-system/no-banned-imports': string;
11
12
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
12
13
  '@atlaskit/design-system/no-deprecated-apis': string;
@@ -33,6 +34,7 @@ export declare const configs: {
33
34
  '@atlaskit/design-system/consistent-css-prop-usage': string;
34
35
  '@atlaskit/design-system/ensure-design-token-usage': string;
35
36
  '@atlaskit/design-system/icon-label': string;
37
+ '@atlaskit/design-system/local-cx-xcss': string;
36
38
  '@atlaskit/design-system/no-banned-imports': string;
37
39
  '@atlaskit/design-system/no-deprecated-apis': string;
38
40
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::d1a459e1ea71650f65b2890dc86cc398>>
3
+ * @codegen <<SignedSource::5026ba2cb55b3c1bcacbfe7fb7728a6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -10,6 +10,7 @@ declare const _default: {
10
10
  '@atlaskit/design-system/ensure-design-token-usage': string;
11
11
  '@atlaskit/design-system/ensure-design-token-usage/preview': string;
12
12
  '@atlaskit/design-system/icon-label': string;
13
+ '@atlaskit/design-system/local-cx-xcss': string;
13
14
  '@atlaskit/design-system/no-banned-imports': string;
14
15
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
15
16
  '@atlaskit/design-system/no-deprecated-apis': string;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::3b93cfbbe0ea14514b9600509632394b>>
3
+ * @codegen <<SignedSource::839224bfab98c1ddf6018dec5320968e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -9,6 +9,7 @@ declare const _default: {
9
9
  '@atlaskit/design-system/consistent-css-prop-usage': string;
10
10
  '@atlaskit/design-system/ensure-design-token-usage': string;
11
11
  '@atlaskit/design-system/icon-label': string;
12
+ '@atlaskit/design-system/local-cx-xcss': string;
12
13
  '@atlaskit/design-system/no-banned-imports': string;
13
14
  '@atlaskit/design-system/no-deprecated-apis': string;
14
15
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
@@ -3,6 +3,7 @@ declare const _default: {
3
3
  'ensure-design-token-usage': import("eslint").Rule.RuleModule;
4
4
  'ensure-design-token-usage/preview': import("eslint").Rule.RuleModule;
5
5
  'icon-label': import("eslint").Rule.RuleModule;
6
+ 'local-cx-xcss': import("eslint").Rule.RuleModule;
6
7
  'no-banned-imports': import("eslint").Rule.RuleModule;
7
8
  'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
8
9
  'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<string, [
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -1,6 +1,5 @@
1
- import type { Rule, Scope } from 'eslint';
2
- type Node = Rule.Node;
3
- type Reference = Scope.Reference;
1
+ import type { Rule } from 'eslint';
2
+ import { SupportedNameChecker } from '../../utils/is-supported-import';
4
3
  type RuleModule = Rule.RuleModule;
5
- export declare const createNoTaggedTemplateExpressionRule: (isUsage: (node: Node, references: Reference[]) => boolean, messageId: string) => RuleModule['create'];
4
+ export declare const createNoTaggedTemplateExpressionRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
6
5
  export {};
@@ -0,0 +1,16 @@
1
+ import type { 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
+ compiled: string;
7
+ emotionReact: string;
8
+ emotionCore: string;
9
+ styledComponents: string;
10
+ atlaskitCss: string;
11
+ };
12
+ type ValidImportSources = string[];
13
+ export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ValidImportSources) => boolean;
14
+ export declare const isCss: SupportedNameChecker;
15
+ export declare const isCxFunction: SupportedNameChecker;
16
+ export {};
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": "8.23.3",
4
+ "version": "8.23.4",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"