Skip to content

ESLint requires the module tslint to load the plugin @typescript-eslint/tslint #2702

@ThomasFerro

Description

@ThomasFerro

Hi 👋

I just migrated from TSLint to ESLint following this guide but I found myself blocked when trying to remove the tslint dependency from my project.

I made a clean install of my dependencies (removing /node_modules and package-lock then running npm i), but now the linter won't work because of a missing tslint module. Here is what happen when trying to run the linter:

# In my package.json, the lint command is the following: eslint -c .eslintrc.js --ext .ts src
$ npm run lint
> eslint -c .eslintrc.js --ext .ts src


Oops! Something went wrong! :(

ESLint: 7.11.0

Error: Failed to load plugin '@typescript-eslint/tslint' declared in '--config': Cannot find module 'tslint'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/path/to/my/project/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/path/to/my/project/node_modules/@typescript-eslint/eslint-plugin-tslint/dist/rules/config.js:8:18)
    at Module._compile (/path/to/my/project/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)

I think that this module should be part of @typescript-eslint/eslint-plugin-tslint and not mine to add, and I see that it is actually a peerDependency in your project.

It may be linked to my npm version (6.13.4) not managing auto-installation of peer dependencies ?

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

module.exports = {
  env: {
    es6: true,
    node: true
  },
  extends: ["prettier", "prettier/@typescript-eslint"],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: "tsconfig.json",
    sourceType: "module"
  },
  plugins: [
    "eslint-plugin-import",
    "eslint-plugin-jsdoc",
    "eslint-plugin-react",
    "@typescript-eslint",
    "@typescript-eslint/tslint"
  ],
  rules: { /*...*/ }
}

Expected Result

Expect the linter to be able to check if my code respect the rules.

Actual Result

Unable to run eslint because of the missing module.

Additional Info

I can run the linter when installing tslint in my project dependencies but replacing this dependency with eslint was the whole point of migrating.

Should @typescript-eslint/eslint-plugin-tslint be able to install its dependencies no matter the npm version ?

Versions

package version
@typescript-eslint/eslint-plugin-tslint 4.5.0
@typescript-eslint/parser 4.5.0
TypeScript 3.8.3
ESLint 7.11.0
node 10.18.1
npm 6.13.4

Thanks in advance and great job maintaining this project 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    fix: user errorissue was fixed by correcting the configuration / correcting the codepackage: eslint-plugin-tslintIssues related to @typescript-eslint/eslint-plugin-tslint

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions