-
Notifications
You must be signed in to change notification settings - Fork 5
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
Running eslint without --fix still updates snapshots #14
Comments
I suspect this is the triggering code: // Trick: Function `fix` is ALWAYS run, and result is collected. However RuleFix objects are only read if `--fix` is passed
get text() {
if (!applied) {
// Make sure we update snapshot only on first read of this object
applied = true;
if (!options.disableExpectTypeSnapshotFix) {
updateTypeSnapshot(fileName, snapshotName, actual);
}
}
return '';
}, Since then (2 years ago) ESLint has probably added some call to |
Adding the |
I'd asked about this in the ESLint Discord: https://discord.com/channels/688543509199716507/711686958635548723/1107343559981551788. Nothing we can use here was mentioned. Ah well. |
## PR Checklist - [x] Addresses an existing open issue: fixes #14 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/eslint-plugin-expect-type/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/eslint-plugin-expect-type/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Only adds a `fix()` function if `process.argv.includes("--fix")`. This will therefore stop type snapshots from being updated automatically when ESLint is run through the Node API, such as in an editor extension. This is the best I can do without ESLint providing a native way for rules to know whether they're in fix mode 😬. I don't like it. It's a rough heuristic and I'll file a followup issue on improving it (that will be blocked on ESLint's making an API, I assume). This also isn't tested yet so I'll file a followup issue for that too.
Thanks for the great library!
The issue is, I'm changing one of the test types expecting them to throw an error. Then running eslint without
--fix
option. It still updates snapshots.Edit: I found out that explicitly setting
"expect-type/expect": ["error", { "disableExpectTypeSnapshotFix": false }]
fixes the issue. It only generates snapshots with --fix.Having no rule at all doesn't prevent snapshots to be generated.
The text was updated successfully, but these errors were encountered: