diff options
author | Rich Trott <rtrott@gmail.com> | 2018-03-21 22:44:47 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-03-24 04:11:48 -0700 |
commit | 0863a0e528ba9ee01f960dce7ffebe8fff3a774c (patch) | |
tree | 37990f3af668c242ec1c4a9e24afd31b720ad96d /tools/node_modules/eslint/lib/rules/no-implicit-coercion.js | |
parent | 5e00a013eb219716d952cb8eb29a134c00f5db54 (diff) | |
download | android-node-v8-0863a0e528ba9ee01f960dce7ffebe8fff3a774c.tar.gz android-node-v8-0863a0e528ba9ee01f960dce7ffebe8fff3a774c.tar.bz2 android-node-v8-0863a0e528ba9ee01f960dce7ffebe8fff3a774c.zip |
tools: update ESLint to 4.19.1
A few bug fixes result in more stringent linting rules.
PR-URL: https://github.com/nodejs/node/pull/19528
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/no-implicit-coercion.js')
-rw-r--r-- | tools/node_modules/eslint/lib/rules/no-implicit-coercion.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js index 7efab83935..1dd4d431d7 100644 --- a/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js +++ b/tools/node_modules/eslint/lib/rules/no-implicit-coercion.js @@ -20,7 +20,6 @@ const ALLOWABLE_OPERATORS = ["~", "!!", "+", "*"]; * @returns {Object} The parsed and normalized option object. */ function parseOptions(options) { - options = options || {}; return { boolean: "boolean" in options ? Boolean(options.boolean) : true, number: "number" in options ? Boolean(options.number) : true, @@ -186,7 +185,7 @@ module.exports = { }, create(context) { - const options = parseOptions(context.options[0]); + const options = parseOptions(context.options[0] || {}); const sourceCode = context.getSourceCode(); /** @@ -197,8 +196,6 @@ module.exports = { * @returns {void} */ function report(node, recommendation, shouldFix) { - shouldFix = typeof shouldFix === "undefined" ? true : shouldFix; - context.report({ node, message: "use `{{recommendation}}` instead.", @@ -233,7 +230,7 @@ module.exports = { if (!operatorAllowed && options.boolean && isDoubleLogicalNegating(node)) { const recommendation = `Boolean(${sourceCode.getText(node.argument.argument)})`; - report(node, recommendation); + report(node, recommendation, true); } // ~foo.indexOf(bar) @@ -249,7 +246,7 @@ module.exports = { if (!operatorAllowed && options.number && node.operator === "+" && !isNumeric(node.argument)) { const recommendation = `Number(${sourceCode.getText(node.argument)})`; - report(node, recommendation); + report(node, recommendation, true); } }, @@ -264,7 +261,7 @@ module.exports = { if (nonNumericOperand) { const recommendation = `Number(${sourceCode.getText(nonNumericOperand)})`; - report(node, recommendation); + report(node, recommendation, true); } // "" + foo @@ -272,7 +269,7 @@ module.exports = { if (!operatorAllowed && options.string && isConcatWithEmptyString(node)) { const recommendation = `String(${sourceCode.getText(getNonEmptyOperand(node))})`; - report(node, recommendation); + report(node, recommendation, true); } }, @@ -285,7 +282,7 @@ module.exports = { const code = sourceCode.getText(getNonEmptyOperand(node)); const recommendation = `${code} = String(${code})`; - report(node, recommendation); + report(node, recommendation, true); } } }; |