@atlaskit/eslint-plugin-ui-styling-standard 0.11.6 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +2 -0
  3. package/constellation/index/overview.mdx +3 -1
  4. package/constellation/no-global-styles/usage.mdx +59 -0
  5. package/constellation/use-compiled/usage.mdx +54 -0
  6. package/dist/cjs/presets/all.codegen.js +3 -1
  7. package/dist/cjs/presets/recommended.codegen.js +3 -1
  8. package/dist/cjs/rules/index.codegen.js +6 -2
  9. package/dist/cjs/rules/no-global-styles/index.js +100 -0
  10. package/dist/cjs/rules/use-compiled/index.js +257 -0
  11. package/dist/cjs/rules/use-compiled/is-safe.js +130 -0
  12. package/dist/cjs/rules/use-compiled/utils.js +26 -0
  13. package/dist/es2019/presets/all.codegen.js +3 -1
  14. package/dist/es2019/presets/recommended.codegen.js +3 -1
  15. package/dist/es2019/rules/index.codegen.js +6 -2
  16. package/dist/es2019/rules/no-global-styles/index.js +67 -0
  17. package/dist/es2019/rules/use-compiled/index.js +182 -0
  18. package/dist/es2019/rules/use-compiled/is-safe.js +118 -0
  19. package/dist/es2019/rules/use-compiled/utils.js +15 -0
  20. package/dist/esm/presets/all.codegen.js +3 -1
  21. package/dist/esm/presets/recommended.codegen.js +3 -1
  22. package/dist/esm/rules/index.codegen.js +6 -2
  23. package/dist/esm/rules/no-global-styles/index.js +94 -0
  24. package/dist/esm/rules/use-compiled/index.js +250 -0
  25. package/dist/esm/rules/use-compiled/is-safe.js +121 -0
  26. package/dist/esm/rules/use-compiled/utils.js +17 -0
  27. package/dist/types/index.codegen.d.ts +4 -0
  28. package/dist/types/presets/all.codegen.d.ts +3 -1
  29. package/dist/types/presets/recommended.codegen.d.ts +3 -1
  30. package/dist/types/rules/index.codegen.d.ts +2 -0
  31. package/dist/types/rules/no-global-styles/index.d.ts +2 -0
  32. package/dist/types/rules/use-compiled/index.d.ts +3 -0
  33. package/dist/types/rules/use-compiled/is-safe.d.ts +10 -0
  34. package/dist/types/rules/use-compiled/utils.d.ts +6 -0
  35. package/dist/types-ts4.5/index.codegen.d.ts +4 -0
  36. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
  37. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +3 -1
  38. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
  39. package/dist/types-ts4.5/rules/no-global-styles/index.d.ts +2 -0
  40. package/dist/types-ts4.5/rules/use-compiled/index.d.ts +3 -0
  41. package/dist/types-ts4.5/rules/use-compiled/is-safe.d.ts +10 -0
  42. package/dist/types-ts4.5/rules/use-compiled/utils.d.ts +6 -0
  43. package/package.json +3 -2
  44. package/src/presets/all.codegen.tsx +3 -1
  45. package/src/presets/recommended.codegen.tsx +3 -1
  46. package/src/rules/index.codegen.tsx +5 -1
  47. package/src/rules/no-global-styles/README.md +56 -0
  48. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +33 -0
  49. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +46 -0
  50. package/src/rules/no-global-styles/index.tsx +85 -0
  51. package/src/rules/use-compiled/README.md +49 -0
  52. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +73 -0
  53. package/src/rules/use-compiled/__tests__/css.test.tsx +126 -0
  54. package/src/rules/use-compiled/__tests__/imports.test.tsx +163 -0
  55. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +140 -0
  56. package/src/rules/use-compiled/__tests__/pragma.test.tsx +108 -0
  57. package/src/rules/use-compiled/__tests__/styled.test.tsx +114 -0
  58. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +15 -0
  59. package/src/rules/use-compiled/index.tsx +275 -0
  60. package/src/rules/use-compiled/is-safe.tsx +163 -0
  61. package/src/rules/use-compiled/utils.tsx +37 -0
@@ -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::78ffc29d20fd2fe3727a620cb4ddf192>>
3
+ * @codegen <<SignedSource::3cea683df6e31f816db56abf1fd65c1e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  import atlaskitTheme from './atlaskit-theme';
@@ -12,10 +12,12 @@ import noClassnameProp from './no-classname-prop';
12
12
  import noContainerQueries from './no-container-queries';
13
13
  import noDynamicStyles from './no-dynamic-styles';
14
14
  import noExportedStyles from './no-exported-styles';
15
+ import noGlobalStyles from './no-global-styles';
15
16
  import noImportantStyles from './no-important-styles';
16
17
  import noImportedStyleValues from './no-imported-style-values';
17
18
  import noNestedSelectors from './no-nested-selectors';
18
19
  import noUnsafeValues from './no-unsafe-values';
20
+ import useCompiled from './use-compiled';
19
21
  export default {
20
22
  'atlaskit-theme': atlaskitTheme,
21
23
  'convert-props-syntax': convertPropsSyntax,
@@ -26,8 +28,10 @@ export default {
26
28
  'no-container-queries': noContainerQueries,
27
29
  'no-dynamic-styles': noDynamicStyles,
28
30
  'no-exported-styles': noExportedStyles,
31
+ 'no-global-styles': noGlobalStyles,
29
32
  'no-important-styles': noImportantStyles,
30
33
  'no-imported-style-values': noImportedStyleValues,
31
34
  'no-nested-selectors': noNestedSelectors,
32
- 'no-unsafe-values': noUnsafeValues
35
+ 'no-unsafe-values': noUnsafeValues,
36
+ 'use-compiled': useCompiled
33
37
  };
@@ -0,0 +1,94 @@
1
+ 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; } } }; }
2
+ 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); }
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
+ import { createLintRule } from '../utils/create-rule';
5
+ var restrictedFileTypes = ['.css', '.less', '.sass', '.scss'];
6
+ var restrictedImports = {
7
+ '@emotion/core': ['Global'],
8
+ '@emotion/react': ['Global'],
9
+ 'styled-components': ['createGlobalStyle', 'injectGlobal']
10
+ };
11
+ function isRestrictedImportSource(importSource) {
12
+ return importSource in restrictedImports;
13
+ }
14
+ export var rule = createLintRule({
15
+ meta: {
16
+ name: 'no-global-styles',
17
+ docs: {
18
+ description: 'Prevents global styles through CSS-in-JS or CSS module imports',
19
+ recommended: true,
20
+ severity: 'warn'
21
+ },
22
+ messages: {
23
+ 'no-global-styles': 'Global styles are not allowed.',
24
+ 'no-css-modules': 'Importing CSS files is not allowed.'
25
+ },
26
+ type: 'problem'
27
+ },
28
+ create: function create(context) {
29
+ function checkFileType(node) {
30
+ var importSource = node.source.value;
31
+ if (restrictedFileTypes.some(function (suffix) {
32
+ return importSource.endsWith(suffix);
33
+ })) {
34
+ context.report({
35
+ node: node.source,
36
+ messageId: 'no-css-modules'
37
+ });
38
+ }
39
+ }
40
+ function checkImports(node) {
41
+ var importSource = node.source.value;
42
+ if (!isRestrictedImportSource(importSource)) {
43
+ return;
44
+ }
45
+ var _iterator = _createForOfIteratorHelper(restrictedImports[importSource]),
46
+ _step;
47
+ try {
48
+ var _loop = function _loop() {
49
+ var importName = _step.value;
50
+ var specifier = node.specifiers.filter(isImportSpecifier).find(function (specifier) {
51
+ return specifier.imported.name === importName;
52
+ });
53
+ if (specifier) {
54
+ context.report({
55
+ node: specifier,
56
+ messageId: 'no-global-styles'
57
+ });
58
+ }
59
+ };
60
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
61
+ _loop();
62
+ }
63
+ } catch (err) {
64
+ _iterator.e(err);
65
+ } finally {
66
+ _iterator.f();
67
+ }
68
+ }
69
+ return {
70
+ ImportDeclaration: function (_ImportDeclaration) {
71
+ function ImportDeclaration(_x) {
72
+ return _ImportDeclaration.apply(this, arguments);
73
+ }
74
+ ImportDeclaration.toString = function () {
75
+ return _ImportDeclaration.toString();
76
+ };
77
+ return ImportDeclaration;
78
+ }(function (node) {
79
+ checkFileType(node);
80
+ checkImports(node);
81
+ }),
82
+ 'JSXOpeningElement[name.name="style"]': function JSXOpeningElementNameNameStyle(node) {
83
+ context.report({
84
+ node: node,
85
+ messageId: 'no-global-styles'
86
+ });
87
+ }
88
+ };
89
+ }
90
+ });
91
+ export default rule;
92
+ function isImportSpecifier(node) {
93
+ return node.type === 'ImportSpecifier';
94
+ }
@@ -0,0 +1,250 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ import { identifier, importDeclaration, importSpecifier, literal } from 'eslint-codemod-utils';
5
+ import { findVariable } from '@atlaskit/eslint-utils/find-variable';
6
+ import { createLintRule } from '../utils/create-rule';
7
+ import { getFirstImportFromSource, isImportDefaultSpecifier, isImportNamespaceSpecifier, isImportSpecifier } from './utils';
8
+ import { isSafeStyled, isSafeUsage } from './is-safe';
9
+ var SUPPORTED_EMOTION_IMPORTS = new Set(['css', 'keyframes', 'ClassNames', 'jsx']);
10
+ var SUPPORTED_IMPORT_MAP = {
11
+ '@emotion/core': SUPPORTED_EMOTION_IMPORTS,
12
+ '@emotion/react': SUPPORTED_EMOTION_IMPORTS,
13
+ '@emotion/styled': new Set(['default']),
14
+ 'styled-components': new Set(['default', 'css', 'keyframes'])
15
+ };
16
+ function isSupportedImportSource(importSource) {
17
+ return importSource in SUPPORTED_IMPORT_MAP;
18
+ }
19
+ var schema = {
20
+ type: 'array',
21
+ items: [{
22
+ type: 'object',
23
+ properties: {
24
+ canAutoFix: {
25
+ type: 'boolean'
26
+ }
27
+ },
28
+ additionalProperties: false
29
+ }]
30
+ };
31
+ var defaultConfig = {
32
+ canAutoFix: false
33
+ };
34
+ function readConfig(context) {
35
+ var _ref = context.options,
36
+ _ref2 = _slicedToArray(_ref, 1),
37
+ config = _ref2[0];
38
+ return Object.assign({}, defaultConfig, config);
39
+ }
40
+ export var rule = createLintRule({
41
+ meta: {
42
+ name: 'use-compiled',
43
+ type: 'problem',
44
+ fixable: 'code',
45
+ docs: {
46
+ description: 'Ensures usage of `@compiled/react` instead of other CSS-in-JS libraries',
47
+ recommended: true,
48
+ severity: 'warn'
49
+ },
50
+ messages: {
51
+ 'use-compiled': "Use '@compiled/react' instead of '{{importSource}}'"
52
+ },
53
+ schema: schema
54
+ },
55
+ create: function create(context) {
56
+ var config = readConfig(context);
57
+ return {
58
+ Program: function Program() {
59
+ var pragma = context.getSourceCode().getAllComments().find(function (n) {
60
+ return n.value.includes('@jsxImportSource @emotion/react');
61
+ });
62
+ if (!pragma) {
63
+ return;
64
+ }
65
+ context.report({
66
+ messageId: 'use-compiled',
67
+ data: {
68
+ importSource: '@emotion/react'
69
+ },
70
+ loc: pragma.loc,
71
+ fix: /*#__PURE__*/_regeneratorRuntime.mark(function fix(fixer) {
72
+ var importDeclarations, hasEmotionImport, hasCompiledImport;
73
+ return _regeneratorRuntime.wrap(function fix$(_context) {
74
+ while (1) switch (_context.prev = _context.next) {
75
+ case 0:
76
+ if (config.canAutoFix) {
77
+ _context.next = 2;
78
+ break;
79
+ }
80
+ return _context.abrupt("return");
81
+ case 2:
82
+ importDeclarations = context.getSourceCode().ast.body.filter(function (node) {
83
+ return node.type === 'ImportDeclaration';
84
+ });
85
+ hasEmotionImport = importDeclarations.some(function (importDeclaration) {
86
+ var importSource = importDeclaration.source.value;
87
+ return importSource.startsWith('@emotion/');
88
+ });
89
+ hasCompiledImport = importDeclarations.some(function (importDeclaration) {
90
+ return importDeclaration.source.value === '@compiled/react';
91
+ });
92
+ if (!(hasEmotionImport || !hasCompiledImport)) {
93
+ _context.next = 7;
94
+ break;
95
+ }
96
+ return _context.abrupt("return");
97
+ case 7:
98
+ _context.next = 9;
99
+ return fixer.replaceText(
100
+ // @ts-expect-error - types don't accept comment nodes
101
+ pragma, "/** @jsxImportSource @compiled/react */");
102
+ case 9:
103
+ case "end":
104
+ return _context.stop();
105
+ }
106
+ }, fix);
107
+ })
108
+ });
109
+ },
110
+ ImportDeclaration: function (_ImportDeclaration) {
111
+ function ImportDeclaration(_x) {
112
+ return _ImportDeclaration.apply(this, arguments);
113
+ }
114
+ ImportDeclaration.toString = function () {
115
+ return _ImportDeclaration.toString();
116
+ };
117
+ return ImportDeclaration;
118
+ }(function (node) {
119
+ var importSource = node.source.value;
120
+ if (!isSupportedImportSource(importSource)) {
121
+ return;
122
+ }
123
+ context.report({
124
+ node: node.source,
125
+ messageId: 'use-compiled',
126
+ data: {
127
+ importSource: importSource
128
+ },
129
+ fix: /*#__PURE__*/_regeneratorRuntime.mark(function fix(fixer) {
130
+ var specifiers;
131
+ return _regeneratorRuntime.wrap(function fix$(_context2) {
132
+ while (1) switch (_context2.prev = _context2.next) {
133
+ case 0:
134
+ if (config.canAutoFix) {
135
+ _context2.next = 2;
136
+ break;
137
+ }
138
+ return _context2.abrupt("return");
139
+ case 2:
140
+ specifiers = getSpecifiers({
141
+ context: context,
142
+ node: node,
143
+ importSource: importSource
144
+ });
145
+ if (specifiers) {
146
+ _context2.next = 5;
147
+ break;
148
+ }
149
+ return _context2.abrupt("return");
150
+ case 5:
151
+ return _context2.delegateYield(fixImport({
152
+ context: context,
153
+ fixer: fixer,
154
+ node: node,
155
+ specifiers: specifiers
156
+ }), "t0", 6);
157
+ case 6:
158
+ case "end":
159
+ return _context2.stop();
160
+ }
161
+ }, fix);
162
+ })
163
+ });
164
+ })
165
+ };
166
+ }
167
+ });
168
+ export default rule;
169
+ function getSpecifiers(_ref3) {
170
+ var context = _ref3.context,
171
+ node = _ref3.node,
172
+ importSource = _ref3.importSource;
173
+ var supportedImports = SUPPORTED_IMPORT_MAP[importSource];
174
+
175
+ // We aren't supporting namespace imports
176
+ if (node.specifiers.some(isImportNamespaceSpecifier)) {
177
+ return;
178
+ }
179
+ var defaultSpecifier = node.specifiers.find(isImportDefaultSpecifier);
180
+ if (defaultSpecifier) {
181
+ if (!supportedImports.has('default')) {
182
+ return;
183
+ }
184
+ var styled = findVariable({
185
+ identifier: defaultSpecifier.local,
186
+ sourceCode: context.getSourceCode()
187
+ });
188
+ if (!styled || !isSafeStyled(styled)) {
189
+ return;
190
+ }
191
+ }
192
+ var namedSpecifiers = node.specifiers.filter(isImportSpecifier);
193
+ if (!namedSpecifiers.every(function (specifier) {
194
+ return isSafeUsage({
195
+ context: context,
196
+ specifier: specifier,
197
+ supportedImports: supportedImports
198
+ });
199
+ })) {
200
+ return;
201
+ }
202
+ if (defaultSpecifier) {
203
+ return [].concat(_toConsumableArray(namedSpecifiers), [
204
+ // ASSUMPTION: the default import, if allowed, is for `styled`
205
+ importSpecifier({
206
+ imported: identifier('styled'),
207
+ local: node.specifiers[0].local
208
+ })]);
209
+ }
210
+ return namedSpecifiers;
211
+ }
212
+ function fixImport(_ref4) {
213
+ var context = _ref4.context,
214
+ fixer = _ref4.fixer,
215
+ node = _ref4.node,
216
+ specifiers = _ref4.specifiers;
217
+ return /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
218
+ var compiledImport;
219
+ return _regeneratorRuntime.wrap(function _callee$(_context3) {
220
+ while (1) switch (_context3.prev = _context3.next) {
221
+ case 0:
222
+ compiledImport = getFirstImportFromSource(context, '@compiled/react');
223
+ if (!compiledImport) {
224
+ _context3.next = 8;
225
+ break;
226
+ }
227
+ _context3.next = 4;
228
+ return fixer.remove(node);
229
+ case 4:
230
+ _context3.next = 6;
231
+ return fixer.replaceText(compiledImport, buildImportDeclaration(compiledImport.specifiers.concat(specifiers), '@compiled/react'));
232
+ case 6:
233
+ _context3.next = 10;
234
+ break;
235
+ case 8:
236
+ _context3.next = 10;
237
+ return fixer.replaceText(node, buildImportDeclaration(specifiers, '@compiled/react'));
238
+ case 10:
239
+ case "end":
240
+ return _context3.stop();
241
+ }
242
+ }, _callee);
243
+ })();
244
+ }
245
+ function buildImportDeclaration(specifiers, source) {
246
+ return "".concat(importDeclaration({
247
+ specifiers: specifiers,
248
+ source: literal(source)
249
+ }), ";");
250
+ }
@@ -0,0 +1,121 @@
1
+ import { closestOfType } from 'eslint-codemod-utils';
2
+ import { findVariable } from '@atlaskit/eslint-utils/find-variable';
3
+ export function isSafeUsage(_ref) {
4
+ var context = _ref.context,
5
+ specifier = _ref.specifier,
6
+ supportedImports = _ref.supportedImports;
7
+ var importName = specifier.imported.name;
8
+ if (!supportedImports.has(importName)) {
9
+ return false;
10
+ }
11
+ if (importName === 'css') {
12
+ var css = findVariable({
13
+ identifier: specifier.local,
14
+ sourceCode: context.getSourceCode()
15
+ });
16
+ return css !== null && isSafeCss(css);
17
+ }
18
+ if (importName === 'keyframes') {
19
+ var keyframes = findVariable({
20
+ identifier: specifier.local,
21
+ sourceCode: context.getSourceCode()
22
+ });
23
+ return keyframes !== null && isSafeKeyframes(keyframes);
24
+ }
25
+ return true;
26
+ }
27
+ export function isSafeKeyframes(keyframes) {
28
+ return keyframes.references.every(function (ref) {
29
+ var callExpression = closestOfType(ref.identifier, 'CallExpression');
30
+ if (!callExpression) {
31
+ return false;
32
+ }
33
+ if (callExpression.callee !== ref.identifier) {
34
+ return false;
35
+ }
36
+ if (callExpression.arguments.length !== 1) {
37
+ return false;
38
+ }
39
+ var argument = callExpression.arguments[0];
40
+ if (argument.type !== 'ObjectExpression') {
41
+ return false;
42
+ }
43
+ return argument.properties.every(function (property) {
44
+ return isSafeProperty(property, isSafeKeyframePropertyValue);
45
+ });
46
+ });
47
+ }
48
+ function isSafeKeyframePropertyValue(value) {
49
+ if (value.type !== 'ObjectExpression') {
50
+ return false;
51
+ }
52
+ return isSafeStyleObject(value);
53
+ }
54
+ export function isSafeCss(css) {
55
+ return css.references.every(function (ref) {
56
+ var callExpression = closestOfType(ref.identifier, 'CallExpression');
57
+ if (!callExpression) {
58
+ return false;
59
+ }
60
+ if (callExpression.callee !== ref.identifier) {
61
+ return false;
62
+ }
63
+ return callExpression.arguments.every(isSafeStyleArgument);
64
+ });
65
+ }
66
+ export function isSafeStyled(styled) {
67
+ return styled.references.every(function (ref) {
68
+ var callExpression = closestOfType(ref.identifier, 'CallExpression');
69
+ if (!callExpression) {
70
+ return false;
71
+ }
72
+
73
+ /**
74
+ * If it's not in the form `styled.tagName()`
75
+ * then we consider it unsafe to auto-fix.
76
+ */
77
+ if (callExpression.callee.type !== 'MemberExpression' || callExpression.callee.object !== ref.identifier) {
78
+ return false;
79
+ }
80
+ return callExpression.arguments.every(isSafeStyleArgument);
81
+ });
82
+ }
83
+
84
+ /**
85
+ * Determines if a style argument is safe for auto-fix conversion.
86
+ */
87
+ function isSafeStyleArgument(arg) {
88
+ if (arg.type === 'ObjectExpression') {
89
+ return isSafeStyleObject(arg);
90
+ }
91
+ return false;
92
+ }
93
+ function isSafeStyleObject(object) {
94
+ return object.properties.every(function (property) {
95
+ return isSafeProperty(property, isSafeStyleValue);
96
+ });
97
+ }
98
+ function isSafeStyleValue(value) {
99
+ if (value.type === 'Literal') {
100
+ return true;
101
+ }
102
+ return false;
103
+ }
104
+ function isSafeProperty(property, isSafePropertyValue) {
105
+ if (property.type === 'SpreadElement') {
106
+ return false;
107
+ }
108
+ if (property.method || property.shorthand || property.kind !== 'init') {
109
+ return false;
110
+ }
111
+ if (!hasSafeKey(property)) {
112
+ return false;
113
+ }
114
+ return isSafePropertyValue(property.value);
115
+ }
116
+ function hasSafeKey(property) {
117
+ if (property.computed) {
118
+ return property.key.type === 'Literal';
119
+ }
120
+ return true;
121
+ }
@@ -0,0 +1,17 @@
1
+ export function getFirstImportFromSource(context, source) {
2
+ return context.getSourceCode().ast.body.filter(isImportDeclaration).find(function (node) {
3
+ return node.source.value === source;
4
+ });
5
+ }
6
+ function isImportDeclaration(node) {
7
+ return node.type === 'ImportDeclaration';
8
+ }
9
+ export function isImportSpecifier(specifier) {
10
+ return specifier.type === 'ImportSpecifier';
11
+ }
12
+ export function isImportDefaultSpecifier(specifier) {
13
+ return specifier.type === 'ImportDefaultSpecifier';
14
+ }
15
+ export function isImportNamespaceSpecifier(specifier) {
16
+ return specifier.type === 'ImportNamespaceSpecifier';
17
+ }
@@ -12,10 +12,12 @@ export declare const configs: {
12
12
  '@atlaskit/ui-styling-standard/no-container-queries': string;
13
13
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
14
14
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
15
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
15
16
  '@atlaskit/ui-styling-standard/no-important-styles': string;
16
17
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
17
18
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
18
19
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
20
+ '@atlaskit/ui-styling-standard/use-compiled': string;
19
21
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
20
22
  excludeReactComponents: boolean;
21
23
  })[];
