@atlaskit/eslint-plugin-ui-styling-standard 0.5.2 → 0.6.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 (50) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +16 -14
  3. package/constellation/convert-props-syntax/usage.mdx +115 -0
  4. package/constellation/index/overview.mdx +16 -14
  5. package/constellation/no-classname-prop/usage.mdx +38 -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/convert-props-syntax/index.js +396 -0
  9. package/dist/cjs/rules/index.codegen.js +5 -1
  10. package/dist/cjs/rules/no-classname-prop/index.js +38 -0
  11. package/dist/cjs/rules/utils/is-supported-import.js +7 -0
  12. package/dist/es2019/presets/all.codegen.js +3 -1
  13. package/dist/es2019/presets/recommended.codegen.js +3 -1
  14. package/dist/es2019/rules/convert-props-syntax/index.js +291 -0
  15. package/dist/es2019/rules/index.codegen.js +5 -1
  16. package/dist/es2019/rules/no-classname-prop/index.js +32 -0
  17. package/dist/es2019/rules/utils/is-supported-import.js +7 -0
  18. package/dist/esm/presets/all.codegen.js +3 -1
  19. package/dist/esm/presets/recommended.codegen.js +3 -1
  20. package/dist/esm/rules/convert-props-syntax/index.js +389 -0
  21. package/dist/esm/rules/index.codegen.js +5 -1
  22. package/dist/esm/rules/no-classname-prop/index.js +32 -0
  23. package/dist/esm/rules/utils/is-supported-import.js +7 -0
  24. package/dist/types/index.codegen.d.ts +4 -0
  25. package/dist/types/presets/all.codegen.d.ts +3 -1
  26. package/dist/types/presets/recommended.codegen.d.ts +3 -1
  27. package/dist/types/rules/convert-props-syntax/index.d.ts +3 -0
  28. package/dist/types/rules/index.codegen.d.ts +2 -0
  29. package/dist/types/rules/no-classname-prop/index.d.ts +2 -0
  30. package/dist/types-ts4.5/index.codegen.d.ts +4 -0
  31. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
  32. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +3 -1
  33. package/dist/types-ts4.5/rules/convert-props-syntax/index.d.ts +3 -0
  34. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
  35. package/dist/types-ts4.5/rules/no-classname-prop/index.d.ts +2 -0
  36. package/package.json +6 -3
  37. package/src/presets/all.codegen.tsx +3 -1
  38. package/src/presets/recommended.codegen.tsx +3 -1
  39. package/src/rules/convert-props-syntax/README.md +113 -0
  40. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +76 -0
  41. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +422 -0
  42. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +140 -0
  43. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +69 -0
  44. package/src/rules/convert-props-syntax/index.tsx +414 -0
  45. package/src/rules/index.codegen.tsx +5 -1
  46. package/src/rules/no-classname-prop/README.md +36 -0
  47. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +39 -0
  48. package/src/rules/no-classname-prop/index.tsx +34 -0
  49. package/src/rules/utils/README.md +1 -0
  50. package/src/rules/utils/is-supported-import.tsx +7 -0
@@ -0,0 +1,389 @@
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 { analyze } from 'eslint-scope';
5
+ import { createLintRule } from '../utils/create-rule';
6
+ import { CSS_IN_JS_IMPORTS, isStyledComponents } from '../utils/is-supported-import';
7
+ import ESTraverse from 'estraverse';
8
+ var IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.styledComponents];
9
+
10
+ /**
11
+ * Represents some information about single line that contains some props, e.g.
12
+ * the arrow function in
13
+ *
14
+ * color: (props) => `mix(${props.myColor}, #fff)`
15
+ *
16
+ * or about a destructuring assignment, e.g. the arrow function in
17
+ *
18
+ * color: ({ myColor, otherColor }) => someFunction(myColor, otherColor)
19
+ *
20
+ * or something that we don't recognise, or that we don't think is valid
21
+ *
22
+ * color: (props, someOtherVariable) => someOtherVariable
23
+ */
24
+
25
+ var standardizePropExpression = function standardizePropExpression(sourceCode, expression) {
26
+ var propsObjectName = 'props';
27
+ if (expression.type === 'Identifier') {
28
+ return "".concat(propsObjectName, ".").concat(expression.name);
29
+ }
30
+ if (expression.type === 'MemberExpression' && expression.property.type === 'Identifier') {
31
+ var propertyName = sourceCode.getText(expression.property);
32
+ return "".concat(propsObjectName, ".").concat(propertyName);
33
+ }
34
+
35
+ // Cannot safely process the expression, bail out!
36
+ return undefined;
37
+ };
38
+ var parseArrowFunctionExpression = function parseArrowFunctionExpression(expression, sourceCode) {
39
+ if (expression.params.length !== 1) {
40
+ return {
41
+ valid: false
42
+ };
43
+ }
44
+ var scopeManager = analyze(expression, {});
45
+ var currentScope = scopeManager.acquire(expression);
46
+ if (!currentScope) {
47
+ return {
48
+ valid: false
49
+ };
50
+ }
51
+ var parameter = expression.params[0];
52
+ var props = [];
53
+
54
+ // Don't bother handling type annotations that appear in the parameters of arrow functions.
55
+ //
56
+ // This only applies if the ESLint rule is running under @typescript-eslint (not regular eslint), hence the roundabout way we use to check whether parameter.typeAnnotation exists or not.
57
+ if ('typeAnnotation' in parameter && parameter.typeAnnotation) {
58
+ return {
59
+ valid: false
60
+ };
61
+ }
62
+ if (parameter.type === 'ObjectPattern') {
63
+ if (parameter.properties.some(function (value) {
64
+ return value.type === 'RestElement';
65
+ })) {
66
+ return {
67
+ valid: false
68
+ };
69
+ }
70
+ var properties = parameter.properties;
71
+ var _iterator = _createForOfIteratorHelper(properties),
72
+ _step;
73
+ try {
74
+ var _loop = function _loop() {
75
+ var property = _step.value;
76
+ var propertyValue = property.value;
77
+ // Don't bother supporting other patterns like rest elements, default values...
78
+ if (propertyValue.type !== 'Identifier') {
79
+ return {
80
+ v: {
81
+ valid: false
82
+ }
83
+ };
84
+ }
85
+ var variable = currentScope.variables.find(function (varb) {
86
+ return varb.name === propertyValue.name;
87
+ });
88
+ if (!variable || !variable.references || !variable.references.length) {
89
+ // Something went wrong, best to just bail out.
90
+ return {
91
+ v: {
92
+ valid: false
93
+ }
94
+ };
95
+ }
96
+ var propName = standardizePropExpression(sourceCode, propertyValue);
97
+ if (!propName) {
98
+ return {
99
+ v: {
100
+ valid: false
101
+ }
102
+ };
103
+ }
104
+ props.push({
105
+ propName: propName,
106
+ usages: variable.references.map(function (reference) {
107
+ return reference.identifier;
108
+ })
109
+ });
110
+ },
111
+ _ret;
112
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
113
+ _ret = _loop();
114
+ if (_ret) return _ret.v;
115
+ }
116
+ } catch (err) {
117
+ _iterator.e(err);
118
+ } finally {
119
+ _iterator.f();
120
+ }
121
+ } else if (parameter.type === 'Identifier') {
122
+ var variable = currentScope.variables.find(function (varb) {
123
+ return varb.name === parameter.name;
124
+ });
125
+ if (!variable || !variable.references || !variable.references.length) {
126
+ // Something went wrong, best to just bail out.
127
+ return {
128
+ valid: false
129
+ };
130
+ }
131
+ var _iterator2 = _createForOfIteratorHelper(variable.references),
132
+ _step2;
133
+ try {
134
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
135
+ var reference = _step2.value;
136
+ var memberExpression = reference.identifier.parent;
137
+ if (memberExpression.type !== 'MemberExpression') {
138
+ // If reference.identifier.parent is not a member expression, that indicates
139
+ // that we have a usage of the props argument that does NOT look like
140
+ //
141
+ // (props) => props.color
142
+ //
143
+ // e.g. we might have (props) => props['...'] or (props) => `${props}px` perhaps...
144
+ //
145
+ // We have no choice but to bail out because the syntax is not what we expect.
146
+ return {
147
+ valid: false
148
+ };
149
+ }
150
+ var propName = standardizePropExpression(sourceCode, memberExpression);
151
+ if (!propName) {
152
+ return {
153
+ valid: false
154
+ };
155
+ }
156
+ props.push({
157
+ propName: propName,
158
+ usages: [memberExpression]
159
+ });
160
+ }
161
+ } catch (err) {
162
+ _iterator2.e(err);
163
+ } finally {
164
+ _iterator2.f();
165
+ }
166
+ } else {
167
+ // Bail out for any syntax we don't recognise.
168
+ return {
169
+ valid: false
170
+ };
171
+ }
172
+ return {
173
+ arrowFunctionExpression: expression,
174
+ props: props,
175
+ valid: true
176
+ };
177
+ };
178
+ var lintArguments = function lintArguments(context, args) {
179
+ var _iterator3 = _createForOfIteratorHelper(args),
180
+ _step3;
181
+ try {
182
+ var _loop2 = function _loop2() {
183
+ var argument = _step3.value;
184
+ if (argument.type === 'ArrowFunctionExpression') {
185
+ // styled.div((props) => ({ ... }))
186
+ // styled.div(({ color, height }) => ({ ... }))
187
+ //
188
+ // Already in the form we want.
189
+ return 0; // continue
190
+ } else if (argument.type === 'ObjectExpression') {
191
+ var allProps = [];
192
+
193
+ // vvvvvvv
194
+ // styled.div({ ... })
195
+ var _iterator4 = _createForOfIteratorHelper(argument.properties),
196
+ _step4;
197
+ try {
198
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
199
+ var property = _step4.value;
200
+ if (property.type === 'SpreadElement') {
201
+ // e.g.
202
+ // styled.div({ color: 'blue', ...someStyles })
203
+ //
204
+ // If we have a spread element, we can no longer safely
205
+ // transform this styled/css call without a lot more effort.
206
+ //
207
+ // Best to give up...
208
+ return {
209
+ v: void 0
210
+ };
211
+ } else {
212
+ ESTraverse.traverse(property.value, {
213
+ enter: function enter(node, _parent) {
214
+ if (node.type === 'ArrowFunctionExpression') {
215
+ var propNames = parseArrowFunctionExpression(node, context.getSourceCode());
216
+ if (!propNames) {
217
+ // We've encountered a CSS value we don't recognise, skip.
218
+ return;
219
+ }
220
+ allProps.push(propNames);
221
+ }
222
+ }
223
+ });
224
+ }
225
+ }
226
+ } catch (err) {
227
+ _iterator4.e(err);
228
+ } finally {
229
+ _iterator4.f();
230
+ }
231
+ if (!allProps.length) {
232
+ return 0; // continue
233
+ }
234
+ if (allProps.some(function (propUsage) {
235
+ return !propUsage.valid;
236
+ })) {
237
+ context.report({
238
+ node: argument,
239
+ messageId: 'unsupported-styled-components-prop-syntax-no-autofixer'
240
+ });
241
+ return {
242
+ v: void 0
243
+ };
244
+ }
245
+ context.report({
246
+ node: argument,
247
+ messageId: 'unsupported-styled-components-prop-syntax',
248
+ fix: function fix(fixer) {
249
+ var sourceCode = context.getSourceCode();
250
+ return fixPropsObjectUsages(fixer, sourceCode, argument,
251
+ // The
252
+ // allProps.some((propUsage) => !propUsage.valid)
253
+ // condition above should have made this type assertion unnecessary...
254
+ allProps);
255
+ }
256
+ });
257
+ }
258
+ },
259
+ _ret2;
260
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
261
+ _ret2 = _loop2();
262
+ if (_ret2 === 0) continue;
263
+ if (_ret2) return _ret2.v;
264
+ }
265
+ } catch (err) {
266
+ _iterator3.e(err);
267
+ } finally {
268
+ _iterator3.f();
269
+ }
270
+ };
271
+ var convertPropUsage = function convertPropUsage(propUsage, sourceCode) {
272
+ var arrowFunctionOffset = propUsage.arrowFunctionExpression.body.loc ? {
273
+ startIndex: sourceCode.getIndexFromLoc(propUsage.arrowFunctionExpression.body.loc.start),
274
+ endIndex: sourceCode.getIndexFromLoc(propUsage.arrowFunctionExpression.body.loc.end)
275
+ } : undefined;
276
+ if (!arrowFunctionOffset) {
277
+ return;
278
+ }
279
+ var sectionsToUpdate = [];
280
+ var newCode = [];
281
+ var _iterator5 = _createForOfIteratorHelper(propUsage.props),
282
+ _step5;
283
+ try {
284
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
285
+ var prop = _step5.value;
286
+ var _iterator6 = _createForOfIteratorHelper(prop.usages),
287
+ _step6;
288
+ try {
289
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
290
+ var usage = _step6.value;
291
+ if (!usage.loc) {
292
+ return;
293
+ }
294
+ sectionsToUpdate.push({
295
+ identifier: usage,
296
+ newCode: prop.propName,
297
+ startIndex: sourceCode.getIndexFromLoc(usage.loc.start),
298
+ endIndex: sourceCode.getIndexFromLoc(usage.loc.end)
299
+ });
300
+ }
301
+ } catch (err) {
302
+ _iterator6.e(err);
303
+ } finally {
304
+ _iterator6.f();
305
+ }
306
+ }
307
+ } catch (err) {
308
+ _iterator5.e(err);
309
+ } finally {
310
+ _iterator5.f();
311
+ }
312
+ sectionsToUpdate.sort(function (a, b) {
313
+ if (!a.identifier.loc || !b.identifier.loc) {
314
+ return 0;
315
+ }
316
+ return a.identifier.loc.start.line - b.identifier.loc.start.line || a.identifier.loc.start.column - b.identifier.loc.start.column;
317
+ });
318
+ var prevEndIndex = arrowFunctionOffset.startIndex;
319
+ for (var _i = 0, _sectionsToUpdate = sectionsToUpdate; _i < _sectionsToUpdate.length; _i++) {
320
+ var section = _sectionsToUpdate[_i];
321
+ if (prevEndIndex > section.startIndex || prevEndIndex >= section.endIndex) {
322
+ // Props overlap! This is unexpected, bail out.
323
+ return;
324
+ }
325
+ newCode.push(sourceCode.getText().slice(prevEndIndex, section.startIndex));
326
+ newCode.push(section.newCode);
327
+ prevEndIndex = section.endIndex;
328
+ }
329
+ newCode.push(sourceCode.getText().slice(prevEndIndex, arrowFunctionOffset.endIndex));
330
+ return newCode.join('');
331
+ };
332
+ var fixPropsObjectUsages = function fixPropsObjectUsages(fixer, sourceCode, expression, allProps) {
333
+ var fixers = [
334
+ // Wrap the object (containing the CSS properties and values) in an arrow function,
335
+ // so it becomes something like
336
+ //
337
+ // styled.div(
338
+ // (props) => ({
339
+ // color: ...
340
+ // })
341
+ // );
342
+ fixer.insertTextBefore(expression, '(props) => ('), fixer.insertTextAfter(expression, ')')];
343
+ var _iterator7 = _createForOfIteratorHelper(allProps),
344
+ _step7;
345
+ try {
346
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
347
+ var propUsage = _step7.value;
348
+ var arrowFunctionExpression = propUsage.arrowFunctionExpression;
349
+ var newCode = convertPropUsage(propUsage, sourceCode);
350
+ if (newCode) {
351
+ fixers.push(fixer.replaceText(arrowFunctionExpression, newCode));
352
+ }
353
+ }
354
+ } catch (err) {
355
+ _iterator7.e(err);
356
+ } finally {
357
+ _iterator7.f();
358
+ }
359
+ return fixers;
360
+ };
361
+ export var rule = createLintRule({
362
+ meta: {
363
+ name: 'convert-props-syntax',
364
+ docs: {
365
+ description: 'Convert props syntax that is unsupported by `styled-components` <4.x to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by `styled-components`.',
366
+ recommended: true,
367
+ severity: 'error'
368
+ },
369
+ fixable: 'code',
370
+ messages: {
371
+ 'unsupported-styled-components-prop-syntax': 'This syntax is not supported by styled-components <4.x and will fail at runtime!\n\nTo fix this, you can either migrate this to `@compiled/react`, or use the autofixer to switch the syntax from the `styled.div({ property: (props) => props.value })` syntax to the `styled.div(props => ({ property: props.value }))` syntax.',
372
+ 'unsupported-styled-components-prop-syntax-no-autofixer': 'This syntax is not supported by styled-components <4.x and will fail at runtime!\n\nTo fix this, you can either migrate this to `@compiled/react`, or manually migrate the syntax from the `styled.div({ property: (props) => props.value })` syntax to the `styled.div(props => ({ property: props.value }))` syntax.\n\nCheck out the rule documentation for examples.'
373
+ },
374
+ type: 'problem'
375
+ },
376
+ create: function create(context) {
377
+ return {
378
+ 'CallExpression[callee.type="MemberExpression"]': function CallExpressionCalleeTypeMemberExpression(node) {
379
+ var references = context.getScope().references;
380
+ var callee = node.callee.type === 'MemberExpression' ? node.callee.object : node.callee;
381
+ if (!isStyledComponents(callee, references, IMPORT_SOURCES)) {
382
+ return;
383
+ }
384
+ lintArguments(context, node.arguments);
385
+ }
386
+ };
387
+ }
388
+ });
389
+ export default rule;
@@ -1,11 +1,15 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::4e0d0cd3ebc010cebc70fb1564055574>>
3
+ * @codegen <<SignedSource::7c8793f6c12f32e915fd9b4dc7a6edef>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
+ import convertPropsSyntax from './convert-props-syntax';
6
7
  import localCxXcss from './local-cx-xcss';
