Tslint: quotemark rule should not apply to JSON files

Created on 1 Aug 2018  路  5Comments  路  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.11.0
  • __TypeScript version__: 3.0.1
  • __Running TSLint via__: CLI

TypeScript code being linted

sample.ts

// TypeScript now allows you to import JSON files
import data from 'data.json';
console.log(data)

data.json

{
    "foo": "bar"
}

tslint.yaml

rules:
  quotemark:
    - true
    - single

Actual behavior

When running tslint --fix, the double quotes in the data.json file are replaced with single-quotes due to the quotemark rule. But single-quotes are not valid in JSON files. Only double quotes are valid JSON.

Expected behavior

The quotemark rule should not apply to JSON files.

Easy Accepting PRs Bug

Most helpful comment

should be fixed in v5.12.1, which no longer tries to lint JSON files at all. let me know if that works for you

All 5 comments

Let's skip linting JSON files altogether rather than address this issue for only one rule. #4426

Just to clarify, you are importing JSON files using the TS 2.9+ --resolveJsonModule option, right?

Yes, that's correct.

should be fixed in v5.12.1, which no longer tries to lint JSON files at all. let me know if that works for you

Awesome! thanks!

Was this page helpful?
0 / 5 - 0 ratings