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

quotemark config option ordering matters? #3063

Closed
ArgonAlex opened this issue Jul 21, 2017 · 3 comments
Closed

quotemark config option ordering matters? #3063

ArgonAlex opened this issue Jul 21, 2017 · 3 comments

Comments

@ArgonAlex
Copy link

ArgonAlex commented Jul 21, 2017

Bug Report

  • TSLint version: 5.5.0
  • TypeScript version: 2.4.2
  • Running TSLint via: tslint-language-service in VSCode

TypeScript code being linted

let k = "blah";

with tslint.json configuration:

{
  "rules": {
    "quotemark": [
      true,
      "avoid-template",
      "single"
    ]
  }
}

Actual behavior

no error

Expected behavior

" should be ' (quotemark) error

If I put "single" after true in the config array, then it works. I tested rearranging the other possible config options like "jsx-double", and those all seem to work regardless of order, but as soon as "single" is not the first config option, the entire rule stops working.

Is this by design or a bug? I couldn't see any documentation on the ordering of config options mattering. Could this be affecting other rules too? I ordered all of my config options alphabetically because I assumed order wouldn't matter.

@ArgonAlex
Copy link
Author

Welp found the place in the code is explicitly checking the first value of the config options: https://github.com/palantir/tslint/blob/master/src/rules/quotemarkRule.ts#L78-L85

I would have seen the error too if I was not using tslint-language-service, but Typescript doesn't yet support logging from plugins for end users. Although, this should probably be mentioned in the rule documentation.

@ajafff
Copy link
Contributor

ajafff commented Jul 23, 2017

You're right, this rule expects "single" or "double" to be the first option.
That should at least be documented.

#889 also tracks validating the config to show an error in such cases.

@aervin
Copy link
Contributor

aervin commented Aug 3, 2017

Would it be better if we searched through argument list to find OPTION_SINGLE or OPTION_DOUBLE and throw error if no such argument provided? This way, argument order is irrelevant.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants