"use strict";
+//------------------------------------------------------------------------------
+// Requirements
+//------------------------------------------------------------------------------
+
+const astUtils = require("./utils/ast-utils");
+
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
type: "suggestion",
docs: {
- description: "enforce camelcase naming convention",
+ description: "Enforce camelcase naming convention",
recommended: false,
url: "https://eslint.org/docs/rules/camelcase"
},
/**
* Checks if a given binding identifier uses the original name as-is.
- * - If it's in object destructuring, the original name is its property name.
+ * - If it's in object destructuring or object expression, the original name is its property name.
* - If it's in import declaration, the original name is its exported name.
* @param {ASTNode} node The `Identifier` node to check.
* @returns {boolean} `true` if the identifier uses the original name as-is.
switch (parent.type) {
case "Property":
return (
- parent.parent.type === "ObjectPattern" &&
+ (parent.parent.type === "ObjectPattern" || parent.parent.type === "ObjectExpression") &&
parent.value === valueNode &&
!parent.computed &&
parent.key.type === "Identifier" &&
case "ImportSpecifier":
return (
parent.local === node &&
- parent.imported.name === localName
+ astUtils.getModuleExportName(parent.imported) === localName
);
default: