Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

How to disable tslint? #133

Closed
azu opened this issue Aug 6, 2017 · 22 comments
Closed

How to disable tslint? #133

azu opened this issue Aug 6, 2017 · 22 comments

Comments

@azu
Copy link

azu commented Aug 6, 2017

Description

Currently, tslint.json contains style-specific rules.

  • indent
  • whitespace
  • quotemark

etc...

I've tried to use react-scripts-ts and I've feel frustrated to following lint error

./src/XXX.ts
[12, 34]: " should be '
[12, 50]: " should be '
[13, 33]: " should be '
[25, 60]: " should be '
... a lot of lint errors..

Expected behavior

  • Relax tslint rule
  • Or, can you provide disabling way?

It is difficult that provide fundamental solution, I think.

Actual behavior

Report style error on npm start

Related

@foxylion
Copy link

foxylion commented Aug 6, 2017

I think this is possible by creating an empty tslint.json in your project root. This will force tslint to disable all linters.

@azu
Copy link
Author

azu commented Aug 6, 2017

@foxylion Oh, Thanks.
It work fine 👍

$ cat tslint.json
{
    "rules":{
    }
}

$ yarn start
Starting the development server...

No valid rules have been specified
...

I've been confused about it, because create-react-app said that

Note that even if you edit your .eslintrc file further, these changes will only affect the editor integration. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes.
-- https://github.com/facebookincubator/create-react-app/blob/e12d053c273037c5ec75971ddcd117b3e9858cdf/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor

@wmonk
Copy link
Owner

wmonk commented Aug 7, 2017

@azu @foxylion is this all solved now? If so please can you close this issue.

@azu azu closed this as completed Aug 7, 2017
azu added a commit to proofdict/_archieve_editor that referenced this issue Aug 8, 2017
@bestwestern
Copy link

bestwestern commented Oct 31, 2017

Please open this again: It wont compile because of unused var
image

Ah - that was because of tsconfig.json:
noUnusedLoals": true

What an awful setting during development!

@loginov-rocks
Copy link

loginov-rocks commented Nov 18, 2017

@bestwestern you're right, I've also removed all rules from tslint.json, removed noUnusedLocals from tsconfig.json and it keeps failing with error TS2552: Cannot find name...

So it seems the issue is back, how we should control tslint?

@YagoLopez
Copy link

Yeah It would be great disable tslint during development. App compilation would be faster without lint check. In my opinion ideal situation would be lint the code voluntarily when you want, not each recompilation.

@loginov-rocks
Copy link

For example, in my case I've wanted to develop an electron app with the help of create-react-app-typescript, but I've needed to do some things that TSLint doesn't want me to do, like window.require() to prevent require() to be handled by webpack, since it is the only way to get access to the electron remote process.

@YagoLopez
Copy link

@1oginov I manged to disable tslint in my environment (react + typescript). In my case deleting all rules in tslint.json and leaving a void {} object in the file did it. Hope that helps.

@Ebuall
Copy link

Ebuall commented Mar 22, 2018

Is there a way to disable it completely, while keeping config?
I think it should live in IDE and only IDE should run it.
I don't want waste PC resources and don't think linter should prevent compilation during development.

@janacm
Copy link

janacm commented Mar 29, 2018

Is there a way to make the linter wait until I'm done typing before yelling at me for semi colon errors?

@TeoTN
Copy link

TeoTN commented Apr 2, 2018

Why to waste time on linting on recompile when you can spare some cpu power on bitcoin mining? Has anyone figured out a way how to kill the linter completely? I'm just trying to check how costly is to migrate from plain jsx to ts and I honestly don't give a .... right now about linter. -.-

@rock007
Copy link

rock007 commented Apr 24, 2018

hi,it can't disable ,but you can do this:
image

exclude all file you code

@gunn4r
Copy link

gunn4r commented Apr 25, 2018

Any updates on this? The internal linter is really wrecking our dev process. We run tslint in our IDEs and on commits / CI. Having a hidden lint config that we can't change is brutal. Any solutions?

@panmona
Copy link

panmona commented Apr 25, 2018

@gunn4r you can change your tslint according to your needs. Never had any issues with that.

@dadayada
Copy link

dadayada commented May 2, 2018

@maracuja-juice linter should not affect compilation. I want the app to work but I also want to see linter`s warnings.

@elektronik2k5
Copy link

@dadayada, not necessarily. It really depends on your use case and how strict you want lint to be enforced.
I for example would prefer to have the linter fail the compilation. You think differently - and that's ok! If you prefer strict linter's feedback in your editor/command line but still compile, you can do that: make the default lenient (to not affect compilation) and extend it with a stricter conf, which your editor/cli will invoke.

What I'm saying is that there's no single right or wrong way to use the linter - because different people use the same tool in different ways for different purposes. We can't cater to all of them with a single default. We can only decide on a reasonable one, which should serve most people.

I'm in favor of a strict default and a well documented way to override it.

@louisptremblay
Copy link

To implement suggested workarounds in VS Code:
-Rename tslint.json to tslint.ide.json
-Create tslint.json with empty {} inside
-Add line to VS Code settings: "tslint.configFile": "./tslint.ide.json"

@tomjakubowski
Copy link

My workaround is like the above, but reversed:

  • Add "defaultSeverity": "warn" to tslint.json
  • Create a new tslint.prod.json, which extends "./tslint.json" but overrides "defaultSeverity": "error"
  • Add a lint script to package.json which runs tslint --project . --config tslint.prod.json.

CI runs npm run lint (so CI catches linter errors) followed by npm run build. I don't think I can configure which tslint config file npm run build uses without ejecting. That means, unfortunately, in CI tslint runs twice: first for npm run lint (with "defaultSeverity:" "error"), then the usual tslint step as part of react-scripts-ts build (with "defaultSeverity": "warning"). But that's OK with me.

@YagoLopez
Copy link

YagoLopez commented Jun 3, 2018

If you are using Webstorm, when you open the project the event log window says:

TSLint is enabled: config file is in the project.
Disable TSLint

Supposedly clicking "Disable TSLint" allows deactivation. Not confirmed.

@gryzzly
Copy link

gryzzly commented Jun 12, 2018

It is unbelievable that there is no workaround for this provided by the tool authors.

Many of us deal with existing projects where we didn’t have a way to choose the tooling and have to deal with what’s there.

Please provide an official way to disable TSLint in development and have it only run within IDE.

jansule added a commit to jansule/geostyler that referenced this issue Aug 13, 2018
Now two tslint configs exist. One for development, one for production. In development, the defaultSeverity is set to "warning". Thus, compiling does not fail when breaking a rule. In production defaultSeverity is set to "error", resulting in failing compilation.

When running `npm run build` tests run before building.

Solution for config setup taken from
wmonk/create-react-app-typescript#329 (comment)
wmonk/create-react-app-typescript#133 (comment)
jansule added a commit to jansule/geostyler that referenced this issue Aug 16, 2018
Now two tslint configs exist. One for development, one for production. In development, the defaultSeverity is set to "warning". Thus, compiling does not fail when breaking a rule. In production defaultSeverity is set to "error", resulting in failing compilation.

When running `npm run build` tests run before building.

Solution for config setup taken from
wmonk/create-react-app-typescript#329 (comment)
wmonk/create-react-app-typescript#133 (comment)
azu added a commit to proofdict/proofdict that referenced this issue Nov 13, 2018
@carpben
Copy link

carpben commented Nov 27, 2018

@gryzzly This is an open source project, and the authors don't get payed. There is no reason to point blame towards or demand from the authors. I am using this project just like you and was quite surprised to read your comment.

@carpben
Copy link

carpben commented Nov 27, 2018

@wmonk I do wonder if such a strict set of rules as default is the right way to go for such a package, which is used and presents itself as Typescript's "create-react-app".
From what I remember create-react-app itself comes with a very basic set of linting rules as default.

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