Skip to content

Commit

Permalink
Merge pull request #863 from czosel/eslint-braces
Browse files Browse the repository at this point in the history
chore(linting): enable "braces" eslint rule
  • Loading branch information
czosel authored Feb 5, 2022
2 parents 1923420 + 469b0f1 commit 3960bea
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 32 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
"prefer-const": "error",
"no-var": "error",
"prettier/prettier": "error",
curly: ["error", "multi-line"],
},
overrides: [
{
Expand Down
96 changes: 64 additions & 32 deletions src/parser/expr.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,85 @@ module.exports = {
expr = this.read_expr_item();
}
// binary operations
if (this.token === "|")
if (this.token === "|") {
return result("bin", "|", expr, this.next().read_expr());
if (this.token === "&")
}
if (this.token === "&") {
return result("bin", "&", expr, this.next().read_expr());
if (this.token === "^")
}
if (this.token === "^") {
return result("bin", "^", expr, this.next().read_expr());
if (this.token === ".")
}
if (this.token === ".") {
return result("bin", ".", expr, this.next().read_expr());
if (this.token === "+")
}
if (this.token === "+") {
return result("bin", "+", expr, this.next().read_expr());
if (this.token === "-")
}
if (this.token === "-") {
return result("bin", "-", expr, this.next().read_expr());
if (this.token === "*")
}
if (this.token === "*") {
return result("bin", "*", expr, this.next().read_expr());
if (this.token === "/")
}
if (this.token === "/") {
return result("bin", "/", expr, this.next().read_expr());
if (this.token === "%")
}
if (this.token === "%") {
return result("bin", "%", expr, this.next().read_expr());
if (this.token === this.tok.T_POW)
}
if (this.token === this.tok.T_POW) {
return result("bin", "**", expr, this.next().read_expr());
if (this.token === this.tok.T_SL)
}
if (this.token === this.tok.T_SL) {
return result("bin", "<<", expr, this.next().read_expr());
if (this.token === this.tok.T_SR)
}
if (this.token === this.tok.T_SR) {
return result("bin", ">>", expr, this.next().read_expr());
}
// more binary operations (formerly bool)
if (this.token === this.tok.T_BOOLEAN_OR)
if (this.token === this.tok.T_BOOLEAN_OR) {
return result("bin", "||", expr, this.next().read_expr());
if (this.token === this.tok.T_LOGICAL_OR)
}
if (this.token === this.tok.T_LOGICAL_OR) {
return result("bin", "or", expr, this.next().read_expr());
if (this.token === this.tok.T_BOOLEAN_AND)
}
if (this.token === this.tok.T_BOOLEAN_AND) {
return result("bin", "&&", expr, this.next().read_expr());
if (this.token === this.tok.T_LOGICAL_AND)
}
if (this.token === this.tok.T_LOGICAL_AND) {
return result("bin", "and", expr, this.next().read_expr());
if (this.token === this.tok.T_LOGICAL_XOR)
}
if (this.token === this.tok.T_LOGICAL_XOR) {
return result("bin", "xor", expr, this.next().read_expr());
if (this.token === this.tok.T_IS_IDENTICAL)
}
if (this.token === this.tok.T_IS_IDENTICAL) {
return result("bin", "===", expr, this.next().read_expr());
if (this.token === this.tok.T_IS_NOT_IDENTICAL)
}
if (this.token === this.tok.T_IS_NOT_IDENTICAL) {
return result("bin", "!==", expr, this.next().read_expr());
if (this.token === this.tok.T_IS_EQUAL)
}
if (this.token === this.tok.T_IS_EQUAL) {
return result("bin", "==", expr, this.next().read_expr());
if (this.token === this.tok.T_IS_NOT_EQUAL)
}
if (this.token === this.tok.T_IS_NOT_EQUAL) {
return result("bin", "!=", expr, this.next().read_expr());
if (this.token === "<")
}
if (this.token === "<") {
return result("bin", "<", expr, this.next().read_expr());
if (this.token === ">")
}
if (this.token === ">") {
return result("bin", ">", expr, this.next().read_expr());
if (this.token === this.tok.T_IS_SMALLER_OR_EQUAL)
}
if (this.token === this.tok.T_IS_SMALLER_OR_EQUAL) {
return result("bin", "<=", expr, this.next().read_expr());
if (this.token === this.tok.T_IS_GREATER_OR_EQUAL)
}
if (this.token === this.tok.T_IS_GREATER_OR_EQUAL) {
return result("bin", ">=", expr, this.next().read_expr());
if (this.token === this.tok.T_SPACESHIP)
}
if (this.token === this.tok.T_SPACESHIP) {
return result("bin", "<=>", expr, this.next().read_expr());
}
if (this.token === this.tok.T_INSTANCEOF) {
expr = result(
"bin",
Expand All @@ -89,8 +115,9 @@ module.exports = {

// extra operations :
// $username = $_GET['user'] ?? 'nobody';
if (this.token === this.tok.T_COALESCE)
if (this.token === this.tok.T_COALESCE) {
return result("bin", "??", expr, this.next().read_expr());
}

// extra operations :
// $username = $_GET['user'] ? true : false;
Expand Down Expand Up @@ -228,14 +255,18 @@ module.exports = {
let result,
expr,
attrs = [];
if (this.token === "+")
if (this.token === "+") {
return this.node("unary")("+", this.next().read_expr());
if (this.token === "-")
}
if (this.token === "-") {
return this.node("unary")("-", this.next().read_expr());
if (this.token === "!")
}
if (this.token === "!") {
return this.node("unary")("!", this.next().read_expr());
if (this.token === "~")
}
if (this.token === "~") {
return this.node("unary")("~", this.next().read_expr());
}

if (this.token === "(") {
expr = this.next().read_expr();
Expand Down Expand Up @@ -307,8 +338,9 @@ module.exports = {
attrs = this.read_attr_list();
}

if (this.token === this.tok.T_CLONE)
if (this.token === this.tok.T_CLONE) {
return this.node("clone")(this.next().read_expr());
}

switch (this.token) {
case this.tok.T_INC:
Expand Down

0 comments on commit 3960bea

Please sign in to comment.