@@ -50,10 +52,12 @@ export declare const configs: {
50
52
  '@atlaskit/ui-styling-standard/no-container-queries': string;
51
53
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
52
54
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
55
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
53
56
  '@atlaskit/ui-styling-standard/no-important-styles': string;
54
57
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
55
58
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
56
59
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
60
+ '@atlaskit/ui-styling-standard/use-compiled': string;
57
61
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
58
62
  excludeReactComponents: boolean;
59
63
  })[];
@@ -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::a0c326baf3aa4e87ac809b303ba34682>>
3
+ * @codegen <<SignedSource::9ac05c3cbd30f6209164b7a24f7a7a19>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,10 +15,12 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-container-queries': string;
16
16
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
18
19
  '@atlaskit/ui-styling-standard/no-important-styles': string;
19
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
20
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
21
22
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
23
+ '@atlaskit/ui-styling-standard/use-compiled': string;
22
24
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
23
25
  excludeReactComponents: boolean;
24
26
  })[];
@@ -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::a0c326baf3aa4e87ac809b303ba34682>>
3
+ * @codegen <<SignedSource::9ac05c3cbd30f6209164b7a24f7a7a19>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,10 +15,12 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-container-queries': string;
16
16
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
18
19
  '@atlaskit/ui-styling-standard/no-important-styles': string;
