Fix prefer-object-spread in src/language-js (part 1) (#7358)
This commit is contained in:
1 parent
c2430bf545
commit
751c134964
6 files changed
+12
-16
No files matched your search
@@ -222,7 +222,7 @@ function escapeTemplateCharacters(doc, raw) {
|
||||
}
|
||||
});
|
||||
|
||||
return Object.assign({}, currentDoc, { parts });
|
||||
return { ...currentDoc, parts };
|
||||
});
|
||||
}
|
||||
|
||||
@@ -305,9 +305,7 @@ function replacePlaceholders(quasisDoc, expressionDocs) {
|
||||
.concat(["${", expression, "}" + suffix])
|
||||
.concat(rest);
|
||||
}
|
||||
return Object.assign({}, doc, {
|
||||
parts
|
||||
});
|
||||
return { ...doc, parts };
|
||||
});
|
||||
|
||||
return expressions.length === replaceCounter ? newDoc : null;
|
||||
|
||||
@@ -10,14 +10,11 @@ function createParser(_parse) {
|
||||
type: "NGRoot",
|
||||
node:
|
||||
options.parser === "__ng_action" && node.type !== "NGChainedExpression"
|
||||
? Object.assign({}, node, {
|
||||
type: "NGChainedExpression",
|
||||
expressions: [node]
|
||||
})
|
||||
? { ...node, type: "NGChainedExpression", expressions: [node] }
|
||||
: node
|
||||
};
|
||||
};
|
||||
return Object.assign({ astFormat: "estree", parse }, locFns);
|
||||
return { astFormat: "estree", parse, ...locFns };
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -28,12 +28,12 @@ function parse(text, parsers, opts) {
|
||||
}
|
||||
|
||||
includeShebang(text, ast);
|
||||
return postprocess(ast, Object.assign({}, opts, { originalText: text }));
|
||||
return postprocess(ast, { ...opts, originalText: text });
|
||||
}
|
||||
|
||||
// Export as a plugin so we can reuse the same bundle for UMD loading
|
||||
module.exports = {
|
||||
parsers: {
|
||||
flow: Object.assign({ parse, astFormat: "estree", hasPragma }, locFns)
|
||||
flow: { parse, astFormat: "estree", hasPragma, ...locFns }
|
||||
}
|
||||
};
|
||||
@@ -31,7 +31,7 @@ function parse(text, parsers, opts) {
|
||||
}
|
||||
|
||||
includeShebang(text, ast);
|
||||
return postprocess(ast, Object.assign({}, opts, { originalText: text }));
|
||||
return postprocess(ast, { ...opts, originalText: text });
|
||||
}
|
||||
|
||||
function tryParseTypeScript(text, jsx) {
|
||||
@@ -59,7 +59,7 @@ function isProbablyJsx(text) {
|
||||
).test(text);
|
||||
}
|
||||
|
||||
const parser = Object.assign({ parse, astFormat: "estree", hasPragma }, locFns);
|
||||
const parser = { parse, astFormat: "estree", hasPragma, ...locFns };
|
||||
|
||||
// Export as a plugin so we can reuse the same bundle for UMD loading
|
||||
module.exports = {
|
||||
|
||||
@@ -9,7 +9,7 @@ function hasPragma(text) {
|
||||
|
||||
function insertPragma(text) {
|
||||
const parsedDocblock = docblock.parseWithComments(docblock.extract(text));
|
||||
const pragmas = Object.assign({ format: "" }, parsedDocblock.pragmas);
|
||||
const pragmas = { format: "", ...parsedDocblock.pragmas };
|
||||
const newDocblock = docblock
|
||||
.print({
|
||||
pragmas,
|
||||
|
||||
@@ -7,12 +7,13 @@ function preprocess(ast, options) {
|
||||
case "json-stringify":
|
||||
case "__js_expression":
|
||||
case "__vue_expression":
|
||||
return Object.assign({}, ast, {
|
||||
return {
|
||||
...ast,
|
||||
type: options.parser.startsWith("__") ? "JsExpressionRoot" : "JsonRoot",
|
||||
node: ast,
|
||||
comments: [],
|
||||
rootMarker: options.rootMarker
|
||||
});
|
||||
};
|
||||
default:
|
||||
return ast;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user