amilajack / eslint-plugin-flowtype-errors

Run Flow as an ESLint plugin
MIT License
402 stars 32 forks source link

New Rule: enforce-min-coverage-comments-sync #277

Closed TSMMark closed 2 years ago

TSMMark commented 2 years ago

Why?

When using rule enforce-min-coverage, a common pattern in practice seems to be override the global eslint config value in several specific files, when the coverage is lower than required in that one file, but you are okay with the lower % for whatever reason.

That looks like:

// @flow
/* eslint "flowtype-errors/enforce-min-coverage": [2, 30] */

// ... all the file's code below

However, after years of doing this in certain files, we've come to a place where some files used to have low coverage %, but at some point, we have improved type-safety of underlying modules and consequently increased the coverage % of many files downstream.

So now we're left with many files with comments like /* eslint "flowtype-errors/enforce-min-coverage": [2, 30] */, when actually the coverage % could be much higher than that.

New Rule Proposal

I have introduced a new rule called enforce-min-coverage-comments-sync which will update the per-file comments if the actual coverage % is greater than the enforce-min-coverage value by a configurable margin %.


Let me know if you think this is a rule you would accept, and if so I can clean up this PR, rebase, whatever you want, lmk.

By the way, I ran this new rule on our medium-sized React codebase and it worked exactly as intended.

Thanks!

amilajack commented 2 years ago

Published this to the next tag. Would appreciate if you could test it out before I publish to latest

npm i eslint-plugin-flowtype-errors@next
amilajack commented 2 years ago

Also windows builds seem to be failing

https://github.com/amilajack/eslint-plugin-flowtype-errors/runs/4216011150?check_suite_focus=true#step:5:126

Any ideas?

TSMMark commented 2 years ago

Just saw this. Will try to test next tag later tonight.

For the windows failure I can only guess something to do with EOL characters since the lines look identical to me

TSMMark commented 2 years ago

Confirmed next release works

amilajack commented 2 years ago

Published to latest 🥳