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

False positive for 'final-newline' rule on windows #65

Closed
davidgilbertson opened this issue Sep 1, 2015 · 2 comments
Closed

False positive for 'final-newline' rule on windows #65

davidgilbertson opened this issue Sep 1, 2015 · 2 comments

Comments

@davidgilbertson
Copy link

The final-newline rule is always reporting a warning for me and I believe it's because of the way Windows reports newlines.

Because they are actually \r\n, this line (last.content !== '\n') is always true.

If I test for \r\nas well the rule behaves as expected on Windows (although I don't have a mac handy to test it on).

if (last.content !== '\n' && last.content !== '\r\n' && parser.options.include) {

Or a shorter version...

if (!last.content.match(/\r?\n/) && parser.options.include) {
@davidgilbertson
Copy link
Author

It looks like the issue for empty-line-between-blocks. This line might need to be this to play well with Windows:

space = (previous.content.indexOf('\n\n') >= 0 || previous.content.indexOf('\r\n\r\n') >= 0);

@davidgilbertson
Copy link
Author

Or... having just learnt that os.EOL is a thing

var os = require('os');
if (last.content !== os.EOL && parser.options.include) {
    // etc.
}

Nice and descriptive...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants