Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no-unused-vars] warnings for used vars #1479

Closed
fairking opened this issue Jan 20, 2020 · 8 comments
Closed

[no-unused-vars] warnings for used vars #1479

fairking opened this issue Jan 20, 2020 · 8 comments
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser

Comments

@fairking
Copy link

fairking commented Jan 20, 2020

Repro

module.exports = {
	root: true,
	env: {
		node: true,
	},
	extends: ["eslint:recommended", "plugin:vue/recommended", "prettier", "prettier/vue", "@vue/typescript"],
	rules: {
		"no-console": process.env.NODE_ENV === "production" ? "error" : "off",
		"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
		"no-unused-vars": "warn",
	},
	parserOptions: {
		parser: "@typescript-eslint/parser",
	},
	plugins: ["vue"],
	overrides: [
		{
			files: ["**/__tests__/*.{j,t}s?(x)"],
			env: {
				jest: true,
			},
		},
	],
};
import Vue, { DirectiveOptions } from "vue";
import AppSubmenu from "@/views/layouts/comps/AppSubmenu.vue";
Vue.directive("appsubmenu", <DirectiveOptions>AppSubmenu);

warning: 'DirectiveOptions' is defined but never used (no-unused-vars)

import { LoginTokenVm } from "@/services/index";
export class UserLoginStateVm {
	status: UserLoginStatus;
	user: LoginTokenVm;
	returnUrl: string;
}

warning: 'LoginTokenVm' is defined but never used (no-unused-vars)

Versions

package version
@typescript-eslint/eslint-plugin ^2.15.0
@typescript-eslint/parser ^2.15.0
TypeScript ^3.7.4
ESLint ^6.8.0
node 12.14.1
npm 6.13.6
@fairking fairking added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jan 20, 2020
@fairking fairking changed the title [no-unused-vars] warning for used vars [no-unused-vars] warnings for used vars Jan 20, 2020
@fairking
Copy link
Author

Might be related to #171

@fairking
Copy link
Author

import Vue, { VNode } from "vue";

declare global {
	namespace JSX {
		// tslint:disable no-empty-interface
		interface Element extends VNode {}
		// tslint:disable no-empty-interface
		interface ElementClass extends Vue {}
		interface IntrinsicElements {
			[elem: string]: any;
		}
	}
}

warning: 'Vue' is defined but never used (no-unused-vars)
warning: 'VNode' is defined but never used (no-unused-vars)

@armano2
Copy link
Member

armano2 commented Jan 20, 2020

no-unused-vars is not working for types at all, i was fixing it in #233 but i stopped because of time

@fairking
Copy link
Author

ok, thanks @armano2. so I am probably going to disable the rule to suppress the noise and to be able to spot other important warnings. You can close the issue if you think it is not worth of spending time.

@armano2 armano2 added bug Something isn't working scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser and removed triage Waiting for maintainers to take a look labels Jan 20, 2020
@fairking
Copy link
Author

fairking commented Jan 21, 2020

Thanks @bradzacher , Yeah, that's the typescript-eslint:
image

@bradzacher
Copy link
Member

This is a KP - the rule doesn't support things used in a type position well.
You should try the rule no-unused-vars-experimental, which uses typescript's tooling to report unused vars.

@bradzacher bradzacher added this to the scope analysis rewrite milestone Apr 6, 2020
@bradzacher
Copy link
Member

Merging into #1856

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin scope analyser Issues that are caused by bugs/incomplete cases in the scope analyser
Projects
None yet
Development

No branches or pull requests

3 participants