@atlaskit/eslint-plugin-design-system 13.25.0 → 13.27.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.
- package/CHANGELOG.md +17 -0
- package/README.md +73 -71
- package/dist/cjs/presets/all-flat.codegen.js +4 -2
- package/dist/cjs/presets/all.codegen.js +4 -2
- package/dist/cjs/presets/recommended-flat.codegen.js +2 -2
- package/dist/cjs/presets/recommended.codegen.js +2 -2
- package/dist/cjs/rules/index.codegen.js +7 -3
- package/dist/cjs/rules/{lozenge-appearance-and-isbold-migration → lozenge-isBold-and-lozenge-badge-appearance-migration}/index.js +115 -19
- package/dist/cjs/rules/no-to-match-snapshot/index.js +49 -0
- package/dist/cjs/rules/no-unsafe-inline-snapshot/index.js +139 -0
- package/dist/es2019/presets/all-flat.codegen.js +4 -2
- package/dist/es2019/presets/all.codegen.js +4 -2
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -2
- package/dist/es2019/presets/recommended.codegen.js +2 -2
- package/dist/es2019/rules/index.codegen.js +7 -3
- package/dist/es2019/rules/{lozenge-appearance-and-isbold-migration → lozenge-isBold-and-lozenge-badge-appearance-migration}/index.js +109 -15
- package/dist/es2019/rules/no-to-match-snapshot/index.js +43 -0
- package/dist/es2019/rules/no-unsafe-inline-snapshot/index.js +134 -0
- package/dist/esm/presets/all-flat.codegen.js +4 -2
- package/dist/esm/presets/all.codegen.js +4 -2
- package/dist/esm/presets/recommended-flat.codegen.js +2 -2
- package/dist/esm/presets/recommended.codegen.js +2 -2
- package/dist/esm/rules/index.codegen.js +7 -3
- package/dist/esm/rules/{lozenge-appearance-and-isbold-migration → lozenge-isBold-and-lozenge-badge-appearance-migration}/index.js +115 -19
- package/dist/esm/rules/no-to-match-snapshot/index.js +43 -0
- package/dist/esm/rules/no-unsafe-inline-snapshot/index.js +133 -0
- package/dist/types/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -1
- package/dist/types/presets/recommended.codegen.d.ts +1 -1
- package/dist/types/rules/index.codegen.d.ts +1 -1
- package/dist/types/rules/no-to-match-snapshot/index.d.ts +4 -0
- package/dist/types/rules/no-unsafe-inline-snapshot/index.d.ts +4 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/no-to-match-snapshot/index.d.ts +4 -0
- package/dist/types-ts4.5/rules/no-unsafe-inline-snapshot/index.d.ts +4 -0
- package/package.json +3 -3
- /package/dist/types/rules/{lozenge-appearance-and-isbold-migration → lozenge-isBold-and-lozenge-badge-appearance-migration}/index.d.ts +0 -0
- /package/dist/types-ts4.5/rules/{lozenge-appearance-and-isbold-migration → lozenge-isBold-and-lozenge-badge-appearance-migration}/index.d.ts +0 -0
|
@@ -8,18 +8,20 @@ var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
|
8
8
|
var _createRule = require("../utils/create-rule");
|
|
9
9
|
var rule = (0, _createRule.createLintRule)({
|
|
10
10
|
meta: {
|
|
11
|
-
name: 'lozenge-
|
|
11
|
+
name: 'lozenge-isBold-and-lozenge-badge-appearance-migration',
|
|
12
12
|
fixable: 'code',
|
|
13
13
|
type: 'suggestion',
|
|
14
14
|
docs: {
|
|
15
|
-
description: 'Helps migrate
|
|
15
|
+
description: 'Helps migrate Lozenge isBold prop and appearance values (for both Lozenge and Badge components) as part of the Labelling System Phase 1 migration.',
|
|
16
16
|
recommended: true,
|
|
17
17
|
severity: 'warn'
|
|
18
18
|
},
|
|
19
19
|
messages: {
|
|
20
20
|
updateAppearance: 'Update appearance value to new semantic value.',
|
|
21
21
|
migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
|
|
22
|
-
manualReview: "Dynamic 'isBold' props require manual review before migration."
|
|
22
|
+
manualReview: "Dynamic 'isBold' props require manual review before migration.",
|
|
23
|
+
updateBadgeAppearance: 'Update Badge appearance value "{{oldValue}}" to new semantic value "{{newValue}}".',
|
|
24
|
+
dynamicBadgeAppearance: 'Dynamic appearance prop values require manual review to ensure they use the new semantic values: neutral, information, inverse, danger, success.'
|
|
23
25
|
}
|
|
24
26
|
},
|
|
25
27
|
create: function create(context) {
|
|
@@ -28,6 +30,11 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
28
30
|
*/
|
|
29
31
|
var lozengeImports = {}; // local name -> import source
|
|
30
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Contains a map of imported Badge components.
|
|
35
|
+
*/
|
|
36
|
+
var badgeImports = {}; // local name -> import source
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Check if a JSX attribute value is a literal false
|
|
33
40
|
*/
|
|
@@ -36,14 +43,25 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
|
-
* Check if a JSX attribute value is dynamic (not a literal
|
|
46
|
+
* Check if a JSX attribute value is dynamic (not a static literal value)
|
|
47
|
+
* Can be used for any prop type (boolean, string, etc.)
|
|
40
48
|
*/
|
|
41
49
|
function isDynamicExpression(node) {
|
|
42
|
-
if (!node
|
|
50
|
+
if (!node) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// If it's a plain literal (e.g., appearance="value"), it's not dynamic
|
|
55
|
+
if (node.type === 'Literal') {
|
|
43
56
|
return false;
|
|
44
57
|
}
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
|
|
59
|
+
// If it's an expression container with a non-literal expression, it's dynamic
|
|
60
|
+
if (node.type === 'JSXExpressionContainer') {
|
|
61
|
+
var expr = node.expression;
|
|
62
|
+
return expr && expr.type !== 'Literal';
|
|
63
|
+
}
|
|
64
|
+
return false;
|
|
47
65
|
}
|
|
48
66
|
|
|
49
67
|
/**
|
|
@@ -76,6 +94,21 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
76
94
|
return mapping[oldValue] || oldValue;
|
|
77
95
|
}
|
|
78
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Map Badge old appearance values to new semantic appearance values
|
|
99
|
+
*/
|
|
100
|
+
function mapBadgeToNewAppearanceValue(oldValue) {
|
|
101
|
+
var mapping = {
|
|
102
|
+
added: 'success',
|
|
103
|
+
removed: 'danger',
|
|
104
|
+
default: 'neutral',
|
|
105
|
+
primary: 'information',
|
|
106
|
+
primaryInverted: 'inverse',
|
|
107
|
+
important: 'danger'
|
|
108
|
+
};
|
|
109
|
+
return mapping[oldValue] || oldValue;
|
|
110
|
+
}
|
|
111
|
+
|
|
79
112
|
/**
|
|
80
113
|
* Extract the string value from a JSX attribute value
|
|
81
114
|
*/
|
|
@@ -92,6 +125,25 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
92
125
|
return null;
|
|
93
126
|
}
|
|
94
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Create a fixer function to replace an appearance prop value
|
|
130
|
+
* Handles both Literal and JSXExpressionContainer with Literal
|
|
131
|
+
*/
|
|
132
|
+
function createAppearanceFixer(attrValue, newValue) {
|
|
133
|
+
return function (fixer) {
|
|
134
|
+
if (!attrValue) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
if (attrValue.type === 'Literal') {
|
|
138
|
+
return fixer.replaceText(attrValue, "\"".concat(newValue, "\""));
|
|
139
|
+
}
|
|
140
|
+
if (attrValue.type === 'JSXExpressionContainer' && 'expression' in attrValue && attrValue.expression && attrValue.expression.type === 'Literal') {
|
|
141
|
+
return fixer.replaceText(attrValue.expression, "\"".concat(newValue, "\""));
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
95
147
|
/**
|
|
96
148
|
* Generate the replacement JSX element text
|
|
97
149
|
*/
|
|
@@ -153,6 +205,18 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
153
205
|
}
|
|
154
206
|
});
|
|
155
207
|
}
|
|
208
|
+
// Track Badge imports
|
|
209
|
+
if (moduleSource === '@atlaskit/badge' || moduleSource.startsWith('@atlaskit/badge')) {
|
|
210
|
+
node.specifiers.forEach(function (spec) {
|
|
211
|
+
if (spec.type === 'ImportDefaultSpecifier') {
|
|
212
|
+
badgeImports[spec.local.name] = moduleSource;
|
|
213
|
+
} else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
|
|
214
|
+
if (spec.imported.name === 'Badge' || spec.imported.name === 'default') {
|
|
215
|
+
badgeImports[spec.local.name] = moduleSource;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
156
220
|
}
|
|
157
221
|
},
|
|
158
222
|
JSXElement: function JSXElement(node) {
|
|
@@ -164,6 +228,45 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
164
228
|
}
|
|
165
229
|
var elementName = node.openingElement.name.name;
|
|
166
230
|
|
|
231
|
+
// Handle Badge components
|
|
232
|
+
if (badgeImports[elementName]) {
|
|
233
|
+
// Find the appearance prop
|
|
234
|
+
var _appearanceProp = node.openingElement.attributes.find(function (attr) {
|
|
235
|
+
return attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier' && attr.name.name === 'appearance';
|
|
236
|
+
});
|
|
237
|
+
if (!_appearanceProp || _appearanceProp.type !== 'JSXAttribute') {
|
|
238
|
+
// No appearance prop or it's a spread attribute, nothing to migrate
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Check if it's a dynamic expression
|
|
243
|
+
if (isDynamicExpression(_appearanceProp.value)) {
|
|
244
|
+
context.report({
|
|
245
|
+
node: _appearanceProp,
|
|
246
|
+
messageId: 'dynamicBadgeAppearance'
|
|
247
|
+
});
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Extract the string value
|
|
252
|
+
var stringValue = extractStringValue(_appearanceProp.value);
|
|
253
|
+
if (stringValue && typeof stringValue === 'string') {
|
|
254
|
+
var mappedValue = mapBadgeToNewAppearanceValue(stringValue);
|
|
255
|
+
if (mappedValue !== stringValue) {
|
|
256
|
+
context.report({
|
|
257
|
+
node: _appearanceProp,
|
|
258
|
+
messageId: 'updateBadgeAppearance',
|
|
259
|
+
data: {
|
|
260
|
+
oldValue: stringValue,
|
|
261
|
+
newValue: mappedValue
|
|
262
|
+
},
|
|
263
|
+
fix: createAppearanceFixer(_appearanceProp.value, mappedValue)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
167
270
|
// Only process if this is a Lozenge component we've imported
|
|
168
271
|
if (!lozengeImports[elementName]) {
|
|
169
272
|
return;
|
|
@@ -177,21 +280,14 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
177
280
|
var shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
|
|
178
281
|
if (!shouldMigrateToTag) {
|
|
179
282
|
// Only update appearance values for Lozenge components that stay as Lozenge
|
|
180
|
-
var
|
|
181
|
-
if (
|
|
182
|
-
var
|
|
183
|
-
if (
|
|
283
|
+
var _stringValue = extractStringValue(appearanceProp.value);
|
|
284
|
+
if (_stringValue && typeof _stringValue === 'string') {
|
|
285
|
+
var _mappedValue = mapToNewAppearanceValue(_stringValue);
|
|
286
|
+
if (_mappedValue !== _stringValue) {
|
|
184
287
|
context.report({
|
|
185
288
|
node: appearanceProp,
|
|
186
289
|
messageId: 'updateAppearance',
|
|
187
|
-
fix:
|
|
188
|
-
if (appearanceProp.value.type === 'Literal') {
|
|
189
|
-
return fixer.replaceText(appearanceProp.value, "\"".concat(mappedValue, "\""));
|
|
190
|
-
} else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
|
|
191
|
-
return fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedValue, "\""));
|
|
192
|
-
}
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
290
|
+
fix: createAppearanceFixer(appearanceProp.value, _mappedValue)
|
|
195
291
|
});
|
|
196
292
|
}
|
|
197
293
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.name = exports.default = void 0;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _createRule = require("../utils/create-rule");
|
|
9
|
+
var name = exports.name = 'no-to-match-snapshot';
|
|
10
|
+
var rule = (0, _createRule.createLintRule)({
|
|
11
|
+
meta: {
|
|
12
|
+
name: name,
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: {
|
|
15
|
+
description: 'Disallow using toMatchSnapshot() in favor of toMatchInlineSnapshot(). See https://hello.atlassian.net/wiki/spaces/DST/pages/6105892000/DSTRFC-038+-+Removal+of+.toMatchSnapshot for rationale.',
|
|
16
|
+
recommended: false,
|
|
17
|
+
severity: 'error'
|
|
18
|
+
},
|
|
19
|
+
messages: {
|
|
20
|
+
useInlineSnapshot: 'Use toMatchInlineSnapshot() instead of toMatchSnapshot(). See https://hello.atlassian.net/wiki/spaces/DST/pages/6105892000/DSTRFC-038+-+Removal+of+.toMatchSnapshot for rationale.'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
create: function create(context) {
|
|
24
|
+
return {
|
|
25
|
+
MemberExpression: function MemberExpression(node) {
|
|
26
|
+
// Check if this is a call to toMatchSnapshot
|
|
27
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.property, 'Identifier') || node.property.name !== 'toMatchSnapshot') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check if the object is an expect() call
|
|
32
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.object, 'CallExpression') || !(0, _eslintCodemodUtils.isNodeOfType)(node.object.callee, 'Identifier') || node.object.callee.name !== 'expect') {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Only report if this is being called (i.e., it's part of a CallExpression)
|
|
37
|
+
// We want to catch expect(...).toMatchSnapshot() but not just the property access
|
|
38
|
+
if (!node.parent || !(0, _eslintCodemodUtils.isNodeOfType)(node.parent, 'CallExpression')) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
context.report({
|
|
42
|
+
node: node.property,
|
|
43
|
+
messageId: 'useInlineSnapshot'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
var _default = exports.default = rule;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.name = exports.default = void 0;
|
|
7
|
+
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
8
|
+
var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
|
|
9
|
+
var _createRule = require("../utils/create-rule");
|
|
10
|
+
var name = exports.name = 'no-unsafe-inline-snapshot';
|
|
11
|
+
var MAX_LINES = 100;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a snapshot contains internal implementation details
|
|
15
|
+
*/
|
|
16
|
+
function containsInternalDetails(snapshotContent) {
|
|
17
|
+
var issues = [];
|
|
18
|
+
|
|
19
|
+
// Check for className attributes (unless they equal "REDACTED")
|
|
20
|
+
// Handles: className="value", className='value', and whitespace variations
|
|
21
|
+
var classNameRegex = /className\s*=\s*(["'])((?:(?!\1)[^\\]|\\.)*)\1/gi;
|
|
22
|
+
var match;
|
|
23
|
+
while ((match = classNameRegex.exec(snapshotContent)) !== null) {
|
|
24
|
+
var classNameValue = match[2];
|
|
25
|
+
if (classNameValue && classNameValue !== 'REDACTED') {
|
|
26
|
+
issues.push("className=\"".concat(classNameValue, "\""));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check for style attributes (unless they equal "REDACTED")
|
|
31
|
+
// Handles: style="value", style='value', and whitespace variations
|
|
32
|
+
// Style values can contain colons, semicolons, etc., so we need to capture the full quoted value
|
|
33
|
+
var styleRegex = /style\s*=\s*(["'])((?:(?!\1)[^\\]|\\.)*)\1/gi;
|
|
34
|
+
while ((match = styleRegex.exec(snapshotContent)) !== null) {
|
|
35
|
+
var styleValue = match[2];
|
|
36
|
+
if (styleValue && styleValue !== 'REDACTED') {
|
|
37
|
+
issues.push("style=\"".concat(styleValue, "\""));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Check for style blocks (unless they contain "REDACTED")
|
|
42
|
+
var styleBlockRegex = /<style[^>]*>([\s\S]*?)<\/style>/gi;
|
|
43
|
+
while ((match = styleBlockRegex.exec(snapshotContent)) !== null) {
|
|
44
|
+
var styleContent = match[1];
|
|
45
|
+
if (styleContent && !styleContent.trim().includes('REDACTED')) {
|
|
46
|
+
issues.push('style block');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
hasIssues: issues.length > 0,
|
|
51
|
+
issues: issues
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Extracts the snapshot content from a template literal or string literal
|
|
57
|
+
*/
|
|
58
|
+
function extractSnapshotContent(node, sourceCode) {
|
|
59
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'TemplateLiteral')) {
|
|
60
|
+
// For template literals, get the raw text including the template parts
|
|
61
|
+
return sourceCode.getText(node);
|
|
62
|
+
}
|
|
63
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'Literal') && typeof node.value === 'string') {
|
|
64
|
+
return node.value;
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
var rule = (0, _createRule.createLintRule)({
|
|
69
|
+
meta: {
|
|
70
|
+
name: name,
|
|
71
|
+
type: 'problem',
|
|
72
|
+
docs: {
|
|
73
|
+
description: 'Enforce guardrails on toMatchInlineSnapshot usage: snapshots must not exceed 100 lines and must not contain internal implementation details like className or style attributes.',
|
|
74
|
+
recommended: false,
|
|
75
|
+
severity: 'error'
|
|
76
|
+
},
|
|
77
|
+
messages: {
|
|
78
|
+
exceedsMaxLines: "Inline snapshot exceeds ".concat(MAX_LINES, " lines. Consider breaking it into smaller snapshots or using a different testing approach."),
|
|
79
|
+
containsInternalDetails: 'Inline snapshot contains internal implementation details: {{details}}. Use "REDACTED" for className and style values, or remove these details from the snapshot.'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
create: function create(context) {
|
|
83
|
+
var sourceCode = (0, _contextCompat.getSourceCode)(context);
|
|
84
|
+
return {
|
|
85
|
+
MemberExpression: function MemberExpression(node) {
|
|
86
|
+
// Check if this is a call to toMatchInlineSnapshot
|
|
87
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.property, 'Identifier') || node.property.name !== 'toMatchInlineSnapshot') {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Check if the object is an expect() call
|
|
92
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node.object, 'CallExpression') || !(0, _eslintCodemodUtils.isNodeOfType)(node.object.callee, 'Identifier') || node.object.callee.name !== 'expect') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Only report if this is being called (i.e., it's part of a CallExpression)
|
|
97
|
+
if (!node.parent || !(0, _eslintCodemodUtils.isNodeOfType)(node.parent, 'CallExpression')) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Get the snapshot content from the first argument
|
|
102
|
+
var callExpression = node.parent;
|
|
103
|
+
if (callExpression.arguments.length === 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
var snapshotArg = callExpression.arguments[0];
|
|
107
|
+
var snapshotContent = extractSnapshotContent(snapshotArg, sourceCode);
|
|
108
|
+
if (!snapshotContent) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Check line count
|
|
113
|
+
var lines = snapshotContent.split('\n');
|
|
114
|
+
if (lines.length > MAX_LINES) {
|
|
115
|
+
context.report({
|
|
116
|
+
node: snapshotArg,
|
|
117
|
+
messageId: 'exceedsMaxLines'
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Check for internal implementation details
|
|
123
|
+
var _containsInternalDeta = containsInternalDetails(snapshotContent),
|
|
124
|
+
hasIssues = _containsInternalDeta.hasIssues,
|
|
125
|
+
issues = _containsInternalDeta.issues;
|
|
126
|
+
if (hasIssues) {
|
|
127
|
+
context.report({
|
|
128
|
+
node: snapshotArg,
|
|
129
|
+
messageId: 'containsInternalDetails',
|
|
130
|
+
data: {
|
|
131
|
+
details: issues.slice(0, 3).join(', ') // Show first 3 issues
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
var _default = exports.default = rule;
|
|
@@ -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::
|
|
3
|
+
* @codegen <<SignedSource::d7a0407a6c6b10bfbba790523d06f97d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ const rules = {
|
|
|
15
15
|
'@atlaskit/design-system/ensure-icon-color': 'error',
|
|
16
16
|
'@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
|
|
17
17
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
18
|
-
'@atlaskit/design-system/lozenge-
|
|
18
|
+
'@atlaskit/design-system/lozenge-isBold-and-lozenge-badge-appearance-migration': 'warn',
|
|
19
19
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
20
20
|
'@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
|
|
21
21
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'error',
|
|
@@ -47,7 +47,9 @@ const rules = {
|
|
|
47
47
|
'@atlaskit/design-system/no-physical-properties': 'error',
|
|
48
48
|
'@atlaskit/design-system/no-separator-with-list-elements': 'warn',
|
|
49
49
|
'@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
|
|
50
|
+
'@atlaskit/design-system/no-to-match-snapshot': 'error',
|
|
50
51
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
52
|
+
'@atlaskit/design-system/no-unsafe-inline-snapshot': 'error',
|
|
51
53
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
52
54
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
53
55
|
'@atlaskit/design-system/no-unused-css-map': '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::
|
|
3
|
+
* @codegen <<SignedSource::e632a96e9bae920c23e25114f40e3c0d>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ const rules = {
|
|
|
14
14
|
'@atlaskit/design-system/ensure-icon-color': 'error',
|
|
15
15
|
'@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
|
|
16
16
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
17
|
-
'@atlaskit/design-system/lozenge-
|
|
17
|
+
'@atlaskit/design-system/lozenge-isBold-and-lozenge-badge-appearance-migration': 'warn',
|
|
18
18
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
19
19
|
'@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
|
|
20
20
|
'@atlaskit/design-system/no-css-tagged-template-expression': 'error',
|
|
@@ -46,7 +46,9 @@ const rules = {
|
|
|
46
46
|
'@atlaskit/design-system/no-physical-properties': 'error',
|
|
47
47
|
'@atlaskit/design-system/no-separator-with-list-elements': 'warn',
|
|
48
48
|
'@atlaskit/design-system/no-styled-tagged-template-expression': 'error',
|
|
49
|
+
'@atlaskit/design-system/no-to-match-snapshot': 'error',
|
|
49
50
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
51
|
+
'@atlaskit/design-system/no-unsafe-inline-snapshot': 'error',
|
|
50
52
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
51
53
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
52
54
|
'@atlaskit/design-system/no-unused-css-map': '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::
|
|
3
|
+
* @codegen <<SignedSource::7ed1a8eeaaea559980cb2c533ba9a2e6>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ const rules = {
|
|
|
11
11
|
'@atlaskit/design-system/consistent-css-prop-usage': 'error',
|
|
12
12
|
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
13
13
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
14
|
-
'@atlaskit/design-system/lozenge-
|
|
14
|
+
'@atlaskit/design-system/lozenge-isBold-and-lozenge-badge-appearance-migration': 'warn',
|
|
15
15
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
16
16
|
'@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
|
|
17
17
|
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::32a0942d7edc5a3fdc70dd0833bb8aca>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ const rules = {
|
|
|
10
10
|
'@atlaskit/design-system/consistent-css-prop-usage': 'error',
|
|
11
11
|
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
12
12
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
13
|
-
'@atlaskit/design-system/lozenge-
|
|
13
|
+
'@atlaskit/design-system/lozenge-isBold-and-lozenge-badge-appearance-migration': 'warn',
|
|
14
14
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
15
15
|
'@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
|
|
16
16
|
'@atlaskit/design-system/no-deprecated-apis': 'error',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::62347cf64e4ac99b927fce9d1a2bd894>>
|
|
4
4
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ import ensureDesignTokenUsagePreview from './ensure-design-token-usage-preview';
|
|
|
11
11
|
import ensureIconColor from './ensure-icon-color';
|
|
12
12
|
import ensureProperXcssUsage from './ensure-proper-xcss-usage';
|
|
13
13
|
import iconLabel from './icon-label';
|
|
14
|
-
import
|
|
14
|
+
import lozengeIsBoldAndLozengeBadgeAppearanceMigration from './lozenge-isBold-and-lozenge-badge-appearance-migration';
|
|
15
15
|
import noBannedImports from './no-banned-imports';
|
|
16
16
|
import noBooleanAutofocusOnModalDialog from './no-boolean-autofocus-on-modal-dialog';
|
|
17
17
|
import noCssTaggedTemplateExpression from './no-css-tagged-template-expression';
|
|
@@ -44,7 +44,9 @@ import noNestedStyles from './no-nested-styles';
|
|
|
44
44
|
import noPhysicalProperties from './no-physical-properties';
|
|
45
45
|
import noSeparatorWithListElements from './no-separator-with-list-elements';
|
|
46
46
|
import noStyledTaggedTemplateExpression from './no-styled-tagged-template-expression';
|
|
47
|
+
import noToMatchSnapshot from './no-to-match-snapshot';
|
|
47
48
|
import noUnsafeDesignTokenUsage from './no-unsafe-design-token-usage';
|
|
49
|
+
import noUnsafeInlineSnapshot from './no-unsafe-inline-snapshot';
|
|
48
50
|
import noUnsafeStyleOverrides from './no-unsafe-style-overrides';
|
|
49
51
|
import noUnsupportedDragAndDropLibraries from './no-unsupported-drag-and-drop-libraries';
|
|
50
52
|
import noUnusedCssMap from './no-unused-css-map';
|
|
@@ -81,7 +83,7 @@ export const rules = {
|
|
|
81
83
|
'ensure-icon-color': ensureIconColor,
|
|
82
84
|
'ensure-proper-xcss-usage': ensureProperXcssUsage,
|
|
83
85
|
'icon-label': iconLabel,
|
|
84
|
-
'lozenge-
|
|
86
|
+
'lozenge-isBold-and-lozenge-badge-appearance-migration': lozengeIsBoldAndLozengeBadgeAppearanceMigration,
|
|
85
87
|
'no-banned-imports': noBannedImports,
|
|
86
88
|
'no-boolean-autofocus-on-modal-dialog': noBooleanAutofocusOnModalDialog,
|
|
87
89
|
'no-css-tagged-template-expression': noCssTaggedTemplateExpression,
|
|
@@ -114,7 +116,9 @@ export const rules = {
|
|
|
114
116
|
'no-physical-properties': noPhysicalProperties,
|
|
115
117
|
'no-separator-with-list-elements': noSeparatorWithListElements,
|
|
116
118
|
'no-styled-tagged-template-expression': noStyledTaggedTemplateExpression,
|
|
119
|
+
'no-to-match-snapshot': noToMatchSnapshot,
|
|
117
120
|
'no-unsafe-design-token-usage': noUnsafeDesignTokenUsage,
|
|
121
|
+
'no-unsafe-inline-snapshot': noUnsafeInlineSnapshot,
|
|
118
122
|
'no-unsafe-style-overrides': noUnsafeStyleOverrides,
|
|
119
123
|
'no-unsupported-drag-and-drop-libraries': noUnsupportedDragAndDropLibraries,
|
|
120
124
|
'no-unused-css-map': noUnusedCssMap,
|