Function / Method Naming

ID

javascript.naming_method

Severity

low

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Naming Convention

Language

JavaScript

Tags

naming

Description

Reports function and method names that do not follow the lowerCamelCase convention:

function process_user(u) { ... }     // FLAW — snake_case
function ProcessUser(u) { ... }      // FLAW — PascalCase looks like a constructor
function processUser(u) { ... }      // OK

Rationale

The JavaScript and TypeScript ecosystems agree on lowerCamelCase for callable names. Deviations confuse readers (ProcessUser looks like a class, process_user looks like a snake_case constant) and break tool expectations:

  • IDE rename / refactor heuristics treat PascalCase callables as classes,

  • serialisation libraries map somePropertysome_property automatically; mixed casing breaks that mapping,

  • test frameworks display method names as report headings — readability matters.

Remediation

Rename to lowerCamelCase:

function processUser(u) { ... }
class Service {
  loadData() { ... }
}

Notes

The rule covers all named callables: function declarations, function expressions, async functions, generators, and methods on classes / object literals. Constructors (constructor()), getters (get foo()), and setters (set foo(v)) are skipped — their names are dictated by the language, not the developer. Arrow functions are also skipped here; their assigned binding name is checked elsewhere.