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

Problem with matching notice headers because of line endings mismatch on Windows #11

Closed
OrkoHunter opened this issue Apr 27, 2020 · 4 comments

Comments

@OrkoHunter
Copy link

Hi @nickdeis ! Thank you for creating the tool, it's very useful! ❤️

Friends at Spotify are using this plugin to lint for notice headers in their Open Source projects. See spotify/eslint-config-oss. There is a notice template file in the repository containing the template for Spotify copyright notice.

When working on spotify/backstage, users noticed that the project would not build on Windows OS and the problem is "missing notice header". Note that there are no errors on the unix platform. All the project source files do have the notice in place, and we should not be seeing this error.
Another key fact is that our build broke when we moved the notice header to a separate text file.

One of the causes we think is that the line endings are different in the backstage source code files and the notice-template.txt. And thus, the matching logic in eslint-plugin-notice is having issues, even though the notice text is exactly the same.

I am referring this comment from @Rugvip on backstage/backstage#613. The issue has more details!

A possible solution is to improve the logic in this plugin to ignore line endings when matching the notice headers. Or it could allow to suppress errors raised due to line endings.

Let us know your thoughts! 🙇

cc @fastfrwrd

@nickdeis
Copy link
Owner

Hey @OrkoHunter,
Thank you for the incredibly kind words and the detailed defect ticket. This seems like a change to the eslint plugin API, because I also ran into this problem while updating unit tests during a routine security update that included updating to eslint 6 to perform tests.

A possible solution is to improve the logic in this plugin to ignore line endings when matching the notice headers.

This is an excellent solution. Or at least normalize line endings to be unix line endings. I don't think people care too much about what kind of line endings are in a copyright notice, but maybe their existence matters.

I'll look into fixing this soon (today probably) as well as adding a CI system to test on both windows/mac. I think Travis CI supports that.
Best,
Nick

nickdeis added a commit that referenced this issue Apr 27, 2020
- Added logic to normalize all strings to unix line endings
- Made some files CRLF and LF in unit tests
- Added .travis.yml for testing on windows and linux
- Added staging tests
@nickdeis
Copy link
Owner

Hey @OrkoHunter,
I have committed a fix for the problem and added a CI file, as well as add "staging" like tests. I have published a package @0.9.10. Please let me know how this works out. Given the platform specific nature of this defect, I will keep this issue open until I get confirmation from you that it's working for your users.
Best,
Nick

@OrkoHunter
Copy link
Author

Thank you thank you @nickdeis !!

@OrkoHunter
Copy link
Author

Thank you @nickdeis ! This looks fixed, and I will close the issue.

fastfrwrd pushed a commit to spotify/eslint-config-oss that referenced this issue Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants