@atlaskit/eslint-plugin-ui-styling-standard 0.3.0 → 0.4.1

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 (80) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +18 -5
  3. package/build/tsconfig.json +2 -4
  4. package/constellation/consistent-css-prop-usage/usage.mdx +5 -0
  5. package/constellation/index/overview.mdx +29 -11
  6. package/constellation/local-cx-xcss/usage.mdx +37 -0
  7. package/constellation/no-css-tagged-template-expression/usage.mdx +5 -0
  8. package/constellation/no-empty-styled-expression/usage.mdx +5 -0
  9. package/constellation/no-exported-css/usage.mdx +5 -0
  10. package/constellation/no-exported-keyframes/usage.mdx +5 -0
  11. package/constellation/no-invalid-css-map/usage.mdx +5 -0
  12. package/constellation/no-js-xcss/usage.mdx +5 -0
  13. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +5 -0
  14. package/constellation/no-styled-tagged-template-expression/usage.mdx +5 -0
  15. package/constellation/no-suppress-xcss/usage.mdx +25 -0
  16. package/dist/cjs/index.codegen.js +26 -0
  17. package/dist/cjs/index.js +12 -33
  18. package/dist/cjs/presets/all.codegen.js +39 -0
  19. package/dist/cjs/presets/recommended.codegen.js +39 -0
  20. package/dist/cjs/rules/external-rules.js +169 -0
  21. package/dist/cjs/rules/index.codegen.js +16 -0
  22. package/dist/cjs/rules/local-cx-xcss/index.js +51 -0
  23. package/dist/cjs/rules/utils/create-rule.js +43 -0
  24. package/dist/cjs/rules/utils/is-supported-import.js +98 -0
  25. package/dist/es2019/index.codegen.js +12 -0
  26. package/dist/es2019/index.js +1 -33
  27. package/dist/es2019/presets/all.codegen.js +33 -0
  28. package/dist/es2019/presets/recommended.codegen.js +33 -0
  29. package/dist/es2019/rules/external-rules.js +164 -0
  30. package/dist/es2019/rules/index.codegen.js +9 -0
  31. package/dist/es2019/rules/local-cx-xcss/index.js +45 -0
  32. package/dist/es2019/rules/utils/create-rule.js +33 -0
  33. package/dist/es2019/rules/utils/is-supported-import.js +87 -0
  34. package/dist/esm/index.codegen.js +12 -0
  35. package/dist/esm/index.js +1 -33
  36. package/dist/esm/presets/all.codegen.js +33 -0
  37. package/dist/esm/presets/recommended.codegen.js +33 -0
  38. package/dist/esm/rules/external-rules.js +164 -0
  39. package/dist/esm/rules/index.codegen.js +9 -0
  40. package/dist/esm/rules/local-cx-xcss/index.js +45 -0
  41. package/dist/esm/rules/utils/create-rule.js +35 -0
  42. package/dist/esm/rules/utils/is-supported-import.js +90 -0
  43. package/dist/types/index.codegen.d.ts +59 -0
  44. package/dist/types/index.d.ts +1 -0
  45. package/dist/types/presets/all.codegen.d.ts +34 -0
  46. package/dist/types/presets/recommended.codegen.d.ts +34 -0
  47. package/dist/types/rules/external-rules.d.ts +11 -0
  48. package/dist/types/rules/index.codegen.d.ts +4 -0
  49. package/dist/types/rules/local-cx-xcss/index.d.ts +3 -0
  50. package/dist/types/rules/utils/create-rule.d.ts +64 -0
  51. package/dist/types/rules/utils/is-supported-import.d.ts +34 -0
  52. package/dist/types-ts4.5/index.codegen.d.ts +59 -0
  53. package/dist/types-ts4.5/index.d.ts +1 -0
  54. package/dist/types-ts4.5/presets/all.codegen.d.ts +34 -0
  55. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +34 -0
  56. package/dist/types-ts4.5/rules/external-rules.d.ts +11 -0
  57. package/dist/types-ts4.5/rules/index.codegen.d.ts +4 -0
  58. package/dist/types-ts4.5/rules/local-cx-xcss/index.d.ts +3 -0
  59. package/dist/types-ts4.5/rules/utils/create-rule.d.ts +64 -0
  60. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +34 -0
  61. package/package.json +13 -4
  62. package/scripts/codegen.tsx +439 -0
  63. package/src/index.codegen.tsx +14 -0
  64. package/src/index.tsx +1 -51
  65. package/src/presets/all.codegen.tsx +78 -0
  66. package/src/presets/recommended.codegen.tsx +78 -0
  67. package/src/rules/TEMPLATE.md +29 -0
  68. package/src/rules/__tests__/utils/_tester.tsx +40 -0
  69. package/src/rules/external-rules.tsx +205 -0
  70. package/src/rules/index.codegen.tsx +10 -0
  71. package/src/rules/local-cx-xcss/README.md +35 -0
  72. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +102 -0
  73. package/src/rules/local-cx-xcss/index.tsx +69 -0
  74. package/src/rules/utils/create-rule.tsx +80 -0
  75. package/src/rules/utils/is-supported-import.tsx +130 -0
  76. package/tsconfig.app.json +5 -1
  77. package/tsconfig.dev.json +5 -1
  78. package/tsconfig.json +7 -6
  79. package/dist/types/src/index.d.ts +0 -29
  80. package/dist/types-ts4.5/src/index.d.ts +0 -29
package/dist/esm/index.js CHANGED
@@ -1,33 +1 @@
1
- export var rules = {};
2
- var importSources = ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/styled', 'styled-components'];
3
- export var configs = {
4
- recommended: {
5
- plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
6
- rules: {
7
- '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
8
- // When passing a css prop to a React component, we don't know whether the component
9
- // is Emotion or Compiled. Hence it is not safe to run autofixes like wrapping it in
10
- // a `css` function call.
11
- excludeReactComponents: true
12
- }],
13
- '@atlaskit/design-system/local-cx-xcss': 'warn',
14
- '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
15
- '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
16
- '@atlaskit/design-system/no-styled-tagged-template-expression': 'warn',
17
- '@compiled/no-suppress-xcss': 'error',
18
- '@compiled/no-js-xcss': 'error',
19
- '@atlaskit/design-system/no-empty-styled-expression': ['warn', {
20
- importSources: importSources
21
- }],
22
- '@atlaskit/design-system/no-exported-css': ['warn', {
23
- importSources: importSources
24
- }],
25
- '@atlaskit/design-system/no-exported-keyframes': ['warn', {
26
- importSources: importSources
27
- }],
28
- '@atlaskit/design-system/no-invalid-css-map': ['warn', {
29
- allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
30
- }]
31
- }
32
- }
33
- };
1
+ export { configs, rules } from './index.codegen';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
+ * @codegen <<SignedSource::9869b1757ca915f74b471fe04f72e5ea>>
4
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
+ */
6
+ export default {
7
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
+ rules: {
9
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
10
+ '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
11
+ excludeReactComponents: true
12
+ }],
13
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
14
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
15
+ '@atlaskit/design-system/no-styled-tagged-template-expression': ['warn', {
16
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
17
+ }],
18
+ '@compiled/no-suppress-xcss': 'warn',
19
+ '@compiled/no-js-xcss': 'warn',
20
+ '@atlaskit/design-system/no-empty-styled-expression': ['warn', {
21
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
22
+ }],
23
+ '@atlaskit/design-system/no-exported-css': ['warn', {
24
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
25
+ }],
26
+ '@atlaskit/design-system/no-exported-keyframes': ['warn', {
27
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
28
+ }],
29
+ '@atlaskit/design-system/no-invalid-css-map': ['warn', {
30
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
31
+ }]
32
+ }
33
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
+ * @codegen <<SignedSource::9869b1757ca915f74b471fe04f72e5ea>>
4
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
+ */
6
+ export default {
7
+ plugins: ['@atlaskit/ui-styling-standard', '@atlaskit/design-system', '@compiled'],
8
+ rules: {
9
+ '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
10
+ '@atlaskit/design-system/consistent-css-prop-usage': ['warn', {
11
+ excludeReactComponents: true
12
+ }],
13
+ '@atlaskit/design-system/no-css-tagged-template-expression': 'warn',
14
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'warn',
15
+ '@atlaskit/design-system/no-styled-tagged-template-expression': ['warn', {
16
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled']
17
+ }],
18
+ '@compiled/no-suppress-xcss': 'warn',
19
+ '@compiled/no-js-xcss': 'warn',
20
+ '@atlaskit/design-system/no-empty-styled-expression': ['warn', {
21
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
22
+ }],
23
+ '@atlaskit/design-system/no-exported-css': ['warn', {
24
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
25
+ }],
26
+ '@atlaskit/design-system/no-exported-keyframes': ['warn', {
27
+ importSources: ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components']
28
+ }],
29
+ '@atlaskit/design-system/no-invalid-css-map': ['warn', {
30
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
31
+ }]
32
+ }
33
+ };
@@ -0,0 +1,164 @@
1
+ import { getRuleUrl } from './utils/create-rule';
2
+
3
+ /** External rules must be scoped, have a display name, and external urls. */
4
+
5
+ var importSources = ['@compiled/react', '@atlaskit/css', '@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components'];
6
+
7
+ /**
8
+ * Same as importSources, but excludes `styled-components` because the type-checking
9
+ * for `styled-components` does not support the `no-styled-tagged-template-expression`
10
+ * lint output for this:
11
+ *
12
+ * export const Container = styled(Section)`
13
+ * max-height: ${gridSize * 46}px;
14
+ * overflow: auto;
15
+ * `;
16
+ *
17
+ * export const ErrorStateContainer = styled(Container)`
18
+ * margin: ${
19
+ * (props: any) =>
20
+ * props.canManageAutomations // Use negative margin to reduce whitespace when the Footer component is shown
21
+ * ? `${gridSize * -4}px ${gridSize * 2}px`
22
+ * : `0 ${gridSize * 2}px`
23
+ * };
24
+ * `;
25
+ */
26
+ var noStyledTaggedTemplateExpressionImportSources = ['@compiled/react', '@atlaskit/css',
27
+ // doesn't do anything because @atlaskit/css doesn't expose a styled API
28
+ '@emotion/core', '@emotion/react', '@emotion/styled'];
29
+ export var externalRules = [{
30
+ name: '@atlaskit/design-system/consistent-css-prop-usage',
31
+ displayName: 'consistent-css-prop-usage',
32
+ isExternal: true,
33
+ fixable: 'code',
34
+ docs: {
35
+ description: 'Ensures consistency with `css` and `xcss` prop usages',
36
+ url: getRuleUrl('consistent-css-prop-usage'),
37
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/consistent-css-prop-usage/usage',
38
+ recommended: true,
39
+ severity: 'warn',
40
+ pluginConfig: {
41
+ // When passing a css prop to a React component, we don't know whether the component
42
+ // is Emotion or Compiled. Hence it is not safe to run autofixes like wrapping it in
43
+ // a `css` function call.
44
+ excludeReactComponents: true
45
+ }
46
+ }
47
+ }, {
48
+ name: '@atlaskit/design-system/no-css-tagged-template-expression',
49
+ displayName: 'no-css-tagged-template-expression',
50
+ isExternal: true,
51
+ fixable: 'code',
52
+ docs: {
53
+ description: 'Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled',
54
+ url: getRuleUrl('no-css-tagged-template-expression'),
55
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage',
56
+ recommended: true,
57
+ severity: 'warn'
58
+ }
59
+ }, {
60
+ name: '@atlaskit/design-system/no-keyframes-tagged-template-expression',
61
+ displayName: 'no-keyframes-tagged-template-expression',
62
+ isExternal: true,
63
+ fixable: 'code',
64
+ docs: {
65
+ description: 'Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled',
66
+ url: getRuleUrl('no-keyframes-tagged-template-expression'),
67
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage',
68
+ recommended: true,
69
+ severity: 'warn'
70
+ }
71
+ }, {
72
+ name: '@atlaskit/design-system/no-styled-tagged-template-expression',
73
+ displayName: 'no-styled-tagged-template-expression',
74
+ isExternal: true,
75
+ fixable: 'code',
76
+ docs: {
77
+ description: 'Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled',
78
+ url: getRuleUrl('no-styled-tagged-template-expression'),
79
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage',
80
+ recommended: true,
81
+ severity: 'warn',
82
+ pluginConfig: {
83
+ importSources: noStyledTaggedTemplateExpressionImportSources
84
+ }
85
+ }
86
+ }, {
87
+ name: '@compiled/no-suppress-xcss',
88
+ displayName: 'no-suppress-xcss',
89
+ isExternal: true,
90
+ docs: {
91
+ description: 'Disallows supressing type violations when using the xcss prop.',
92
+ url: getRuleUrl('no-suppress-xcss'),
93
+ externalUrl: 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-suppress-xcss',
94
+ recommended: true,
95
+ severity: 'warn'
96
+ }
97
+ }, {
98
+ name: '@compiled/no-js-xcss',
99
+ displayName: 'no-js-xcss',
100
+ isExternal: true,
101
+ docs: {
102
+ description: 'Disallows using xcss prop inside JavaScript files.',
103
+ url: getRuleUrl('no-js-xcss'),
104
+ externalUrl: 'https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss',
105
+ recommended: true,
106
+ severity: 'warn'
107
+ }
108
+ }, {
109
+ name: '@atlaskit/design-system/no-empty-styled-expression',
110
+ displayName: 'no-empty-styled-expression',
111
+ isExternal: true,
112
+ docs: {
113
+ description: 'Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements).',
114
+ url: getRuleUrl('no-empty-styled-expression'),
115
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage',
116
+ recommended: true,
117
+ severity: 'warn',
118
+ pluginConfig: {
119
+ importSources: importSources
120
+ }
121
+ }
122
+ }, {
123
+ name: '@atlaskit/design-system/no-exported-css',
124
+ displayName: 'no-exported-css',
125
+ isExternal: true,
126
+ docs: {
127
+ description: 'Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.',
128
+ url: getRuleUrl('no-exported-css'),
129
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage',
130
+ recommended: true,
131
+ severity: 'warn',
132
+ pluginConfig: {
133
+ importSources: importSources
134
+ }
135
+ }
136
+ }, {
137
+ name: '@atlaskit/design-system/no-exported-keyframes',
138
+ displayName: 'no-exported-keyframes',
139
+ isExternal: true,
140
+ docs: {
141
+ description: 'Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.',
142
+ url: getRuleUrl('no-exported-keyframes'),
143
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage',
144
+ recommended: true,
145
+ severity: 'warn',
146
+ pluginConfig: {
147
+ importSources: importSources
148
+ }
149
+ }
150
+ }, {
151
+ name: '@atlaskit/design-system/no-invalid-css-map',
152
+ displayName: 'no-invalid-css-map',
153
+ isExternal: true,
154
+ docs: {
155
+ description: "Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking.",
156
+ url: getRuleUrl('no-invalid-css-map'),
157
+ externalUrl: 'https://atlassian.design/components/eslint-plugin-design-system/no-invalid-css-map/usage',
158
+ recommended: true,
159
+ severity: 'warn',
160
+ pluginConfig: {
161
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
162
+ }
163
+ }
164
+ }];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
+ * @codegen <<SignedSource::f907e3f7ab0b7145dcb8318732ae1fec>>
4
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
+ */
6
+ import localCxXcss from './local-cx-xcss';
7
+ export default {
8
+ 'local-cx-xcss': localCxXcss
9
+ };
@@ -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: 'warn'
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;
@@ -0,0 +1,35 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
+
4
+ /**
5
+ * We are moving to our own small abstraction to create a lint rule that we have the power
6
+ * to change and mold to our own needs.
7
+ *
8
+ * @see createLintRule
9
+ *
10
+ * @private
11
+ * @deprecated
12
+ */
13
+ export var createRule = ESLintUtils.RuleCreator(function (name) {
14
+ return getRuleUrl(name);
15
+ });
16
+ /**
17
+ * Tiny wrapped over the ESLint rule module type that ensures
18
+ * there is a docs link to our ESLint plugin documentation page,
19
+ * as well as improving type support.
20
+ */
21
+ export var createLintRule = function createLintRule(rule) {
22
+ rule.meta.docs.url = getRuleUrl(rule.meta.name);
23
+ return rule;
24
+ };
25
+ export function getRuleUrl(ruleName) {
26
+ var name = getPathSafeName(ruleName);
27
+ return "https://atlassian.design/components/eslint-plugin-ui-styling-standard/".concat(name, "/usage");
28
+ }
29
+
30
+ /**
31
+ * If it's a nested rule, ensure the url is clean and safe for urls, file paths, etc.
32
+ */
33
+ export function getPathSafeName(ruleName) {
34
+ return ruleName.replace('/', '-');
35
+ }
@@ -0,0 +1,90 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
+
4
+ export var CSS_IN_JS_IMPORTS = {
5
+ compiled: '@compiled/react',
6
+ emotionReact: '@emotion/react',
7
+ emotionCore: '@emotion/core',
8
+ styledComponents: 'styled-components',
9
+ atlaskitCss: '@atlaskit/css',
10
+ atlaskitPrimitives: '@atlaskit/primitives'
11
+ };
12
+
13
+ // A CSS-in-JS library an import of a valid css, cx, cssMap, etc.
14
+ // function might originate from, e.g. @compiled/react, @emotion/core.
15
+ // All ESLint rules originating from `@compiled/eslint-plugin` should apply to these libraries.
16
+ export var DEFAULT_IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.atlaskitCss];
17
+
18
+ /**
19
+ * Given the ESLint rule context, extract and parse the value of the importSources rule option.
20
+ * The importSources option is used to define additional libraries for which an ESLint rule
21
+ * should apply to.
22
+ *
23
+ * Note that `@compiled/react` and `@atlaskit/css` are always included in importSources, regardless
24
+ * of what importSources is configured to by the user.
25
+ *
26
+ * @param context The rule context.
27
+ * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
28
+ * on the rule options configuration.
29
+ */
30
+ export var getImportSources = function getImportSources(context) {
31
+ var options = context.options;
32
+ if (!options.length) {
33
+ return DEFAULT_IMPORT_SOURCES;
34
+ }
35
+ if (options[0].importSources && Array.isArray(options[0].importSources)) {
36
+ return [].concat(DEFAULT_IMPORT_SOURCES, _toConsumableArray(options[0].importSources));
37
+ }
38
+ return DEFAULT_IMPORT_SOURCES;
39
+ };
40
+ var isSupportedImportWrapper = function isSupportedImportWrapper(functionName) {
41
+ var checkDefinitionHasImport = function checkDefinitionHasImport(def, importSources) {
42
+ if (def.type !== 'ImportBinding') {
43
+ return false;
44
+ }
45
+ if (!def.parent || !importSources.includes(def.parent.source.value)) {
46
+ return false;
47
+ }
48
+ return (
49
+ // import { functionName } from 'import-source';
50
+ def.node.type === 'ImportSpecifier' && def.node.imported.name === functionName ||
51
+ // import functionName from 'import-source';
52
+ def.node.type === 'ImportDefaultSpecifier' && def.node.local.name === functionName
53
+ );
54
+ };
55
+
56
+ /**
57
+ * Checks whether:
58
+ *
59
+ * 1. A function name `nodeToCheck` matches the name of the function we
60
+ * want to check for (e.g. `cx`, `css`, `cssMap`, or `keyframes`), and
61
+ * 2. Whether `nodeToCheck` originates from one of the libraries listed
62
+ * in `importSources`.
63
+ *
64
+ * @param nodeToCheck The function callee we are checking (e.g. The `css` in `css()`).
65
+ * @param referencesInScope List of references that are in scope. We'll use this
66
+ * to check where the function callee is imported from.
67
+ * @param importSources List of libraries that we want to ensure `nodeToCheck`
68
+ * comes from.
69
+ *
70
+ * @returns Whether the above conditions are true.
71
+ */
72
+ var isSupportedImport = function isSupportedImport(nodeToCheck, referencesInScope, importSources) {
73
+ return nodeToCheck.type === 'Identifier' && referencesInScope.some(function (reference) {
74
+ var _reference$resolved;
75
+ return reference.identifier === nodeToCheck && ((_reference$resolved = reference.resolved) === null || _reference$resolved === void 0 ? void 0 : _reference$resolved.defs.some(function (def) {
76
+ return checkDefinitionHasImport(def, importSources);
77
+ }));
78
+ });
79
+ };
80
+ return isSupportedImport;
81
+ };
82
+
83
+ // Unused functions have been commented out until we implement corresponding
84
+ // eslint rules which use them
85
+ //
86
+ export var isCss = isSupportedImportWrapper('css');
87
+ export var isCxFunction = isSupportedImportWrapper('cx');
88
+ export var isCssMap = isSupportedImportWrapper('cssMap');
89
+ export var isKeyframes = isSupportedImportWrapper('keyframes');
90
+ export var isStyled = isSupportedImportWrapper('styled');
@@ -0,0 +1,59 @@
1
+ export { default as rules } from './rules/index.codegen';
2
+ export declare const configs: {
3
+ all: {
4
+ plugins: string[];
5
+ rules: {
6
+ '@atlaskit/ui-styling-standard/local-cx-xcss': string;
7
+ '@atlaskit/design-system/consistent-css-prop-usage': (string | {
8
+ excludeReactComponents: boolean;
9
+ })[];
10
+ '@atlaskit/design-system/no-css-tagged-template-expression': string;
11
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
12
+ '@atlaskit/design-system/no-styled-tagged-template-expression': (string | {
13
+ importSources: string[];
14
+ })[];
15
+ '@compiled/no-suppress-xcss': string;
16
+ '@compiled/no-js-xcss': string;
17
+ '@atlaskit/design-system/no-empty-styled-expression': (string | {
18
+ importSources: string[];
19
+ })[];
20
+ '@atlaskit/design-system/no-exported-css': (string | {
21
+ importSources: string[];
22
+ })[];
23
+ '@atlaskit/design-system/no-exported-keyframes': (string | {
24
+ importSources: string[];
25
+ })[];
26
+ '@atlaskit/design-system/no-invalid-css-map': (string | {
27
+ allowedFunctionCalls: string[][];
28
+ })[];
29
+ };
30
+ };
31
+ recommended: {
32
+ plugins: string[];
33
+ rules: {
34
+ '@atlaskit/ui-styling-standard/local-cx-xcss': string;
35
+ '@atlaskit/design-system/consistent-css-prop-usage': (string | {
36
+ excludeReactComponents: boolean;
37
+ })[];
38
+ '@atlaskit/design-system/no-css-tagged-template-expression': string;
39
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
40
+ '@atlaskit/design-system/no-styled-tagged-template-expression': (string | {
41
+ importSources: string[];
42
+ })[];
43
+ '@compiled/no-suppress-xcss': string;
44
+ '@compiled/no-js-xcss': string;
45
+ '@atlaskit/design-system/no-empty-styled-expression': (string | {
46
+ importSources: string[];
47
+ })[];
48
+ '@atlaskit/design-system/no-exported-css': (string | {
49
+ importSources: string[];
50
+ })[];
51
+ '@atlaskit/design-system/no-exported-keyframes': (string | {
52
+ importSources: string[];
53
+ })[];
54
+ '@atlaskit/design-system/no-invalid-css-map': (string | {
55
+ allowedFunctionCalls: string[][];
56
+ })[];
57
+ };
58
+ };
59
+ };
@@ -0,0 +1 @@
1
+ export { configs, rules } from './index.codegen';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
+ * @codegen <<SignedSource::9869b1757ca915f74b471fe04f72e5ea>>
4
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
+ */
6
+ declare const _default: {
7
+ plugins: string[];
8
+ rules: {
9
+ '@atlaskit/ui-styling-standard/local-cx-xcss': string;
10
+ '@atlaskit/design-system/consistent-css-prop-usage': (string | {
11
+ excludeReactComponents: boolean;
12
+ })[];
13
+ '@atlaskit/design-system/no-css-tagged-template-expression': string;
14
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
15
+ '@atlaskit/design-system/no-styled-tagged-template-expression': (string | {
16
+ importSources: string[];
17
+ })[];
18
+ '@compiled/no-suppress-xcss': string;
19
+ '@compiled/no-js-xcss': string;
20
+ '@atlaskit/design-system/no-empty-styled-expression': (string | {
21
+ importSources: string[];
22
+ })[];
23
+ '@atlaskit/design-system/no-exported-css': (string | {
24
+ importSources: string[];
25
+ })[];
26
+ '@atlaskit/design-system/no-exported-keyframes': (string | {
27
+ importSources: string[];
28
+ })[];
29
+ '@atlaskit/design-system/no-invalid-css-map': (string | {
30
+ allowedFunctionCalls: string[][];
31
+ })[];
32
+ };
33
+ };
34
+ export default _default;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
+ * @codegen <<SignedSource::9869b1757ca915f74b471fe04f72e5ea>>
4
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
+ */
6
+ declare const _default: {
7
+ plugins: string[];
8
+ rules: {
9
+ '@atlaskit/ui-styling-standard/local-cx-xcss': string;
10
+ '@atlaskit/design-system/consistent-css-prop-usage': (string | {
11
+ excludeReactComponents: boolean;
12
+ })[];
13
+ '@atlaskit/design-system/no-css-tagged-template-expression': string;
14
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
15
+ '@atlaskit/design-system/no-styled-tagged-template-expression': (string | {
16
+ importSources: string[];
17
+ })[];
18
+ '@compiled/no-suppress-xcss': string;
19
+ '@compiled/no-js-xcss': string;
20
+ '@atlaskit/design-system/no-empty-styled-expression': (string | {
21
+ importSources: string[];
22
+ })[];
23
+ '@atlaskit/design-system/no-exported-css': (string | {
24
+ importSources: string[];
25
+ })[];
26
+ '@atlaskit/design-system/no-exported-keyframes': (string | {
27
+ importSources: string[];
28
+ })[];
29
+ '@atlaskit/design-system/no-invalid-css-map': (string | {
30
+ allowedFunctionCalls: string[][];
31
+ })[];
32
+ };
33
+ };
34
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { type LintRuleMeta } from './utils/create-rule';
2
+ /** External rules must be scoped, have a display name, and external urls. */
3
+ export type ExternalRuleMeta = LintRuleMeta & {
4
+ isExternal: true;
5
+ name: `@${string}/${string}`;
6
+ displayName: string;
7
+ docs: {
8
+ externalUrl: `https://${string}`;
9
+ };
10
+ };
11
+ export declare const externalRules: ExternalRuleMeta[];
@@ -0,0 +1,4 @@
1
+ declare const _default: {
2
+ 'local-cx-xcss': import("eslint").Rule.RuleModule;
3
+ };
4
+ export default _default;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;