Enforce braces after `if`/etc (#1719)
See https://github.com/prettier/prettier/pull/1718#discussion_r118382742master
parent
a6068c0532
commit
7344a37b5c
|
@ -8,6 +8,7 @@ module.exports = {
|
||||||
extends: ["eslint:recommended"],
|
extends: ["eslint:recommended"],
|
||||||
plugins: ["prettier"],
|
plugins: ["prettier"],
|
||||||
rules: {
|
rules: {
|
||||||
|
curly: "error",
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
"no-inner-declarations": "off",
|
"no-inner-declarations": "off",
|
||||||
"no-var": "error",
|
"no-var": "error",
|
||||||
|
|
|
@ -27,8 +27,9 @@ FastPath.from = function(obj) {
|
||||||
// lightweight FastPath [..., name, value] stacks.
|
// lightweight FastPath [..., name, value] stacks.
|
||||||
const copy = Object.create(FastPath.prototype);
|
const copy = Object.create(FastPath.prototype);
|
||||||
const stack = [obj.value];
|
const stack = [obj.value];
|
||||||
for (let pp; (pp = obj.parentPath); obj = pp)
|
for (let pp; (pp = obj.parentPath); obj = pp) {
|
||||||
stack.push(obj.name, pp.value);
|
stack.push(obj.name, pp.value);
|
||||||
|
}
|
||||||
copy.stack = stack.reverse();
|
copy.stack = stack.reverse();
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1369,9 +1369,10 @@ function genericPrintNoParens(path, options, print, args) {
|
||||||
case "CatchClause":
|
case "CatchClause":
|
||||||
parts.push("catch (", path.call(print, "param"));
|
parts.push("catch (", path.call(print, "param"));
|
||||||
|
|
||||||
if (n.guard)
|
if (n.guard) {
|
||||||
// Note: esprima does not recognize conditional catch clauses.
|
// Note: esprima does not recognize conditional catch clauses.
|
||||||
parts.push(" if ", path.call(print, "guard"));
|
parts.push(" if ", path.call(print, "guard"));
|
||||||
|
}
|
||||||
|
|
||||||
parts.push(") ", path.call(print, "body"));
|
parts.push(") ", path.call(print, "body"));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function isExportDeclaration(node) {
|
function isExportDeclaration(node) {
|
||||||
if (node)
|
if (node) {
|
||||||
switch (node.type) {
|
switch (node.type) {
|
||||||
case "ExportDeclaration":
|
case "ExportDeclaration":
|
||||||
case "ExportDefaultDeclaration":
|
case "ExportDefaultDeclaration":
|
||||||
|
@ -11,6 +11,7 @@ function isExportDeclaration(node) {
|
||||||
case "ExportAllDeclaration":
|
case "ExportAllDeclaration":
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue