-
Notifications
You must be signed in to change notification settings - Fork 885
Add dry-run to Linter API fix option #1760
Comments
I'd like to get the fixed result without actually writing it to the file as well. We run TSLint, ESLint and Prettier in a pipe and it would be nice, if I could just write the newest versions of a file at the end on my own. |
My thoughts on this:
|
What do you think about adding a similar concept as TypeScript's |
My use case is the same as ESLint fix's API. ESLint has two methods:
This is great for building tools where you are combining multiple tools together, such as I always saw the |
@azz This is tangential to the issue thread, but have you checked out https://github.com/ikatyang/tslint-plugin-prettier? Curious to hear your thoughts on the tradeoffs between the two. |
e.g. I can type: if(!foo) throw "bah!" save, then it will transform to: if (!foo) {
throw new Error("bah!");
} |
FYI, this is also how I currently use tslint-plugin-prettier (in conjunction with tslint-config-prettier)... It sounds like you are just allowing some TSLint rules to override prettier's choices then? That makes sense, I guess, if you want to diverge from prettier's opinions. Thanks for explaining. |
@azz you can already achieve the same as ESLint works very similar: it gathers all fixes, sorts them in descending order and applies them to the text. If there are overlapping fixes, only the first is applied and the second is ignored. |
Seems like a lot of work that should live inside TSLint itself. ESLint's |
By now, this is out of scope. 😿 See #4534. |
🤖 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! 👋 |
The current implementation in tslint 4.0 for the lint method has the following:
If in the configuration I set
fix
to true thensource = fs.readFileSync(fileName, { encoding: "utf-8" });
gets called. This is great for the CLI but when writing my custom code I usually don't pass the fileName of something that exists. I simply pass the source code. Now, in this case I wanted to try to see if I could see the results of the fixer but it failed at the line I just mentioned.Could we get pass in an extra option in order to prevent the lint method from reading and writing the file? A dry run option would be great, for instance:
By default we can assume that dryRun is false so that the same behaviour stays the same.
The main goal I want to achieve is to get all the failures and the output of the fixer.
The text was updated successfully, but these errors were encountered: