@atlaskit/eslint-plugin-design-system 10.12.5 → 10.14.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 (69) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +3 -3
  3. package/dist/cjs/presets/all.codegen.js +4 -5
  4. package/dist/cjs/presets/recommended.codegen.js +4 -5
  5. package/dist/cjs/rules/no-empty-styled-expression/index.js +1 -2
  6. package/dist/cjs/rules/no-exported-css/index.js +1 -2
  7. package/dist/cjs/rules/no-exported-keyframes/index.js +1 -2
  8. package/dist/cjs/rules/no-invalid-css-map/index.js +4 -1
  9. package/dist/cjs/rules/no-legacy-icons/helpers.js +3 -3
  10. package/dist/cjs/rules/use-heading/config/index.js +2 -1
  11. package/dist/cjs/rules/use-heading/transformers/native-elements.js +61 -31
  12. package/dist/cjs/rules/use-primitives-text/config/index.js +2 -1
  13. package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +48 -26
  14. package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +62 -51
  15. package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +56 -32
  16. package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +48 -26
  17. package/dist/es2019/presets/all.codegen.js +4 -5
  18. package/dist/es2019/presets/recommended.codegen.js +4 -5
  19. package/dist/es2019/rules/no-empty-styled-expression/index.js +1 -2
  20. package/dist/es2019/rules/no-exported-css/index.js +1 -2
  21. package/dist/es2019/rules/no-exported-keyframes/index.js +1 -2
  22. package/dist/es2019/rules/no-invalid-css-map/index.js +4 -1
  23. package/dist/es2019/rules/no-legacy-icons/helpers.js +3 -3
  24. package/dist/es2019/rules/use-heading/config/index.js +2 -1
  25. package/dist/es2019/rules/use-heading/transformers/native-elements.js +60 -29
  26. package/dist/es2019/rules/use-primitives-text/config/index.js +2 -1
  27. package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +47 -24
  28. package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +63 -52
  29. package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +55 -30
  30. package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +47 -24
  31. package/dist/esm/presets/all.codegen.js +4 -5
  32. package/dist/esm/presets/recommended.codegen.js +4 -5
  33. package/dist/esm/rules/no-empty-styled-expression/index.js +1 -2
  34. package/dist/esm/rules/no-exported-css/index.js +1 -2
  35. package/dist/esm/rules/no-exported-keyframes/index.js +1 -2
  36. package/dist/esm/rules/no-invalid-css-map/index.js +4 -1
  37. package/dist/esm/rules/no-legacy-icons/helpers.js +3 -3
  38. package/dist/esm/rules/use-heading/config/index.js +2 -1
  39. package/dist/esm/rules/use-heading/transformers/native-elements.js +61 -31
  40. package/dist/esm/rules/use-primitives-text/config/index.js +2 -1
  41. package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +48 -26
  42. package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +62 -51
  43. package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +56 -32
  44. package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +48 -26
  45. package/dist/types/index.codegen.d.ts +6 -8
  46. package/dist/types/presets/all.codegen.d.ts +4 -5
  47. package/dist/types/presets/recommended.codegen.d.ts +4 -5
  48. package/dist/types/rules/ensure-design-token-usage/rule-meta.d.ts +43 -2
  49. package/dist/types/rules/no-legacy-icons/helpers.d.ts +13 -1
  50. package/dist/types/rules/use-heading/config/index.d.ts +2 -1
  51. package/dist/types/rules/use-heading/transformers/native-elements.d.ts +5 -1
  52. package/dist/types/rules/use-primitives-text/config/index.d.ts +1 -0
  53. package/dist/types/rules/use-primitives-text/transformers/emphasis-elements.d.ts +6 -1
  54. package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -0
  55. package/dist/types/rules/use-primitives-text/transformers/span-elements.d.ts +6 -1
  56. package/dist/types/rules/use-primitives-text/transformers/strong-elements.d.ts +6 -1
  57. package/dist/types-ts4.5/index.codegen.d.ts +6 -8
  58. package/dist/types-ts4.5/presets/all.codegen.d.ts +4 -5
  59. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +4 -5
  60. package/dist/types-ts4.5/rules/ensure-design-token-usage/rule-meta.d.ts +43 -2
  61. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +13 -1
  62. package/dist/types-ts4.5/rules/use-heading/config/index.d.ts +2 -1
  63. package/dist/types-ts4.5/rules/use-heading/transformers/native-elements.d.ts +5 -1
  64. package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +1 -0
  65. package/dist/types-ts4.5/rules/use-primitives-text/transformers/emphasis-elements.d.ts +6 -1
  66. package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -0
  67. package/dist/types-ts4.5/rules/use-primitives-text/transformers/span-elements.d.ts +6 -1
  68. package/dist/types-ts4.5/rules/use-primitives-text/transformers/strong-elements.d.ts +6 -1
  69. package/package.json +2 -2
@@ -15,60 +15,65 @@ export const ParagraphElements = {
15
15
  // Check whether all criteria needed to make a transformation are met
16
16
  const {
17
17
  success,
18
+ autoFixable,
18
19
  refs
19
20
  } = ParagraphElements._check(node, {
20
21
  context,
21
22
  config
22
23
  });
23
- if (!success) {
24
- return;
25
- }
26
- if (refs.siblings.length > 1) {
27
- var _refs$siblings$0$loc, _refs$siblings$loc;
28
- /**
29
- * Highlighting from first opening element to last closing element
30
- * to indicate fix will change all p elements and wrap them in a Stack,
31
- * falls back to first opening element.
32
- */
33
- const startLoc = (_refs$siblings$0$loc = refs.siblings[0].loc) === null || _refs$siblings$0$loc === void 0 ? void 0 : _refs$siblings$0$loc.start;
34
- const endLoc = (_refs$siblings$loc = refs.siblings[refs.siblings.length - 1].loc) === null || _refs$siblings$loc === void 0 ? void 0 : _refs$siblings$loc.end;
35
- const fix = ParagraphElements._fixMultiple(node, {
36
- context,
37
- config,
38
- refs
39
- });
40
- context.report({
41
- loc: startLoc && endLoc && {
42
- start: startLoc,
43
- end: endLoc
44
- },
45
- node: node.openingElement,
46
- messageId: 'preferPrimitivesStackedText',
47
- ...(config.enableUnsafeAutofix ? {
48
- fix
49
- } : {
50
- suggest: [{
51
- desc: `Convert to Text and Stack`,
24
+ if (success && autoFixable) {
25
+ if (refs.siblings.length > 1) {
26
+ var _refs$siblings$0$loc, _refs$siblings$loc;
27
+ /**
28
+ * Highlighting from first opening element to last closing element
29
+ * to indicate fix will change all p elements and wrap them in a Stack,
30
+ * falls back to first opening element.
31
+ */
32
+ const startLoc = (_refs$siblings$0$loc = refs.siblings[0].loc) === null || _refs$siblings$0$loc === void 0 ? void 0 : _refs$siblings$0$loc.start;
33
+ const endLoc = (_refs$siblings$loc = refs.siblings[refs.siblings.length - 1].loc) === null || _refs$siblings$loc === void 0 ? void 0 : _refs$siblings$loc.end;
34
+ const fix = ParagraphElements._fixMultiple(node, {
35
+ context,
36
+ config,
37
+ refs
38
+ });
39
+ context.report({
40
+ loc: startLoc && endLoc && {
41
+ start: startLoc,
42
+ end: endLoc
43
+ },
44
+ node: node.openingElement,
45
+ messageId: 'preferPrimitivesStackedText',
46
+ ...(config.enableUnsafeAutofix ? {
52
47
  fix
53
- }]
54
- })
55
- });
56
- } else {
57
- const fix = ParagraphElements._fixSingle(node, {
58
- context,
59
- config
60
- });
61
- context.report({
62
- node,
63
- messageId: 'preferPrimitivesText',
64
- ...(config.enableUnsafeAutofix ? {
65
- fix
66
- } : {
67
- suggest: [{
68
- desc: `Convert to Text`,
48
+ } : {
49
+ suggest: [{
50
+ desc: `Convert to Text and Stack`,
51
+ fix
52
+ }]
53
+ })
54
+ });
55
+ } else {
56
+ const fix = ParagraphElements._fixSingle(node, {
57
+ context,
58
+ config
59
+ });
60
+ context.report({
61
+ node: node.openingElement,
62
+ messageId: 'preferPrimitivesText',
63
+ ...(config.enableUnsafeAutofix ? {
69
64
  fix
70
- }]
71
- })
65
+ } : {
66
+ suggest: [{
67
+ desc: `Convert to Text`,
68
+ fix
69
+ }]
70
+ })
71
+ });
72
+ }
73
+ } else if (success && config.enableUnsafeReport) {
74
+ context.report({
75
+ node: node.openingElement,
76
+ messageId: 'preferPrimitivesText'
72
77
  });
73
78
  }
74
79
  },
@@ -105,7 +110,8 @@ export const ParagraphElements = {
105
110
  // All siblings have to be paragraph elements with no unallowed props
106
111
  if (!isNodeOfType(node.parent, 'JSXElement')) {
107
112
  return {
108
- success: false,
113
+ success: true,
114
+ autoFixable: false,
109
115
  refs: {
110
116
  siblings: []
111
117
  }
@@ -117,7 +123,8 @@ export const ParagraphElements = {
117
123
  // Only report for the first p element by comparing node location
118
124
  if (((_siblings$0$range = siblings[0].range) === null || _siblings$0$range === void 0 ? void 0 : _siblings$0$range[0]) !== ((_node$range = node.range) === null || _node$range === void 0 ? void 0 : _node$range[0]) || ((_siblings$0$range2 = siblings[0].range) === null || _siblings$0$range2 === void 0 ? void 0 : _siblings$0$range2[1]) !== ((_node$range2 = node.range) === null || _node$range2 === void 0 ? void 0 : _node$range2[1])) {
119
125
  return {
120
- success: false,
126
+ success: true,
127
+ autoFixable: false,
121
128
  refs: {
122
129
  siblings
123
130
  }
@@ -135,7 +142,8 @@ export const ParagraphElements = {
135
142
  });
136
143
  if (!siblingsMatch) {
137
144
  return {
138
- success: false,
145
+ success: true,
146
+ autoFixable: false,
139
147
  refs: {
140
148
  siblings
141
149
  }
@@ -143,7 +151,8 @@ export const ParagraphElements = {
143
151
  }
144
152
  } else if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
145
153
  return {
146
- success: false,
154
+ success: true,
155
+ autoFixable: false,
147
156
  refs: {
148
157
  siblings
149
158
  }
@@ -154,7 +163,8 @@ export const ParagraphElements = {
154
163
  // If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
155
164
  if (importDeclaration.length > 1) {
156
165
  return {
157
- success: false,
166
+ success: true,
167
+ autoFixable: false,
158
168
  refs: {
159
169
  siblings
160
170
  }
@@ -162,6 +172,7 @@ export const ParagraphElements = {
162
172
  }
163
173
  return {
164
174
  success: true,
175
+ autoFixable: true,
165
176
  refs: {
166
177
  siblings
167
178
  }
@@ -13,60 +13,85 @@ export const SpanElements = {
13
13
  }
14
14
 
15
15
  // Check whether all criteria needed to make a transformation are met
16
- if (!SpanElements._check(node, {
17
- context,
18
- config
19
- })) {
20
- return;
21
- }
22
- const fix = SpanElements._fix(node, {
16
+ const {
17
+ success,
18
+ autoFixable
19
+ } = SpanElements._check(node, {
23
20
  context,
24
21
  config
25
22
  });
26
- context.report({
27
- node: node.openingElement,
28
- messageId: 'preferPrimitivesText',
29
- ...(config.enableUnsafeAutofix ? {
30
- fix
31
- } : {
32
- suggest: [{
33
- desc: `Convert to Text`,
23
+ if (success && autoFixable) {
24
+ const fix = SpanElements._fix(node, {
25
+ context,
26
+ config
27
+ });
28
+ context.report({
29
+ node: node.openingElement,
30
+ messageId: 'preferPrimitivesText',
31
+ ...(config.enableUnsafeAutofix ? {
34
32
  fix
35
- }]
36
- })
37
- });
33
+ } : {
34
+ suggest: [{
35
+ desc: `Convert to Text`,
36
+ fix
37
+ }]
38
+ })
39
+ });
40
+ } else if (success && config.enableUnsafeReport) {
41
+ context.report({
42
+ node: node.openingElement,
43
+ messageId: 'preferPrimitivesText'
44
+ });
45
+ }
38
46
  },
39
47
  _check(node, {
40
48
  context,
41
49
  config
42
50
  }) {
43
51
  if (!config.patterns.includes('span-elements')) {
44
- return false;
52
+ return {
53
+ success: false
54
+ };
45
55
  }
46
56
  const elementName = ast.JSXElement.getName(node);
47
57
  if (elementName !== 'span') {
48
- return false;
58
+ return {
59
+ success: false
60
+ };
49
61
  }
50
62
  if (!node.children.length) {
51
- return false;
52
- }
53
-
54
- // Element has no unallowed props
55
- if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
56
- return false;
63
+ return {
64
+ success: false
65
+ };
57
66
  }
58
67
 
59
68
  // Only allow elements with strings as children
60
69
  if (!hasTextChildrenOnly(node)) {
61
- return false;
70
+ return {
71
+ success: false
72
+ };
73
+ }
74
+
75
+ // Element has no unallowed props
76
+ if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
77
+ return {
78
+ success: true,
79
+ autoFixable: false
80
+ };
62
81
  }
63
- const importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
64
82
 
65
83
  // If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
84
+ const importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
66
85
  if (importDeclaration.length > 1) {
67
- return false;
86
+ return {
87
+ success: true,
88
+ autoFixable: false
89
+ };
68
90
  }
69
- return true;
91
+ return {
92
+ success: true,
93
+ autoFixable: true
94
+ };
70
95
  },
71
96
  _fix(node, {
72
97
  context,
@@ -13,55 +13,78 @@ export const StrongElements = {
13
13
  }
14
14
 
15
15
  // Check whether all criteria needed to make a transformation are met
16
- if (!StrongElements._check(node, {
17
- context,
18
- config
19
- })) {
20
- return;
21
- }
22
- const fix = StrongElements._fix(node, {
16
+ const {
17
+ success,
18
+ autoFixable
19
+ } = StrongElements._check(node, {
23
20
  context,
24
21
  config
25
22
  });
26
- context.report({
27
- node: node.openingElement,
28
- messageId: 'preferPrimitivesText',
29
- ...(config.enableUnsafeAutofix ? {
30
- fix
31
- } : {
32
- suggest: [{
33
- desc: `Convert to Text`,
23
+ if (success && autoFixable) {
24
+ const fix = StrongElements._fix(node, {
25
+ context,
26
+ config
27
+ });
28
+ context.report({
29
+ node: node.openingElement,
30
+ messageId: 'preferPrimitivesText',
31
+ ...(config.enableUnsafeAutofix ? {
34
32
  fix
35
- }]
36
- })
37
- });
33
+ } : {
34
+ suggest: [{
35
+ desc: `Convert to Text`,
36
+ fix
37
+ }]
38
+ })
39
+ });
40
+ } else if (success && config.enableUnsafeReport) {
41
+ context.report({
42
+ node: node.openingElement,
43
+ messageId: 'preferPrimitivesText'
44
+ });
45
+ }
38
46
  },
39
47
  _check(node, {
40
48
  context,
41
49
  config
42
50
  }) {
43
51
  if (!config.patterns.includes('strong-elements')) {
44
- return false;
52
+ return {
53
+ success: false
54
+ };
45
55
  }
46
56
  const elementName = ast.JSXElement.getName(node);
47
57
  if (elementName !== 'strong') {
48
- return false;
58
+ return {
59
+ success: false
60
+ };
49
61
  }
50
62
  if (!node.children.length) {
51
- return false;
63
+ return {
64
+ success: false
65
+ };
52
66
  }
53
67
 
54
68
  // Element has no unallowed props
55
69
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
56
- return false;
70
+ return {
71
+ success: true,
72
+ autoFixable: false
73
+ };
57
74
  }
58
75
 
59
76
  // If there is more than one `@atlaskit/primitives` import, then it becomes difficult to determine which import to transform
60
77
  const importDeclaration = ast.Root.findImportsByModule(context.getSourceCode().ast.body, '@atlaskit/primitives');
61
78
  if (importDeclaration.length > 1) {
62
- return false;
79
+ return {
80
+ success: true,
81
+ autoFixable: false
82
+ };
63
83
  }
64
- return true;
84
+ return {
85
+ success: true,
86
+ autoFixable: true
87
+ };
65
88
  },
66
89
  _fix(node, {
67
90
  context,
@@ -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::ab43b6e1a867d07b9a27eae78d48834a>>
3
+ * @codegen <<SignedSource::b6947ac630ea512fe3f4e3f44abb6783>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  export default {
@@ -17,12 +17,11 @@ export default {
17
17
  '@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
18
18
  '@atlaskit/design-system/no-deprecated-imports': 'error',
19
19
  '@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': 'error',
20
- '@atlaskit/design-system/no-empty-styled-expression': 'warn',
21
- '@atlaskit/design-system/no-exported-css': 'warn',
22
- '@atlaskit/design-system/no-exported-keyframes': 'warn',
23
20
  '@atlaskit/design-system/no-html-anchor': 'warn',
24
21
  '@atlaskit/design-system/no-html-button': 'warn',
25
- '@atlaskit/design-system/no-invalid-css-map': 'error',
22
+ '@atlaskit/design-system/no-invalid-css-map': ['error', {
23
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
24
+ }],
26
25
  '@atlaskit/design-system/no-keyframes-tagged-template-expression': 'error',
27
26
  '@atlaskit/design-system/no-legacy-icons': 'warn',
28
27
  '@atlaskit/design-system/no-margin': '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::a620cfa5339ecfe9527af26afe5121e4>>
3
+ * @codegen <<SignedSource::9b6bccf688f4ee18dd0d49dbce48e475>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  export default {
@@ -14,12 +14,11 @@ export default {
14
14
  '@atlaskit/design-system/no-deprecated-design-token-usage': 'warn',
15
15
  '@atlaskit/design-system/no-deprecated-imports': 'error',
16
16
  '@atlaskit/design-system/no-direct-use-of-web-platform-drag-and-drop': 'error',
17
- '@atlaskit/design-system/no-empty-styled-expression': 'warn',
18
- '@atlaskit/design-system/no-exported-css': 'warn',
19
- '@atlaskit/design-system/no-exported-keyframes': 'warn',
20
17
  '@atlaskit/design-system/no-html-anchor': 'warn',
21
18
  '@atlaskit/design-system/no-html-button': 'warn',
22
- '@atlaskit/design-system/no-invalid-css-map': 'error',
19
+ '@atlaskit/design-system/no-invalid-css-map': ['error', {
20
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
21
+ }],
23
22
  '@atlaskit/design-system/no-nested-styles': 'error',
24
23
  '@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
25
24
  '@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
@@ -43,8 +43,7 @@ var noEmptyStyledExpressionRule = createLintRule({
43
43
  name: 'no-empty-styled-expression',
44
44
  docs: {
45
45
  description: 'Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements).',
46
- recommended: true,
47
- severity: 'warn'
46
+ removeFromPresets: true // effectively disable this rule here, this is configured by `@atlaskit/ui-styling-standard` instead
48
47
  },
49
48
  messages: {
50
49
  unexpected: 'Found an empty expression, or empty object argument passed to `styled` function call. This unnecessarily causes a major performance penalty - please use a plain JSX element or a React fragment instead (e.g. `<div>Hello</div>` or `<>Hello</>`).'
@@ -7,8 +7,7 @@ var noExportedCssRule = createLintRule({
7
7
  type: 'problem',
8
8
  docs: {
9
9
  description: 'Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.',
10
- recommended: true,
11
- severity: 'warn'
10
+ removeFromPresets: true // effectively disable this rule here, this is overriden by `@atlaskit/ui-styling-standard` instead
12
11
  },
13
12
  messages: {
14
13
  unexpected: "`css` can't be exported - this will cause unexpected behaviour at runtime. Instead, please move your `css(...)` code to the same file where these styles are being used."
@@ -7,8 +7,7 @@ var noExportedKeyframesRule = createLintRule({
7
7
  type: 'problem',
8
8
  docs: {
9
9
  description: 'Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable.',
10
- recommended: true,
11
- severity: 'warn'
10
+ removeFromPresets: true // effectively disable this rule here, this is overriden by `@atlaskit/ui-styling-standard` instead
12
11
  },
13
12
  messages: {
14
13
  unexpected: "`keyframes` can't be exported - this will cause unexpected behaviour at runtime. Instead, please move your `keyframes(...)` code to the same file where these styles are being used."
@@ -59,7 +59,10 @@ var noInvalidCssMapRule = createLintRule({
59
59
  docs: {
60
60
  description: "Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking.",
61
61
  recommended: true,
62
- severity: 'error'
62
+ severity: 'error',
63
+ pluginConfig: {
64
+ allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
65
+ }
63
66
  },
64
67
  messages: {
65
68
  mustBeTopLevelScope: 'cssMap must only be used in the top-most scope of the module.',
@@ -132,12 +132,12 @@ export var createGuidance = function createGuidance(iconPackage) {
132
132
  * @returns True if the color can be migrated, false otherwise
133
133
  */
134
134
  export var canMigrateColor = function canMigrateColor(color) {
135
- if (color.match(/^color\.text$/)) {
136
- return true;
137
- } else if (color.match(/^color\.icon/)) {
135
+ if (color.match(/^color\.icon/)) {
138
136
  return true;
139
137
  } else if (color.match(/^color\.link/)) {
140
138
  return true;
139
+ } else if (color.match(/^color\.text/)) {
140
+ return true;
141
141
  } else if (color === 'currentColor') {
142
142
  return true;
143
143
  } else {
@@ -1,7 +1,8 @@
1
1
  var defaults = {
2
2
  failSilently: false,
3
3
  patterns: ['native-elements'],
4
- enableUnsafeAutofix: false
4
+ enableUnsafeAutofix: false,
5
+ enableUnsafeReport: false
5
6
  };
6
7
  export var getConfig = function getConfig(overrides) {
7
8
  return Object.assign({}, defaults, overrides);
@@ -20,63 +20,93 @@ export var NativeElements = {
20
20
  var context = _ref.context,
21
21
  config = _ref.config;
22
22
  // Check whether all criteria needed to make a transformation are met
23
- if (!NativeElements._check(node, {
24
- context: context,
25
- config: config
26
- })) {
27
- return;
28
- }
29
- var fix = NativeElements._fix(node, {
30
- context: context,
31
- config: config
32
- });
33
- context.report(_objectSpread({
34
- node: node,
35
- messageId: 'preferHeading'
36
- }, config.enableUnsafeAutofix ? {
37
- fix: fix
38
- } : {
39
- suggest: [{
40
- desc: "Convert to Heading",
23
+ var _NativeElements$_chec = NativeElements._check(node, {
24
+ context: context,
25
+ config: config
26
+ }),
27
+ success = _NativeElements$_chec.success,
28
+ autoFixable = _NativeElements$_chec.autoFixable;
29
+ if (success && autoFixable) {
30
+ var fix = NativeElements._fix(node, {
31
+ context: context,
32
+ config: config
33
+ });
34
+ context.report(_objectSpread({
35
+ node: node,
36
+ messageId: 'preferHeading'
37
+ }, config.enableUnsafeAutofix ? {
41
38
  fix: fix
42
- }]
43
- }));
39
+ } : {
40
+ suggest: [{
41
+ desc: "Convert to Heading",
42
+ fix: fix
43
+ }]
44
+ }));
45
+ } else if (success && config.enableUnsafeReport) {
46
+ context.report({
47
+ node: node,
48
+ messageId: 'preferHeading'
49
+ });
50
+ }
44
51
  },
45
52
  _check: function _check(node, _ref2) {
46
53
  var config = _ref2.config;
47
54
  if (!config.patterns.includes('native-elements')) {
48
- return false;
55
+ return {
56
+ success: false
57
+ };
49
58
  }
50
59
  if (!isNodeOfType(node, 'JSXElement')) {
51
- return false;
60
+ return {
61
+ success: false
62
+ };
52
63
  }
53
64
  if (!node.children.length) {
54
- return false;
55
- }
56
- if (!node.parent) {
57
- return false;
65
+ return {
66
+ success: false
67
+ };
58
68
  }
59
69
  var elementName = ast.JSXElement.getName(node);
60
70
  if (!Object.keys(tagSizeMap).includes(elementName)) {
61
- return false;
71
+ return {
72
+ success: false
73
+ };
74
+ }
75
+ if (!node.parent) {
76
+ return {
77
+ success: true,
78
+ autoFixable: false
79
+ };
62
80
  }
63
81
 
64
82
  // Element has to be first element of its siblings
65
83
  if (!(isNodeOfType(node.parent, 'JSXElement') || isNodeOfType(node.parent, 'JSXFragment'))) {
66
- return false;
84
+ return {
85
+ success: true,
86
+ autoFixable: false
87
+ };
67
88
  }
68
89
  var siblings = ast.JSXElement.getChildren(node.parent);
69
90
  if (siblings.length > 1) {
70
91
  var _siblings$0$range, _node$range, _siblings$0$range2, _node$range2;
71
92
  // Only report if element is first child element
72
93
  if (((_siblings$0$range = siblings[0].range) === null || _siblings$0$range === void 0 ? void 0 : _siblings$0$range[0]) !== ((_node$range = node.range) === null || _node$range === void 0 ? void 0 : _node$range[0]) || ((_siblings$0$range2 = siblings[0].range) === null || _siblings$0$range2 === void 0 ? void 0 : _siblings$0$range2[1]) !== ((_node$range2 = node.range) === null || _node$range2 === void 0 ? void 0 : _node$range2[1])) {
73
- return false;
94
+ return {
95
+ success: true,
96
+ autoFixable: false
97
+ };
74
98
  }
75
99
  }
76
100
  if (!ast.JSXElement.hasAllowedAttrsOnly(node, allowedAttrs)) {
77
- return false;
101
+ return {
102
+ success: true,
103
+ autoFixable: false
104
+ };
78
105
  }
79
- return true;
106
+ return {
107
+ success: true,
108
+ autoFixable: true
109
+ };
80
110
  },
81
111
  _fix: function _fix(node, _ref3) {
82
112
  var context = _ref3.context;
@@ -2,7 +2,8 @@ var defaults = {
2
2
  failSilently: false,
3
3
  patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements'],
4
4
  inheritColor: false,
5
- enableUnsafeAutofix: false
5
+ enableUnsafeAutofix: false,
6
+ enableUnsafeReport: false
6
7
  };
7
8
  export var getConfig = function getConfig(overrides) {
8
9
  return Object.assign({}, defaults, overrides);