]> git.proxmox.com Git - pve-eslint.git/blobdiff - eslint/lib/rules/camelcase.js
import 8.23.1 source
[pve-eslint.git] / eslint / lib / rules / camelcase.js
index 61dd062edea4ecb31ddb29d7fad4437c09b0f284..ee1b6bf598d31e89f09252b8e066574a91a25009 100644 (file)
@@ -5,6 +5,12 @@
 
 "use strict";
 
+//------------------------------------------------------------------------------
+// Requirements
+//------------------------------------------------------------------------------
+
+const astUtils = require("./utils/ast-utils");
+
 //------------------------------------------------------------------------------
 // Rule Definition
 //------------------------------------------------------------------------------
@@ -15,7 +21,7 @@ module.exports = {
         type: "suggestion",
 
         docs: {
-            description: "enforce camelcase naming convention",
+            description: "Enforce camelcase naming convention",
             recommended: false,
             url: "https://eslint.org/docs/rules/camelcase"
         },
@@ -140,7 +146,7 @@ module.exports = {
 
         /**
          * 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.
@@ -155,7 +161,7 @@ module.exports = {
             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" &&
@@ -165,7 +171,7 @@ module.exports = {
                 case "ImportSpecifier":
                     return (
                         parent.local === node &&
-                        parent.imported.name === localName
+                        astUtils.getModuleExportName(parent.imported) === localName
                     );
 
                 default: