Enable arrow-body-style rule (#9918)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-12-17 14:31:51 +08:00
1 parent df8eef0013
commit 0fd2a28cff
14 files changed
+74 -89

No files matched your search

+3
View File
@@ -13,6 +13,9 @@ plugins:
settings:
import/internal-regex: ^linguist-languages/
rules:
arrow-body-style:
- error
- as-needed
curly: error
dot-notation: error
eqeqeq:
+5 -5
View File
@@ -427,16 +427,16 @@ function lastLineHasInlineComment(text) {
function stringifyNode(node) {
if (node.groups) {
const open = node.open && node.open.value ? node.open.value : "";
const groups = node.groups.reduce((previousValue, currentValue, index) => {
return (
const groups = node.groups.reduce(
(previousValue, currentValue, index) =>
previousValue +
stringifyNode(currentValue) +
(node.groups[0].type === "comma_group" &&
index !== node.groups.length - 1
? ","
: "")
);
}, "");
: ""),
""
);
const close = node.close && node.close.value ? node.close.value : "";
return open + groups + close;
+8 -13
View File
@@ -440,19 +440,14 @@ function addIsSpaceSensitive(ast, options) {
return node.clone({
children: node.children
.map((child) => {
return {
...child,
isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode(
child,
options
),
isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode(
child,
options
),
};
})
.map((child) => ({
...child,
isLeadingSpaceSensitive: isLeadingSpaceSensitiveNode(child, options),
isTrailingSpaceSensitive: isTrailingSpaceSensitiveNode(
child,
options
),
}))
.map((child, index, children) => ({
...child,
isLeadingSpaceSensitive:
+11 -5
View File
@@ -12,11 +12,17 @@ function format(path, print, textToDoc) {
// Get full template literal with expressions replaced by placeholders
const rawQuasis = node.quasis.map((q) => q.value.raw);
let placeholderID = 0;
const text = rawQuasis.reduce((prevVal, currVal, idx) => {
return idx === 0
? currVal
: prevVal + "@prettier-placeholder-" + placeholderID++ + "-id" + currVal;
}, "");
const text = rawQuasis.reduce(
(prevVal, currVal, idx) =>
idx === 0
? currVal
: prevVal +
"@prettier-placeholder-" +
placeholderID++ +
"-id" +
currVal,
""
);
const doc = textToDoc(
text,
{ parser: "scss" },
+1 -3
View File
@@ -109,9 +109,7 @@ function printTypeParameter(path, options, print) {
if (parent.nameType) {
parts.push(
" as ",
path.callParent((path) => {
return path.call(print, "nameType");
})
path.callParent((path) => path.call(print, "nameType"))
);
}
parts.push("]");
+1 -3
View File
@@ -563,9 +563,7 @@ function printPathNoParens(path, options, print, args) {
case "ConditionalExpression":
return printTernary(path, options, print);
case "VariableDeclaration": {
const printed = path.map((childPath) => {
return print(childPath);
}, "declarations");
const printed = path.map((childPath) => print(childPath), "declarations");
// We generally want to terminate all variable declarations with a
// semicolon, except when they in the () part of for loops.
+2 -3
View File
@@ -46,9 +46,8 @@ const tokenizeEsSyntax = (eat, value) => {
};
/* istanbul ignore next */
tokenizeEsSyntax.locator = (value /*, fromIndex*/) => {
return isExport(value) || isImport(value) ? -1 : 1;
};
tokenizeEsSyntax.locator = (value /*, fromIndex*/) =>
isExport(value) || isImport(value) ? -1 : 1;
function esSyntax() {
const { Parser } = this;
+3 -4
View File
@@ -422,11 +422,10 @@ function genericPrint(path, options, print) {
align(
" ".repeat(4),
printChildren(path, options, print, {
processor: (childPath, index) => {
return index === 0
processor: (childPath, index) =>
index === 0
? group(concat([softline, childPath.call(print)]))
: childPath.call(print);
},
: childPath.call(print),
})
),
nextNode && nextNode.type === "footnoteDefinition"
+3 -3
View File
@@ -213,9 +213,9 @@ function mapAst(ast, handler) {
const newNode = { ...handler(node, index, parentStack) };
if (newNode.children) {
newNode.children = newNode.children.map((child, index) => {
return preorder(child, index, [newNode].concat(parentStack));
});
newNode.children = newNode.children.map((child, index) =>
preorder(child, index, [newNode].concat(parentStack))
);
}
return newNode;
+4 -6
View File
@@ -166,13 +166,11 @@ function optionInfoToSchema(optionInfo, { isCLI, optionInfos }) {
}
if (optionInfo.exception) {
parameters.validate = (value, schema, utils) => {
return optionInfo.exception(value) || schema.validate(value, utils);
};
parameters.validate = (value, schema, utils) =>
optionInfo.exception(value) || schema.validate(value, utils);
} else {
parameters.validate = (value, schema, utils) => {
return value === undefined || schema.validate(value, utils);
};
parameters.validate = (value, schema, utils) =>
value === undefined || schema.validate(value, utils);
}
/* istanbul ignore next */
@@ -79,11 +79,10 @@ describe("CLI overrides take precedence", () => {
});
});
test("API resolveConfig with no args", () => {
return prettier.resolveConfig().then((result) => {
test("API resolveConfig with no args", () =>
prettier.resolveConfig().then((result) => {
expect(result).toEqual({});
});
});
}));
test("API resolveConfig.sync with no args", () => {
expect(prettier.resolveConfig.sync()).toEqual({});
+24 -30
View File
@@ -45,32 +45,30 @@ function Tidelift() {
);
}
const HomeSplash = (props) => {
return (
<div className="homeContainer">
<Tidelift />
<div className="homeSplashFade">
<div className="wrapper homeWrapper">
<div className="animatedLogoWrapper">
<AnimatedLogo version="wide" />
</div>
<div className="inner">
<div className="section promoSection">
<div className="promoRow">
<div className="pluginRowBlock">
<Button href="/playground/">Try It Online</Button>&nbsp;
<Button href={"/docs/" + props.language + "/install.html"}>
Install Prettier
</Button>
</div>
const HomeSplash = (props) => (
<div className="homeContainer">
<Tidelift />
<div className="homeSplashFade">
<div className="wrapper homeWrapper">
<div className="animatedLogoWrapper">
<AnimatedLogo version="wide" />
</div>
<div className="inner">
<div className="section promoSection">
<div className="promoRow">
<div className="pluginRowBlock">
<Button href="/playground/">Try It Online</Button>&nbsp;
<Button href={"/docs/" + props.language + "/install.html"}>
Install Prettier
</Button>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
</div>
);
HomeSplash.propTypes = {
language: PropTypes.string,
@@ -242,16 +240,12 @@ const EditorSupportSection = () => (
const UsersSection = ({ language }) => {
const showcase = siteConfig.users
.filter((user) => {
return user.pinned;
})
.map((user, i) => {
return (
<a key={i} className="growOnHover alignCenter" href={user.infoLink}>
<img className="user" src={user.greyImage} title={user.caption} />
</a>
);
});
.filter((user) => user.pinned)
.map((user, i) => (
<a key={i} className="growOnHover alignCenter" href={user.infoLink}>
<img className="user" src={user.greyImage} title={user.caption} />
</a>
));
return (
<div className="usersSection productShowcaseSection">
+5 -7
View File
@@ -7,13 +7,11 @@ const siteConfig = require(process.cwd() + "/siteConfig.js");
class Users extends React.Component {
render() {
const showcase = siteConfig.users.map((user, i) => {
return (
<a key={i} href={user.infoLink}>
<img src={user.image} title={user.caption} />
</a>
);
});
const showcase = siteConfig.users.map((user, i) => (
<a key={i} href={user.infoLink}>
<img src={user.image} title={user.caption} />
</a>
));
return (
<div>
+1 -3
View File
@@ -27,9 +27,7 @@ function formatMarkdown(
isIdempotent ? [] : ["", "**Second Output:**", codeBlock(output2, syntax)]
)
.concat(full ? ["", "**Expected behavior:**", ""] : [])
.filter((part) => {
return part != null;
})
.filter((part) => part != null)
.join("\n");
}