Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Rewrite and fix object-literal-key-quotes #2515

Merged
merged 1 commit into from
Apr 12, 2017
Merged

Rewrite and fix object-literal-key-quotes #2515

merged 1 commit into from
Apr 12, 2017

Conversation

ajafff
Copy link
Contributor

@ajafff ajafff commented Apr 6, 2017

PR checklist

  • Addresses an existing issue: #0000
  • New feature, bugfix, or enhancement
    • Includes tests
  • Documentation update

Overview of change:

[bugfix] object-literal-key-quotes: does no longer require quotes for property names containing digits
[bugfix] object-literal-key-quotes: correctly stringify numbers when fixing

Is there anything you'd like reviewers to focus on?

Copy link
Contributor

@adidahiya adidahiya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to resolve merge conflicts (likely due to #2527)

yarn.lock Outdated
version "1.4.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.4.0.tgz#84f8a83df9967d35bf1ff3aa48c7339593d64e19"

tsutils@^1.6.0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh, let's try to de-dupe this entry again? not sure if it matters though

@@ -6,8 +6,8 @@ const o = {
"hyphens-need-quotes": null,
[computed]: 456,
"123": "hello", // failure
"1e4": "something", // failure
".123": "float", // failure
"10000": "something", // failure
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does the fix replacement know to expand 1e4 to 1000?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1e4 is a numeric literal that is automatically expanded to 1000 by the javascript vm before stringifying. Fixing this to "1e4" would actually break the program.

> Object.keys({1e4: "foo"})
[ '10000' ]
> String(1e4)==="10000"
true

[bugfix] `object-literal-key-quotes`: does no longer require quotes for reserved words and property names containing digits
[bugfix] `object-literal-key-quotes`: correctly stringify numbers when fixing
@ajafff
Copy link
Contributor Author

ajafff commented Apr 12, 2017

@adidahiya rebased and resolved merge conflicts

@adidahiya adidahiya merged commit f824dd0 into palantir:master Apr 12, 2017
@adidahiya adidahiya added this to the TSLint v5.2 milestone Apr 12, 2017
@ajafff ajafff deleted the object-literal-key-quotes branch April 12, 2017 20:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants