mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
15.97k stars 519 forks source link

fix(setupWorker): prevent the `mockServiceWorker.js` script to be picked up by v8 coverage (e.g. Vitest) #2280

Closed astorije closed 2 months ago

astorije commented 2 months ago

This ensures that projects setting up msw do not accidentally drop their coverage metrics for the auto-generated script.

This can of course be configured at consumer level but I figured it makes more sense to do so in the script itself like it is currently done for ESLint and TSLint.

References:

Let me know what you think! :)

kettanaito commented 2 months ago

Hi! Thanks for proposing this. This isn't something that MSW should ship. Instead, you shouldn't run your linting in the /public directory, to begin with. Please configure your tools to ignore that directory.

This has been suggested multiple times in different shapes (adding eslint-ignore, etc), and I think it's about time I added a proper decision document I can link so it's easier to explain why this shouldn't be a part of the library. I will write that document whenever I have a minute.

Thanks for understanding!