Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable typescript-eslint plugin rule (no-explicit-any) with inline comment

I have an eslint error that comes from the @typescript-eslint plugin.

Unexpected any. Specify a different type.eslint(@typescript-eslint/no-explicit-any)

This is the no-implicit-any rule. In just one file I want to disable that rule with a comment at the top of the file.

The compiler complains if I just try a standard eslint disable:

/* eslint-disable  no-explicit-any */ 

Definition for rule 'no-explicit-any' was not found.eslint(no-explicit-any)

I've tried to find documentation on inline rules for the TS plugin, but without much luck. I've also tried various combinations like these:

/* typescript-eslint-disable no-implicit-any */ /* typescript-eslint: disable no-implicit-any */ /* typescript-eslint: disable noImplicitAny */ /* typescript-eslint-disable @typescript-eslint/no-implicit-any */ 

There are no eslint complaints but the error will not disappear.

How do I disable an typescript-eslint rule?

like image 469
cham Avatar asked Dec 02 '19 22:12

cham


People also ask

How do I disable inline ESLint?

To turn off ESLint in the whole file, you can add /* eslint-disable */ in the first line of that file.

How do I turn off all rules in ESLint?

Use /* eslint-disable */ to ignore all warnings in a file.

Is ESLint necessary for TypeScript?

ESLint is capable of performing a comprehensive set of code quality checks on TypeScript and is the recommended linter for TypeScript code. ESLint is highly configurable and can be adjusted to meet the requirements of a particular project.


2 Answers

add this to the .eslintrc (tslintrc) file :

rules: {     "@typescript-eslint/no-explicit-any": "off"   }, 
like image 184
abdelhedi hlel Avatar answered Sep 20 '22 15:09

abdelhedi hlel


The correct syntax is like this:

/* eslint-disable  @typescript-eslint/no-explicit-any */ 

So that you directly reference the plugin via eslint.

like image 26
cham Avatar answered Sep 16 '22 15:09

cham