8
+ import noClassnameProp from './no-classname-prop';
7
9
  import noImportantStyles from './no-important-styles';
8
10
  export default {
11
+ 'convert-props-syntax': convertPropsSyntax,
9
12
  'local-cx-xcss': localCxXcss,
13
+ 'no-classname-prop': noClassnameProp,
10
14
  'no-important-styles': noImportantStyles
11
15
  };
@@ -0,0 +1,32 @@
1
+ import { isNodeOfType } from 'eslint-codemod-utils';
2
+ import { createLintRule } from '../utils/create-rule';
3
+ export var rule = createLintRule({
4
+ meta: {
5
+ name: 'no-classname-prop',
6
+ docs: {
7
+ description: 'Disallows usage of the `className` prop in JSX',
8
+ recommended: true,
9
+ severity: 'warn'
10
+ },
11
+ messages: {
12
+ 'no-classname-prop': 'Avoid `className` because it invites the use of unsafe global styles and is impossible to determine via local tooling.'
13
+ },
14
+ type: 'problem'
15
+ },
16
+ create: function create(context) {
17
+ return {
18
+ JSXAttribute: function JSXAttribute(node) {
19
+ if (!isNodeOfType(node, 'JSXAttribute')) {
20
+ return;
21
+ }
22
+ if (node.name.name === 'className') {
23
+ context.report({
24
+ node: node,
25
+ messageId: 'no-classname-prop'
26
+ });
27
+ }
28
+ }
29
+ };
30
+ }
31
+ });
32
+ export default rule;
@@ -1,3 +1,10 @@
1
+ // This should be kept in sync with
2
+ // packages/design-system/eslint-plugin/src/rules/utils/is-supported-import.tsx
3
+ // whenever possible.
4
+ //
5
+ // TODO: would having an @atlassian/eslint-plugin-design-system-common
6
+ // package be useful?
7
+
1
8
  // eslint-disable-next-line import/no-extraneous-dependencies
2
9
 
3
10
  export var CSS_IN_JS_IMPORTS = {
@@ -3,7 +3,9 @@ export declare const configs: {
3
3
  all: {
4
4
  plugins: string[];
5
5
  rules: {
6
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
6
7
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
8
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
7
9
  '@atlaskit/ui-styling-standard/no-important-styles': string;
8
10
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
9
11
  excludeReactComponents: boolean;
@@ -32,7 +34,9 @@ export declare const configs: {
32
34
  recommended: {
33
35
  plugins: string[];
34
36
  rules: {
37
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
35
38
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
39
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
36
40
  '@atlaskit/ui-styling-standard/no-important-styles': string;
37
41
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
38
42
  excludeReactComponents: boolean;
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::c0973784c8a5047835032781219885ce>>
3
+ * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
7
7
  plugins: string[];
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
9
10
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
11
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
10
12
  '@atlaskit/ui-styling-standard/no-important-styles': string;
11
13
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
12
14
  excludeReactComponents: boolean;
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::c0973784c8a5047835032781219885ce>>
3
+ * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
7
7
  plugins: string[];
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
9
10
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
11
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
10
12
  '@atlaskit/ui-styling-standard/no-important-styles': string;
11
13
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
12
14
  excludeReactComponents: boolean;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -1,5 +1,7 @@
1
1
  declare const _default: {
2
+ 'convert-props-syntax': import("eslint").Rule.RuleModule;
2
3
  'local-cx-xcss': import("eslint").Rule.RuleModule;
4
+ 'no-classname-prop': import("eslint").Rule.RuleModule;
3
5
  'no-important-styles': import("eslint").Rule.RuleModule;
4
6
  };
5
7
  export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -3,7 +3,9 @@ export declare const configs: {
3
3
  all: {
4
4
  plugins: string[];
5
5
  rules: {
6
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
6
7
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
8
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
7
9
  '@atlaskit/ui-styling-standard/no-important-styles': string;
8
10
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
9
11
  excludeReactComponents: boolean;
@@ -32,7 +34,9 @@ export declare const configs: {
32
34
  recommended: {
33
35
  plugins: string[];
34
36
  rules: {
37
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
35
38
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
39
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
36
40
  '@atlaskit/ui-styling-standard/no-important-styles': string;
37
41
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
38
42
  excludeReactComponents: boolean;
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::c0973784c8a5047835032781219885ce>>
3
+ * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
7
7
  plugins: string[];
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
9
10
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
11
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
10
12
  '@atlaskit/ui-styling-standard/no-important-styles': string;
11
13
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
12
14
  excludeReactComponents: boolean;
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::c0973784c8a5047835032781219885ce>>
3
+ * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  declare const _default: {
7
7
  plugins: string[];
8
8
  rules: {
9
+ '@atlaskit/ui-styling-standard/convert-props-syntax': string;
9
10
  '@atlaskit/ui-styling-standard/local-cx-xcss': string;
11
+ '@atlaskit/ui-styling-standard/no-classname-prop': string;
10
12
  '@atlaskit/ui-styling-standard/no-important-styles': string;
11
13
  '@atlaskit/design-system/consistent-css-prop-usage': (string | {
12
14
  excludeReactComponents: boolean;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ export declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -1,5 +1,7 @@
1
1
  declare const _default: {
2
+ 'convert-props-syntax': import("eslint").Rule.RuleModule;
2
3
  'local-cx-xcss': import("eslint").Rule.RuleModule;
4
+ 'no-classname-prop': import("eslint").Rule.RuleModule;
3
5
  'no-important-styles': import("eslint").Rule.RuleModule;
4
6
  };
5
7
  export default _default;
@@ -0,0 +1,2 @@
1
+ export declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-ui-styling-standard",
3
- "version": "0.5.2",
3
+ "version": "0.6.1",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
6
6
  "license": "Apache-2.0",
@@ -38,6 +38,8 @@
38
38
  "dependencies": {
39
39
  "@babel/runtime": "^7.0.0",
40
40
  "@typescript-eslint/utils": "^5.48.1",
41
+ "eslint-codemod-utils": "^1.8.6",
42
+ "eslint-scope": "^8.0.0",
41
43
  "estraverse": "^5.3.0"
42
44
  },
43
45
  "devDependencies": {
@@ -45,13 +47,14 @@
45
47
  "@atlaskit/eslint-plugin-design-system": "^8.37.0",
46
48
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
47
49
  "@atlassian/codegen": "*",
48
- "@compiled/eslint-plugin": "^0.13.3",
50
+ "@compiled/eslint-plugin": "^0.13.6",
49
51
  "@types/eslint": "^8.4.5",
50
52
  "@types/estraverse": "^5.1.7",
51
53
  "eslint": "^8.49.0",
52
54
  "lodash": "^4.17.21",
53
55
  "outdent": "^0.5.0",
54
56
  "prettier": "^2.8.0",
57
+ "ts-node": "^10.9.1",
55
58
  "tsconfig-paths": "^4.2.0",
56
59
  "typescript": "~4.9.5"
57
60
  },
@@ -59,4 +62,4 @@
59
62
  "codegen": "ts-node -r tsconfig-paths/register ./scripts/codegen.tsx"
60
63
  },
61
64
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
62
- }
65
+ }
@@ -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::c0973784c8a5047835032781219885ce>>
3
+ * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
@@ -10,7 +10,9 @@ export default {
10
10
  '@compiled',
11
11
  ],
12
12
  rules: {
13
+ '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
13
14
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
15
+ '@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
14
16
  '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
15
17
  '@atlaskit/design-system/consistent-css-prop-usage': [
16
18
  'warn',
@@ -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::c0973784c8a5047835032781219885ce>>
3
+ * @codegen <<SignedSource::c4a9648d888d86d752ea2b3442d395ba>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
5
5
  */
6
6
  export default {
@@ -10,7 +10,9 @@ export default {
10
10
  '@compiled',
11
11
  ],
12
12
  rules: {
13
+ '@atlaskit/ui-styling-standard/convert-props-syntax': 'error',
13
14
  '@atlaskit/ui-styling-standard/local-cx-xcss': 'warn',
15
+ '@atlaskit/ui-styling-standard/no-classname-prop': 'warn',
14
16
  '@atlaskit/ui-styling-standard/no-important-styles': 'warn',
15
17
  '@atlaskit/design-system/consistent-css-prop-usage': [
16
18
  'warn',