Tslint: Improve no-implicit-dependencies message for case sensitive mismatches

Created on 3 Nov 2017  ยท  7Comments  ยท  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.8.0
  • __TypeScript version__: 2.6.1
  • __Running TSLint via__: tslint-loader (webpack) and VSCode plugin

TypeScript code being linted

import "toFormat";

with tslint.json configuration:

    "no-implicit-dependencies": true,

and packages.json:

  "dependencies": {
    "@angular/animations": "^4.4.6",
    "@angular/common": "^4.4.6",
    "@angular/compiler": "^4.4.6",
    "@angular/compiler-cli": "^4.4.6",
    "@angular/core": "^4.4.6",
    "@angular/forms": "^4.4.6",
    "@angular/http": "^4.4.6",
    "@angular/platform-browser": "^4.4.6",
    "@angular/platform-browser-dynamic": "^4.4.6",
    "@angular/platform-server": "^4.4.6",
    "@angular/router": "^4.4.6",
    "@markpieszak/ng-application-insights": "^2.4.1",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.5",
    "angular-compare-validator": "^0.1.2",
    "chart.js": "^2.7.1",
    "core-js": "^2.5.1",
    "decimal.js": "^7.3.0",
    "jw-bootstrap-switch-ng2": "^1.0.7",
    "jwt-decode": "^2.2.0",
    "msalx": "^0.1.2",
    "ng2-adsense": "^4.0.12",
    "ng2-charts": "^1.6.0",
    "ngx-clipboard": "^8.1.1",
    "ngx-loading": "^1.0.8",
    "rxjs": "^5.5.2",
    "time-ago-pipe": "^1.2.1",
    "toformat": "^2.0.0",
    "zone.js": "^0.8.18"
  },

Actual behavior

image

Expected behavior

Not an error

P4 Rule Enhancement ๐ŸŒน R.I.P. ๐ŸŒน

Most helpful comment

Not sure if this is also a false positive, but are imports supposed to also include devDependencies (tests, for instance)?

// __tests__/User.test.ts
import axios from "axios"
// package.json
{
  //...
  "devDependencies": {
    "axios": "^0.18.0",
    "jest": "^22.4.3",
    "tslint": "^5.9.1",
}

screen shot 2018-03-25 at 1 31 17 pm

EDIT: nevermind, there's a rule for devDependencies; "no-implicit-dependencies": [true, "dev"]

All 7 comments

Can you provide a minimal repro as a github project you can link to? It's a little hard to tell what's going on here without more info.

The import is camelCase while the name of the dependency is all lowercase.
The rule is case sensitive.

Thanks, good catch! I wonder if on Windows systems the rule should look case-insensitively to provide a better error ("did you mean?"). It makes sense that the rule is case-sensitive, don't get me wrong, but I imagine this being a common blunder.

Not sure if this is also a false positive, but are imports supposed to also include devDependencies (tests, for instance)?

// __tests__/User.test.ts
import axios from "axios"
// package.json
{
  //...
  "devDependencies": {
    "axios": "^0.18.0",
    "jest": "^22.4.3",
    "tslint": "^5.9.1",
}

screen shot 2018-03-25 at 1 31 17 pm

EDIT: nevermind, there's a rule for devDependencies; "no-implicit-dependencies": [true, "dev"]

It'd be nice to see an improved error message for case sensitivity. Changing the issue title to reflect this in searches.

โ˜ ๏ธ TSLint's time has come! โ˜ ๏ธ

TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. โœจ

It was a pleasure open sourcing with you all!

๐Ÿค– Beep boop! ๐Ÿ‘‰ TSLint is deprecated ๐Ÿ‘ˆ _(#4534)_ and you should switch to typescript-eslint! ๐Ÿค–

๐Ÿ”’ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings