summaryrefslogtreecommitdiff
path: root/tools/node_modules/eslint/lib/rules/camelcase.js
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-11-22 14:17:22 -0500
committercjihrig <cjihrig@gmail.com>2019-11-25 11:55:40 -0500
commit90fb308de42575adeed82d864da57148049185b3 (patch)
tree79d362bf7f18f1088da78b8b3073252b059b7c3f /tools/node_modules/eslint/lib/rules/camelcase.js
parent02d4c742369975fd7499bb242be61bbb1f8fc1ab (diff)
downloadandroid-node-v8-90fb308de42575adeed82d864da57148049185b3.tar.gz
android-node-v8-90fb308de42575adeed82d864da57148049185b3.tar.bz2
android-node-v8-90fb308de42575adeed82d864da57148049185b3.zip
tools: update ESLint to 6.7.1
Update ESLint to 6.7.1 PR-URL: https://github.com/nodejs/node/pull/30598 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/lib/rules/camelcase.js')
-rw-r--r--tools/node_modules/eslint/lib/rules/camelcase.js25
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/node_modules/eslint/lib/rules/camelcase.js b/tools/node_modules/eslint/lib/rules/camelcase.js
index cdc16fab9f..a06c7f9404 100644
--- a/tools/node_modules/eslint/lib/rules/camelcase.js
+++ b/tools/node_modules/eslint/lib/rules/camelcase.js
@@ -28,6 +28,10 @@ module.exports = {
type: "boolean",
default: false
},
+ ignoreImports: {
+ type: "boolean",
+ default: false
+ },
properties: {
enum: ["always", "never"]
},
@@ -56,6 +60,7 @@ module.exports = {
const options = context.options[0] || {};
let properties = options.properties || "";
const ignoreDestructuring = options.ignoreDestructuring;
+ const ignoreImports = options.ignoreImports;
const allow = options.allow || [];
if (properties !== "always" && properties !== "never") {
@@ -79,7 +84,7 @@ module.exports = {
function isUnderscored(name) {
// if there's an underscore, it might be A_CONSTANT, which is okay
- return name.indexOf("_") > -1 && name !== name.toUpperCase();
+ return name.includes("_") && name !== name.toUpperCase();
}
/**
@@ -89,9 +94,9 @@ module.exports = {
* @private
*/
function isAllowed(name) {
- return allow.findIndex(
+ return allow.some(
entry => name === entry || name.match(new RegExp(entry, "u"))
- ) !== -1;
+ );
}
/**
@@ -127,7 +132,7 @@ module.exports = {
* @private
*/
function report(node) {
- if (reported.indexOf(node) < 0) {
+ if (!reported.includes(node)) {
reported.push(node);
context.report({ node, messageId: "notCamelCase", data: { name: node.name } });
}
@@ -209,10 +214,18 @@ module.exports = {
}
// Check if it's an import specifier
- } else if (["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"].indexOf(node.parent.type) >= 0) {
+ } else if (["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"].includes(node.parent.type)) {
+
+ if (node.parent.type === "ImportSpecifier" && ignoreImports) {
+ return;
+ }
// Report only if the local imported identifier is underscored
- if (node.parent.local && node.parent.local.name === node.name && nameIsUnderscored) {
+ if (
+ node.parent.local &&
+ node.parent.local.name === node.name &&
+ nameIsUnderscored
+ ) {
report(node);
}