Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jslint fails with linebreak on windows #6912

Closed
kunalspathak opened this issue May 21, 2016 · 17 comments
Closed

jslint fails with linebreak on windows #6912

kunalspathak opened this issue May 21, 2016 · 17 comments
Assignees
Labels
tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.

Comments

@kunalspathak
Copy link
Member

  • Version: master
  • Platform: windows
  • Subsystem:

After e77e935 changes made by @Trott, jslint error fails on windows machine because linebreak-style rule expects linebreaks to be LF but on windows they are CRLF and this fails the linebreak-style rule for all *.js files.

@bnoordhuis
Copy link
Member

It sounds like you have core.autocrlf set to true in your git config. Try setting git config core.eol lf and disable core.autocrlf - and make sure your editor uses UNIX line endings, of course.

@bnoordhuis bnoordhuis added the windows Issues and PRs related to the Windows platform. label May 21, 2016
@silverwind
Copy link
Contributor

silverwind commented May 21, 2016

Or alternatively, get git to behave with the third option here (globally):

@mscdex mscdex added the tools Issues and PRs related to the tools directory. label May 21, 2016
@kunalspathak
Copy link
Member Author

Thanks @bnoordhuis , @silverwind . However as seen in git's help message, I am using the recommended setting core.autocrlf=true on windows machine for cross platform project. How about passing it programmatically inside tools\jslint.js file using return value from process.platform?

kunalspathak added a commit to kunalspathak/node-chakracore that referenced this issue May 22, 2016
Recently linebreak-style rule was added in jslint which expects
linebreaks to be unix style i.e. `LR` by default. However windows
has linebreak `CRLF` (`git config auto.crlf=true`) causing this rule
to fail for all `*.js` files present in repo. I have disabled the rule
for now and opened nodejs/node#6912 to get the right rule
for windows user.
@bnoordhuis
Copy link
Member

You can configure core.autocrlf on a per-project setting. I doubt we'd accept patches to work around local configuration issues.

@joaocgreis
Copy link
Member

core.autocrlf=true has been discussed in #2494 , there was no consensus but we kept it supported at the time.

