I'm writing a node project with syntax checking through ESLint. I want to meet POSIX standard and have a newline at the end of every file, so I set the eol-last
test to 2
in my .eslintrc
. However, this rule seems to be totally ignored while others work just fine.
I tried this .eslintrc
:
{
"rules": {
"eol-last": 2,
"no-console": 2
}
}
and tested this file:
console.log('Test');
In response, I get:
1:1 error Unexpected console statement no-console
✖ 1 problem (1 error, 0 warnings)
It makes no sense to me. I've tried everything and the rule seems to be useless. Thank you.
If you use unix
style ( lf
) then it will work as you have it configured above. You can try it on online demo .
If you use windows
styles ( crlf
), then you need to configure the rule like this:
{
"eol-last": [2, "windows"]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.