Enable line ending normalization in git, not in the linter
Checklist
-
tests and code linting passes -
the commit message follows commit guidelines
Affected core subsystem(s)
meta, tools
Description of change
After https://github.com/nodejs/node/pull/6685 landed, linting is broken on Windows because line endings are CRLF and the linter expects only LF (ref https://github.com/nodejs/node/issues/6912). The linter rule is necessary because files committed to the repository should be strictly LF.
In Windows, it's recommended to use git with core.autocrlf=true
, but this was not enforced and the Unix counterpart (core.autocrlf=input
) wasn't even recommended. The first commit of this PR adds * text=auto
to .gitattributes
(as described in https://git-scm.com/docs/gitattributes ), forcing end-of-line normalization for files detected to be text on all systems. Unix users will check out LF files, Windows users will check out CRLF files, and the files stored in the repository will be LF. Git detection of text vs binary files should not be a problem, as it is used by autocrlf
and currently done in CI.
Exceptions are added for some text files currently committed as CRLF (only from dependencies), and should be removed when those files are updated. The exception for text fixtures is left as it were, since those were also ignored by ESLint.
With this change, the linter rule is no longer necessary and can be removed, fixing vcbuild jslint
on Windows.
Note: Windows users not using autocrlf
will have to reset the files in the working dir as explained in https://help.github.com/articles/dealing-with-line-endings/#refreshing-a-repository-after-changing-line-endings . Unix users and Windows users using autocrlf
should not be affected.
Fixes: https://github.com/nodejs/node/issues/6912
cc @nodejs/testing @nodejs/platform-windows