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

Improve error message when tslint is not recognized #738

Closed
marcusjwhelan opened this issue Oct 9, 2020 · 4 comments
Closed

Improve error message when tslint is not recognized #738

marcusjwhelan opened this issue Oct 9, 2020 · 4 comments
Labels
area: command line Arguments parsing and/or output printing on the CLI. status: accepting prs Please, send in a PR to resolve this! ✨ type: enhancement New feature or request

Comments

@marcusjwhelan
Copy link

🐛 Bug Report

  • tslint-to-eslint-config version: 1.5.0
  • ESLint version: 7.10.0
  • Node version: 12.18.2

Actual Behavior

I run the command

tslint-to-eslint-config --comments tsconfig.json

Just like in my other project and get this output instead of conversion. All the same versions in my other project except it works

❌ Could not start tslint-to-eslint: ❌
  Command failed: tslint --print-config "./tslint.json"
'tslint' is not recognized as an internal or external command,
operable program or batch file.

Expected Behavior

Converts just like my other project using all the same versions

Reproduction

base.json - is the base for the tsconfig

{
    "compileOnSave": false,
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "target": "esnext",
        "module": "commonjs",
        "moduleResolution": "node",
        "strict": true,
        "pretty": true,
        "sourceMap": true,
        "declaration": true,
        "importHelpers": true,
        "removeComments": true,
        "noImplicitAny": true,
        "noEmitOnError": true,
        "strictNullChecks": true
    }
}

tsconfig

{
  "extends": "./configs/base.json",
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./",
    "lib": [
        "es6",
        "es2015",
        "es2017",
        "es2016.array.include",
        "es2017.object"
    ]
  },
  "include": [
    "src/**/*.ts",
    "node_modules/**/*.d.ts"
  ],
  "exclude": [
    "dist",
    "node_modules",
    "spec",
    "webpack"
  ]
}

tslint

{
  "extends": [
    "tslint:recommended"
  ],
  "rules": {
    "variable-name": [true, "ban-keywords"],
    "ordered-imports": false,
    "object-literal-sort-keys": false,
    "max-line-length": [false],
    "no-bitwise": false,
    "no-var-requires": false,
    "no-console": false,
    "typedef-whitespace": false,
    "quotemark": [ true, "single", "jsx-double", "avoid-escape"]
  }
}

Or check out the package npm clone tedb-utils https://github.com/tedb-org/tedb-utils

@JoshuaKGoldberg
Copy link
Member

👋 @marcusjwhelan, thanks for using tslint-to-eslint-config and filing an issue! Is TSLint installed globally or as a direct dependency of the project you're running in? tslint-to-eslint-config needs it to compute the full rules list for a configuration (e.g. in yours, it needs the tslint package to understand what "tslint:recommended" means). Running this might fix usage for you:

npm i -g tslint

That being said, I think tslint-to-eslint-config should give a better error message in this case. Vaguely, maybe, something like:

$ tslint-to-eslint-config --comments tsconfig.json

Error: could not find the 'tslint' package. Do you need to install it?

    npm i -g tslint

@JoshuaKGoldberg JoshuaKGoldberg added area: command line Arguments parsing and/or output printing on the CLI. status: accepting prs Please, send in a PR to resolve this! ✨ type: enhancement New feature or request labels Oct 9, 2020
@marcusjwhelan
Copy link
Author

@JoshuaKGoldberg I found that my IDE(Webstorm) did not have the node interpreter targeting my local npm. I did not have to install globally just locally as dev. I rather not install global packages unless absolutely necassary, but it would be nice to not have to have an install of tlsint to do this.

Also, I have seen this fix on many other issues and wonder why it doesn't get placed on default if it fixes many issues.

In .eslintrc.js inside "parserOptions" placing

'createDefaultProgram': true

Seems to fix a lot of eslint issues with my IDE. Also the error message for the error shown here typescript-eslint/typescript-eslint#967 can be fixed with this and the combination of fixing the includes from

"include": [
    "/src"
]

to

"include": [
    "**/src/**/*.ts"
]

If that helps any I just wanted to state the things I had to do to update this project to work with this project. Thanks for the help it looks like things are working now.

@JoshuaKGoldberg
Copy link
Member

Love it! Filed separate issues to investigate those two items in particular: #739 #740.

@JoshuaKGoldberg JoshuaKGoldberg changed the title Could not start tslint-to-eslint failed tslint is not recognized Improve error message when tslint is not recognized Oct 11, 2020
@JoshuaKGoldberg
Copy link
Member

Solved in #837. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: command line Arguments parsing and/or output printing on the CLI. status: accepting prs Please, send in a PR to resolve this! ✨ type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants