MCPcopy Create free account
hub / github.com/ampproject/amphtml / fix

Function fix

build-system/eslint-rules/prefer-unnested-spread-objects.js:54–73  ·  view source on GitHub ↗
(fixer)

Source from the content-addressed store, hash-verified

52 message: 'Nesting an object under an object spread is not useful',
53
54 fix(fixer) {
55 const {parent, properties} = node;
56 const texts = properties.map((prop) => sourceCode.getText(prop));
57
58 if (texts.length > 0) {
59 return fixer.replaceText(node.parent, texts.join(','));
60 }
61
62 const grandParent = parent.parent;
63 const next = findAfter(grandParent.properties, parent);
64
65 if (next) {
66 return fixer.removeRange([parent.range[0], next.range[0] - 1]);
67 }
68
69 return fixer.removeRange([
70 parent.range[0],
71 grandParent.range[1] - 1,
72 ]);
73 },
74 });
75 },
76 };

Callers

nothing calls this directly

Calls 1

findAfterFunction · 0.85

Tested by

no test coverage detected