tslint trying to lint JSON
See original GitHub issueI’m trying to use the new JSON imports in TypeScript 2.9. I’m using a simple import for a JSON file:
import cfg from 'operations_client_config.json';
It builds great, but is failing at lint time with an error. Not sure why tslint is all of the sudden deciding that it should import the JSON file and lint it as TypeScript 🤷♂️
> google-gax@0.16.1 check /Users/beckwith/Code/gax-nodejs
> gts check
The 'no-reference' rule threw an error in '/Users/beckwith/Code/gax-nodejs/src/operations_client_config.json':
TypeError: Cannot read property 'length' of undefined
at walk (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/rules/noReferenceRule.js:46:67)
at Rule.AbstractRule.applyWithFunction (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/language/rule/abstractRule.js:39:9)
at Rule.apply (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/rules/noReferenceRule.js:27:21)
at Linter.applyRule (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/linter.js:197:29)
at /Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/linter.js:139:85
at Object.flatMap (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/utils.js:151:29)
at Linter.getAllFailures (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/linter.js:139:32)
at Linter.lint (/Users/beckwith/Code/gax-nodejs/node_modules/tslint/lib/linter.js:99:33)
at srcFiles.forEach.file (/Users/beckwith/Code/gax-nodejs/node_modules/gts/build/src/lint.js:43:20)
at Array.forEach (<anonymous>)
/Users/beckwith/Code/gax-nodejs/src/operations_client_config.json
unused expression, expected an assignment or function call (no-unused-expression)
> 1 | {
2 | "interfaces": {
3 | "google.longrunning.Operations": {
4 | "retry_codes": {
Missing semicolon (semicolon)
44 | }
45 | }
> 46 | }
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Configuring TSLint - Palantir Open Source
When using the CLI or many third-party tools, a file named tslint.json or tslint.yaml is used to configure which rules get run and...
Read more >TSLint command-line interface - Palantir Open Source
By default, TSLint looks for a configuration file named tslint.json in the directory of the file being linted and, if not found, searches...
Read more >Testing Rules
The test system lints the .ts.lint files with the settings specified in tslint.json and makes sure that failures generated by the TSLint match...
Read more >TSLint core rules - Palantir Open Source
Lint rules encode logic for syntactic & semantic checks of TypeScript source code. TypeScript-specific. These rules find errors related to TypeScript features:.
Read more >TSLint - Palantir Open Source
A linter for the TypeScript language. ... a basic configuration file tslint --init # Lint TypeScript source globs tslint -c tslint.json 'src/**/*.ts'.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Please add in your
tslint.json
file**/*.json
is necessary to be recursiveAvailable since version
5.8
It worked like a charm! Thanks @GabrielDelepine!