Windows CI servers use core.autocrlf=true (no warning in #6685 because linting is not run on Windows).

I believe most users who compile on Windows have core.autocrlf=true and I would not welcome a platform specific recommendation to change it. Most importantly, if we want to support end users running node on CRLF javascript files, we should keep testing this way and keep core.autocrlf=true fully supported. Thus, I would welcome a change to make vcbuild jslint work again.

cc @nodejs/testing

@bnoordhuis
Copy link
Member

Most importantly, if we want to support end users running node on CRLF javascript files, we should keep testing this way and keep core.autocrlf=true fully supported.

I don't understand this comment. This issue is about our test suite, not node-on-windows in general.

@Trott
Copy link
Member

Trott commented May 23, 2016

The main purpose of the lint rule is to let contributors know if they are about to submit code (in a PR) that does not conform to the existing code base.

If the typical user setup on Windows is to have git convert line endings to CRLF on check-out and back to LF on check-in, then the lint rule should probably be removed.

If that's an atypical setup or a setup we want to discourage for other reasons, then the lint rule should remain as-is.

I don't think there's much to be gained by adding complexity and having the rule check for different line endings on different platforms. That probably would not solve any real issues, and might create a few new ones.

@kunalspathak
Copy link
Member Author

kunalspathak commented May 24, 2016

This issue is about our test suite, not node-on-windows in general.

@bnoordhuis , I think @joaocgreis meant node contributors working on windows platform.

I agree with @Trott . Instead of complicating things here, we should remove linebreak-style from jslint or reduce its severity. As I mentioned earlier, git does recommend having core.autocrlf=true for windows users. It is very unlikely that developer working on windows would use IDE with unix ending.

@bnoordhuis
Copy link
Member

All files in the repository should have UNIX line endings. Contributors are expected to follow the project's conventions and the new lint rule helps with that. I don't see how that is controversial.

It is very unlikely that developer working on windows would use IDE with unix ending.

That seems like a very weak argument. You're either saying that Windows IDEs are defective or that Windows developers are too lazy and/or clueless to configure their editor. Both seem implausible.

@orangemocha
Copy link
Contributor

Line endings on Windows are different than on Unix. As awkward as it may seem, it's a platform difference that we simply have to live with.

IMO, core.autocrlf=true is the correct default for Windows users. It allows us to have text files with portable line endings. If we absolutely want the Unix line ending, we can mark the file as binary.

@bnoordhuis
Copy link
Member

Without this lint rule, how would you catch CRLFs when someone has core.autocrlf disabled and checks in changes with Windows line endings?

It's not a rhetorical question. Windows line endings have slipped in several times over the years. They broke the build at least once (25a5e90) although that wasn't in the test suite.

The only solution I can think of is a new CI lint check but that seems like a lot of effort when people just have to run git config core.eol lf locally once.

@Trott
Copy link
Member

Trott commented May 24, 2016

I'd be OK with a separate ESLint config file for CI only that included just two things:

  • the extends configuration indicating the actual ESLint config file that we use now (EDIT: with the EOL rule removed from that file, of course)
  • a line enabling the EOL rule

kunalspathak added a commit to kunalspathak/node-chakracore that referenced this issue May 25, 2016
Recently linebreak-style rule was added in jslint which expects
linebreaks to be unix style i.e. `LF` by default. However windows
has linebreak `CRLF` (`git config auto.crlf=true`) causing this rule
to fail for all `*.js` files present in repo. I have disabled the rule
for now and opened nodejs/node#6912 to get the right rule
for windows user.

PR-URL: nodejs#73
Reviewed-By: Jianchun Xu <Jianchun.Xu@microsoft.com>
@joaocgreis
Copy link
Member

Moving away from CRLF line endings, like disabling core.autocrlf, is the wrong answer to this issue. If we did something like that, all js test files would have LF line endings, and possible bugs affecting only CRLF js files would not be caught.

We should check for the correct line endings in the linter because the repository should contain only LF line endings, as @bnoordhuis mentioned above. @Trott, I think the rule should be used everywhere, not only in CI. I am working on a PR to fix this.

@joaocgreis joaocgreis self-assigned this May 26, 2016
@Trott
Copy link
Member

Trott commented May 26, 2016

I think the rule should be used everywhere, not only in CI.

That describes the current situation.

@bnoordhuis
Copy link
Member

possible bugs affecting only CRLF js files would not be caught

If you have concerns that node doesn't handle CRLF correctly in all cases, we can add regression tests and whitelist them. That would be a good addition regardless of the outcome of this issue.

@joaocgreis
Copy link
Member

@bnoordhuis I believe that CRLF is handled correctly now because we are testing it in CI. We should keep testing it in general (all files on Windows machines) and not only some specific test, because CRLF is the correct line ending on Windows.

@joaocgreis
Copy link
Member

PR: #7019

joaocgreis added a commit to JaneaSystems/node that referenced this issue Sep 26, 2016
Line breaks on Windows should be CRLF, but Node also supports LF.
Hence, do not check line breaks on Windows, when running
vcbuild jslint.

Fixes: nodejs#6912
@jasnell jasnell closed this as completed in 75a970b Oct 7, 2016
jasnell pushed a commit that referenced this issue Oct 10, 2016
Line breaks on Windows should be CRLF, but Node also supports LF.
Hence, do not check line breaks on Windows, when running
vcbuild jslint.

Fixes: #6912
PR-URL: #8785
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fishrock123 pushed a commit that referenced this issue Oct 11, 2016
Line breaks on Windows should be CRLF, but Node also supports LF.
Hence, do not check line breaks on Windows, when running
vcbuild jslint.

Fixes: #6912
PR-URL: #8785
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Issues and PRs related to the tools directory. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants