Bug: False positive no-unused-vars on import in custom.d.ts
See original GitHub issueTell us about your environment
Node version: v12.16.2 npm version: v6.13.6 Local ESLint version: v6.8.0 (Currently used) Global ESLint version: Not found OS: macOS 10.15.5
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
Configuration
module.exports = {
'env': {
'es6': true
},
'extends': 'eslint:recommended',
'globals': {
'process': true
},
'settings': {
'import/resolver': {
'node': {
'extensions': ['.js', '.jsx', '.ts', '.tsx']
}
}
},
'parser': '@typescript-eslint/parser',
'parserOptions': {
'project': 'tsconfig.json',
'sourceType': 'module'
},
'plugins': [
'@typescript-eslint',
'eslint-plugin-import'
],
'rules': {
'@typescript-eslint/indent': ['error', 4],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/quotes': [
'error',
'single'
],
'comma-dangle': 'error',
'curly': 'error',
'eqeqeq': [
'error',
'always'
],
'no-trailing-spaces': 'error',
'no-var': 'error',
'prefer-const': 'error',
'no-console': 'error',
'no-unused-vars': ['error', { 'args': 'none' }],
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'import/no-extraneous-dependencies': 'error',
'import/no-cycle': 'error',
'import/no-self-import': 'error',
'import/no-unresolved': 'error'
},
'overrides': [{
'files': ['*.ts', '*.tsx'],
'rules': {
'@typescript-eslint/no-unused-vars': [2, { args: 'none' }],
'no-undef': 'off'
}
}]
};
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
Contents of custom.d.ts file:
/* eslint-disable no-unused-vars */
import { Server } from 'ws';
declare global {
namespace Express {
interface Request {
ws?: Server;
}
}
}
export {};
eslint -c .eslintrc.js --ext .ts src
What did you expect to happen?
I expected to be able to define the type of ws (imported from @types/ws)
What actually happened? Please include the actual, raw output from ESLint.
Two different failures:
- the import is considered unused
eslint-disable no-unused-vars
has no effect
Are you willing to submit a pull request to fix this bug?
I don’t have a fix to offer at this point.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
[@typescript-eslint/no-unused-vars] False positive no ... - GitHub
... False positive no-unused-vars on import in custom.d.ts #2287 ... Are you willing to submit a pull request to fix this bug?
Read more >typescript-eslint/no-unused-vars false positive in type ...
And we have @typescript-eslint/no-unused-vars error in string with type declaration, which says 'name' is defined but never used.
Read more >Importing into the United States A Guide for Commercial ...
This edition of Importing Into the United States contains material pursuant to the. Trade Act of 2002 and the Customs Modernization Act (Title...
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
"problem" means the rule is identifying code that either will cause an error or may cause a confusing behavior. · "suggestion" means the...
Read more >TypeScript - Fastify
npm init -y npm i fastify npm i -D typescript @types/node ... import { FromSchema } from "json-schema-to-ts"; fastify.post<{ Body: FromSchema<typeof todo> } ......
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
@ajmas Hi 😃 some eslint rule does not work properly with typescript code. What about use typescript-eslint/no-unused-vars instead?
@mdjermanovic thanks. Will do.