I think that for the use case you presented the git core.autocrlf config option is more appropriate.
With this option each developer can work with their native eol character.
However what I like about your option is that you can commit the gitattribute file and force the change for every developers
Thanks for the tip.
You're not really forcing it if you need to ask everyone to flush their cache / reset gitattributes.
If you need cooperation, it's better to just ask developers to set their autocrlf setting properly.
Prettier issue aside, it's better to preempt accidental commits of eol changes anyway.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.