19
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
20
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
21
22
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
23
+ '@atlaskit/ui-styling-standard/use-compiled': string;
22
24
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
23
25
  excludeReactComponents: boolean;
24
26
  })[];
@@ -8,9 +8,11 @@ declare const _default: {
8
8
  'no-container-queries': import("eslint").Rule.RuleModule;
9
9
  'no-dynamic-styles': import("eslint").Rule.RuleModule;
10
10
  'no-exported-styles': import("eslint").Rule.RuleModule;
11
+ 'no-global-styles': import("eslint").Rule.RuleModule;
11
12
  'no-important-styles': import("eslint").Rule.RuleModule;
12
13
  'no-imported-style-values': import("eslint").Rule.RuleModule;
13
14
  'no-nested-selectors': import("eslint").Rule.RuleModule;
14
15
  'no-unsafe-values': import("eslint").Rule.RuleModule;
16
+ 'use-compiled': import("eslint").Rule.RuleModule;
15
17
  };
16
18
  export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,10 @@
1
+ import type { Rule, Scope } from 'eslint';
2
+ import type * as ESTree from 'eslint-codemod-utils';
3
+ export declare function isSafeUsage({ context, specifier, supportedImports, }: {
4
+ context: Rule.RuleContext;
5
+ specifier: ESTree.ImportSpecifier;
6
+ supportedImports: Set<string>;
7
+ }): boolean;
8
+ export declare function isSafeKeyframes(keyframes: Scope.Variable): boolean;
9
+ export declare function isSafeCss(css: Scope.Variable): boolean;
10
+ export declare function isSafeStyled(styled: Scope.Variable): boolean;
@@ -0,0 +1,6 @@
1
+ import type { Rule } from 'eslint';
2
+ import type * as ESTree from 'eslint-codemod-utils';
3
+ export declare function getFirstImportFromSource(context: Rule.RuleContext, source: string): ESTree.ImportDeclaration | undefined;
4
+ export declare function isImportSpecifier(specifier: ESTree.Node): specifier is ESTree.ImportSpecifier;
5
+ export declare function isImportDefaultSpecifier(specifier: ESTree.Node): specifier is ESTree.ImportDefaultSpecifier;
6
+ export declare function isImportNamespaceSpecifier(specifier: ESTree.Node): specifier is ESTree.ImportNamespaceSpecifier;
@@ -12,10 +12,12 @@ export declare const configs: {
12
12
  '@atlaskit/ui-styling-standard/no-container-queries': string;
13
13
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
14
14
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
15
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
15
16
  '@atlaskit/ui-styling-standard/no-important-styles': string;
16
17
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
17
18
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
18
19
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
20
+ '@atlaskit/ui-styling-standard/use-compiled': string;
19
21
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
20
22
  excludeReactComponents: boolean;
21
23
  })[];
