Skip to content

fix(lint): correct camelcase rule docs for destructuring and named imports#3364

Open
bartlomieju wants to merge 1 commit into
mainfrom
fix-camelcase-docs-1324
Open

fix(lint): correct camelcase rule docs for destructuring and named imports#3364
bartlomieju wants to merge 1 commit into
mainfrom
fix-camelcase-docs-1324

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Addresses denoland/deno_lint#1324.

The camelcase rule docs list two snippets in the Invalid section that
are actually valid:

  • const { last_name } = obj1; — shorthand destructuring binds a local whose
    name is fixed by the source object property; the user has no control over it.
  • import { not_camelCased } from "external-module.js"; — a named import binds
    the exported name from the external module, likewise outside the user's
    control.

This matches the rule's documented note that it applies to imported/exported
variables but not to object properties of those variables, and reflects the
behaviour change in denoland/deno_lint#1187.

Verified against deno_lint main:

$ deno lint --rule camelcase
const obj1 = { last_name: "x" };       // flagged (object literal key) — stays Invalid
const { last_name } = obj1;            // no diagnostic — Valid
import { not_camelCased } from "...";   // no diagnostic — Valid

Only the object-literal key on line 1 is reported, confirming the two moved
snippets belong in the Valid section.

This supersedes the stale denoland/deno_lint#1325, which targeted the old
in-repo docs/rules/camelcase.md that was since removed when rule docs moved
to this repo.

…ports

Shorthand destructuring (`const { last_name } = obj1`) and named imports
(`import { not_camelCased }`) are valid under the camelcase rule, since the
identifier is determined by the source object/module and the user has no
control over it. Move both examples from the Invalid to the Valid section.

Verified against deno_lint main: `deno lint --rule camelcase` reports no
diagnostic for either form.

Fixes denoland/deno_lint#1324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant