commonmark / commonmark/commonmark.js

Don't use javascript reserved word as Object keys

Open
#154 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.6k
Forks
231
Avg merge
2d 11h
Merged PRs (30d)
3

Description

Hi,

I have observed the block.js file makes use of javascript keywords as objects keys. Ref: here.

Although this isn't prohibited, it isn't the correct thing to do.

  • Editors highlight is wrongly
  • Code minifiers have trouble with them.

Its best to not use them at all, in this scenarios it can be named as proceed. i.e the function returns. If that's not possible, at least you can quote them as below.

from

var object  = {
  continue: function(){}
}

object.continue();

to

var object  = {
  'continue': function(){}
}
object['continue']()

Please let me know how you wish to address this, I'll submit a PR with the changes.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at lib/blocks.js around line 223 and inspect the object keys that use JavaScript reserved words. Check whether the affected keys can use the suggested naming or quoted access without changing parser behavior. The work is done when reserved-word keys in this area are addressed and the existing project checks pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.