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

Add fix for object-literal-key-quotes #1953

Merged
merged 1 commit into from Jan 1, 2017

Conversation

andy-hanson
Copy link
Contributor

PR checklist

What changes did you make?

Added fixes for object-literal-key-quotes (except in consistent mode, where a fix would be ambiguous).

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

This always uses double quotes. Might it be possible to peer into the setting for quotemark and choose quotes accordingly?

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 1, 2017

I'm interested to know how rules can know about other rule's options

@nchen63
Copy link
Contributor

nchen63 commented Jan 1, 2017

I don't think we want to encourage rules looking at the options of a different rule. I'm fine with the fix using double quotes since most people use double quotes, and the quotemark fixer is likely to come after object-literal-key-quotes and fix the quote type anyways.

@nchen63 nchen63 merged commit b7741b0 into palantir:master Jan 1, 2017
@nchen63
Copy link
Contributor

nchen63 commented Jan 1, 2017

@andy-hanson thanks!

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 1, 2017

I think allowing quote preference as an option would be nice. Might work on a pr today

@mohsen1
Copy link
Contributor

mohsen1 commented Jan 1, 2017

Actually if quote rule fix come after this fix it will fix it.

I suggest making sure the recommended config has the right order of these two rules

@ajafff
Copy link
Contributor

ajafff commented Jan 2, 2017

the quotemark fixer is likely to come after object-literal-key-quotes and fix the quote type anyways.

@nchen63 how is that possible? They operate on the same AST so the order doesn't matter, as the quotemark rule wont see the quotes added by object-literal-key-quotes until the next run.

With --fix linting is run twice - second run without fixing -, if there were fixes. The quotes would only be reported as lint errors but are not fixed.

@nchen63
Copy link
Contributor

nchen63 commented Jan 2, 2017

@ajafff The AST is reloaded each time fixes are made. See linter.ts, line 121.

If it didn't reload, then 2 different fixes would incorrectly be applied since fixes are position based and fix 1 could later offsets to be different than expected.

@andy-hanson andy-hanson deleted the object_key_fix branch January 2, 2017 17:40
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.

None yet

4 participants