fix(lint): correct camelcase rule docs for destructuring and named imports#3364
Open
bartlomieju wants to merge 1 commit into
Open
fix(lint): correct camelcase rule docs for destructuring and named imports#3364bartlomieju wants to merge 1 commit into
bartlomieju wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses denoland/deno_lint#1324.
The
camelcaserule docs list two snippets in the Invalid section thatare actually valid:
const { last_name } = obj1;— shorthand destructuring binds a local whosename is fixed by the source object property; the user has no control over it.
import { not_camelCased } from "external-module.js";— a named import bindsthe 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: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.mdthat was since removed when rule docs movedto this repo.