Skip to content

Commit

Permalink
use - -
Browse files Browse the repository at this point in the history
  • Loading branch information
gurgunday committed Dec 13, 2023
1 parent fe7e048 commit 5531723
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/src/rules/no-implicit-coercion.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ This rule has three main options and one override option to allow some coercions
* `"number"` (`true` by default) - When this is `true`, this rule warns shorter type conversions for `number` type.
* `"string"` (`true` by default) - When this is `true`, this rule warns shorter type conversions for `string` type.
* `"disallowTemplateShorthand"` (`false` by default) - When this is `true`, this rule warns `string` type conversions using `${expression}` form.
* `"allow"` (`empty` by default) - Each entry in this array can be one of `~`, `!!`, `+`, `-(-)`, `-`, or `*` that are to be allowed.
* `"allow"` (`empty` by default) - Each entry in this array can be one of `~`, `!!`, `+`, `- -`, `-`, or `*` that are to be allowed.

Note that operator `+` in `allow` list would allow `+foo` (number coercion) as well as `"" + foo` (string coercion).

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-implicit-coercion.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------

const INDEX_OF_PATTERN = /^(?:i|lastI)ndexOf$/u;
const ALLOWABLE_OPERATORS = ["~", "!!", "+", "-(-)", "-", "*"];
const ALLOWABLE_OPERATORS = ["~", "!!", "+", "- -", "-", "*"];

/**
* Parses and normalizes an option object.
Expand Down Expand Up @@ -302,7 +302,7 @@ module.exports = {
}

// -(-foo)
operatorAllowed = options.allow.includes("-(-)");
operatorAllowed = options.allow.includes("- -");
if (!operatorAllowed && node.operator === "-" && node.argument.type === "UnaryExpression" && node.argument.operator === "-") {
const recommendation = `Number(${sourceCode.getText(node.argument.argument)})`;

Expand Down

0 comments on commit 5531723

Please sign in to comment.