@@ -50,10 +52,12 @@ export declare const configs: {
50
52
  '@atlaskit/ui-styling-standard/no-container-queries': string;
51
53
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
52
54
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
55
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
53
56
  '@atlaskit/ui-styling-standard/no-important-styles': string;
54
57
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
55
58
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
56
59
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
60
+ '@atlaskit/ui-styling-standard/use-compiled': string;
57
61
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
58
62
  excludeReactComponents: boolean;
59
63
  })[];
@@ -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::a0c326baf3aa4e87ac809b303ba34682>>
3
+ * @codegen <<SignedSource::9ac05c3cbd30f6209164b7a24f7a7a19>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
@@ -15,10 +15,12 @@ declare const _default: {
15
15
  '@atlaskit/ui-styling-standard/no-container-queries': string;
16
16
  '@atlaskit/ui-styling-standard/no-dynamic-styles': string;
17
17
  '@atlaskit/ui-styling-standard/no-exported-styles': string;
18
+ '@atlaskit/ui-styling-standard/no-global-styles': string;
18
19
  '@atlaskit/ui-styling-standard/no-important-styles': string;
19
20
  '@atlaskit/ui-styling-standard/no-imported-style-values': string;
20
21
  '@atlaskit/ui-styling-standard/no-nested-selectors': string;
21
22
  '@atlaskit/ui-styling-standard/no-unsafe-values': string;
23
+ '@atlaskit/ui-styling-standard/use-compiled': string;
22
24
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
23
25
  excludeReactComponents: boolean;
24
26
  })[];