Vue-cli: TSLint bombs on .vue files for some rules from tslint-microsoft-contrib

Created on 11 Oct 2018  路  5Comments  路  Source: vuejs/vue-cli

Version

3.0.5

Reproduction link

https://github.com/millimoose/vue-tslint-microsoft-contrib-bug

Node and OS info

Node v10.11.0, npm 6.4.1, Typescript 3.1.2, TSLint 5.11.0, Ubuntu 18.04.1 LTS on WSL on Windows 10

Steps to reproduce

Run npm run lint --no-fix

What is expected?

The lint runs without errors

What is actually happening?

I get the following stack trace:

The 'no-use-before-declare' rule threw an error in '/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/src/App.vue':
TypeError: Cannot read property 'members' of undefined
    at resolveNameHelper (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:31434:105)
    at resolveName (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:31276:20)
    at resolveEntityName (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:32120:26)
    at getSymbolOfEntityNameOrPropertyAccessExpression (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescrip
t.js:55582:80)
    at getSymbolAtLocation (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:55669:28)
    at Object.getSymbolAtLocation (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:30310:31)
    at recur (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.js:65:54)
    at visitNode (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:15829:24)
    at Object.forEachChild (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:16208:24)
    at recur (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/tslint/lib/rules/noUseBeforeDeclareRule.js:69:27)
The 'no-unsafe-any' rule threw an error in '/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/src/App.vue':
TypeError: Cannot read property 'members' of undefined
    at resolveNameHelper (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:31434:105)
    at resolveName (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:31276:20)
    at resolveEntityName (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:32120:26)
    at getSymbolOfEntityNameOrPropertyAccessExpression (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:55582:80)
    at getSymbolAtLocation (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:55669:28)
    at Object.getSymbolAtLocation (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/typescript/lib/typescript.js:30310:31)
    at isNodeAny (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/tslint/lib/rules/noUnsafeAnyRule.js:368:26)
    at NoUnsafeAnyWalker.check (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/tslint/lib/rules/noUnsafeAnyRule.js:262:14)
    at NoUnsafeAnyWalker.visitNode (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/tslint/lib/rules/noUnsafeAnyRule.js:88:45)
    at NoUnsafeAnyWalker._this.visitNodeCallback (/mnt/c/Repos/vue-tslint-microsoft-contrib-bug/node_modules/tslint/lib/rules/noUnsafeAnyRule.js:55:71)
needs team repro typescript

Most helpful comment

@LinusBorg, @JoshuaKGoldberg - in light of the investigation leading to other culprits, maybe this issue can be closed as superseded by those other issues?

All 5 comments

The failing rules are no-use-before-declare and no-unsafe-any, which are both part of core TSLint rather than tslint-microsoft-contrib.

These are bugs that should be fixed in TSLint. We should note that no-use-before-declare is a legacy rule and it is recommend you no longer use it.

Hm, it seems the tslint-microsoft-contrib recommended ruleset enables them which is what threw me off? As in, the sequence of events for me was: using the TSLint ruleset was fine, adding the contrib one caused the bug to manifest, it didn't occur to me to look into which project has the actual rules complaining.

Anyway, thanks for taking a look at this @JoshuaKGoldberg, should I refile this with TSLint? Additionally, maybe tslint-microsoft-contrib shouldn't enable no-use-before-declare in its recommended ruleset anymore?

refile this with TSLint

Yes please 馃槉. I'm already planning on taking a look anyway, but it'd be nice for tracking there.

maybe tslint-microsoft-contrib shouldn't enable no-use-before-declare in its recommended ruleset

Agreed!

@JoshuaKGoldberg - Done at palantir/tslint#4273, thanks.

@LinusBorg, @JoshuaKGoldberg - in light of the investigation leading to other culprits, maybe this issue can be closed as superseded by those other issues?

Was this page helpful?
0 / 5 - 0 ratings