We have a project developed by multiple developers on multiple operating systems. We have a character limit in our prettier config set to 120 characters. Our windows machines are producing snapshots different than our linux/unix machines.
windows:
<h4
className="RightPanel__item--heading heading--headingBlocks
subHeading--headingBlocks subHeading--different"
>
whereas on our linux/unix machines the snapshot produces the following line:
<h4
className="RightPanel__item--heading heading--headingBlocks subHeading--headingBlocks subHeading--different"
>
For the linux/unix snapshot, the code ends right on column 119, whereas windows machines produce a new line before the last couple of attributes. We use React, Jest for Testing, eslint for linting, Babel for transformation.
React, Babel, Webpack, vanilla es6+ no typescript project with jest for testing
We've tried setting the eslint's "linebreak-style": ["error", "unix"] to see if the eslint change would update the fix the jest snapshot for windows to no avail. We've ensured the same installed version of jest across machines. Same with prettier and eslint.
Any suggestions on how we might fix this issue so tests don't fail for one OS or the other?
The best way to synchronize something like this across a team is to use EditorConfig. Most code editors support it, either natively or through an extension.
EditorConfig is a universal way to specify editor setting, Line Endings in your case, that is respected by all code editors on all OSes.
https://editorconfig.org
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With