`tslint.json` is required, even though documentation claims it's optional
gamesguru opened this issue Β· comments
π Bug Report
tslint-to-eslint-config
version: 2.13.2- ESLint version: v8.20.0
- Node version: v16.17.0 (npm 8.15.0)
Actual Behavior
I get the following error. We do NOT have a tslint.json
config file. (Link to repo is at the bottom.)
I must be missing something obvious?
~/nutra/web$ npx tslint-to-eslint-config
β Could not start tslint-to-eslint: β
Could not find your TSLint configuration file at './tslint.json'. Try providing a different --tslint path.
Expected Behavior
Running the script should convert our code base by some default / minimal configuration.
The documentation even says all the flags are optional?
Reproduction
Err, why are you trying to convert from TSLint to ESLint on that project? I don't see any way to run TSLint lint rules on it, and you already have a .eslintrc.js
.
What I was thinking of saying, if you were using TSLint somehow
This is the first time anybody has asked about converting a project that _doesn't have an existing `tslint.json`_. Funny.There probably is some utility in still working if a tslint.json
file wasn't found. The defaults for TSLint aren't the same as ESLint. But most of the time the not finding a tslint.json
file means the user ran tslint-to-eslint-config
from the wrong directory.
Accepting PRs to add some explicit way of indicating that a tslint.json
file doesn't exist (maybe --config false
?).
I started a branch where I removed references to tslint in package.json
and in .eslintrc.js
.
https://github.com/nutratech/web/tree/chore/tslint-deprecation
nutratech/web@7d87857
The project lints cleanly with tslint; all prior errors/warnings were long resolved in master. But how can I be sure that, in dropping it from the devDependencies, that no new errors will crop up? Or that if they do, they WILL be reported by eslint. I might be able to dig in prior commits, or artificially create an example where tslint-specific errors/warnings exist.
I guess that's my only concern... in dropping the tslint-specific warnings/errors, am I sure that eslint will now report what it once didn't (which we relied on tslint for).
I assumed this tool would be what helped my transition. I guess it's possible eslint will carry over any of the old tslint errors, and this will be handled automatically without any changes needed on my end. I'm just looking for a bit of guidance on that.
Got it, thanks for the clarification - that's good context.
Your project isn't using TSLint for anything right now. You have no TSLint rules enabled right now. You can safely remove any references to TSLint from your package because they're effectively dead code at the moment.
Running the tslint
package on its own requires at least one TSLint rule be enabled. See https://github.com/JoshuaKGoldberg/repros/tree/tslint-no-config-or-rules.
Your repo uses the @typescript-eslint/eslint-plugin-tslint
package to spawn the TSLint process within ESLint and report rule errors there. But, you haven't enabled any TSLint rules to be run in the package! So it's doing nothing. π
By the way, I see from your ESLint configuration that you're manually configuring rules some ESLint formatting rules for compatibility with Prettier. We in typescript-eslint strongly recommend you use eslint-config-prettier
instead. It's more comprehensive and requires fewer lines of configuration. Cheers!
That was the "deprecate tslint" branch, which doesn't.
But the master branch does extend tslint plugins, and I have seen tslint specific rules crop up. That's why I'm hesitating to drop it (by merging that branch in).
See our master branch eslintrc:
https://github.com/nutratech/web/blob/4d3b9e7820e0b3d25ce452ab5464da9355e532c4/.eslintrc.js#L21
I have seen tslint specific rules crop up
Can you post a link explaining+showing this? I don't understand how they could impact you π
Maybe you are right, I couldn't find any in old commits. Maybe I was thinking about tsc
.
But what does extending that plugin do then? Does it not make any new rules available?
plugins: ["react", "@typescript-eslint", "@typescript-eslint/tslint"],
It runs TSLint on your code and reports its rule complaints through ESLint. That's all it does. If you don't have any TSLint rules configured then it does nothing.
https://github.com/typescript-eslint/typescript-eslint/tree/main/packages/eslint-plugin-tslint