Bug Report
TSLint version: 4.0.2
TypeScript version: 2.1.4
Running TSLint via: CLI
TypeScript code being linted
export const x = "x";
Enable the file end with newline rule, and see that it fails the linter.
TSLint could autofix this error. It currently does not.
I wouldn't mind trying to fix this but I'm not sure when I'd have the time
How do you know which line ending to choose? \r\n or \n?
Of course this could be inferred from the other line endings in the file, but what if there is only a single line?
Good point.
One idea is to only autofix this when there are multiple lines in the file, that way the line ending can be inferred.
Another strategy is just to guess. Not ideal, could potentially be configured, but that seems like a lot of overhead for such a small edge case.
Does the existing TSLint rule just check that the file ends in \r\n or \n?
Does the existing TSLint rule just check that the file ends in \r\n or \n?
It just checks if the last character is \n. That covers both cases.
I like the idea of fixing only multiline files. Otherwise when guessing wrong we could introduce new failures for the linebreak-style rule.
Is it possible to check what the value of the linebreak-style rule is while trying to autofix the eofline rule?
Nope, currently each rule is limited to its own configuration.
There is no way to access the config of another rule, although that would be pretty useful in many cases.
I don't think we want rules reading options that don't belong to it. I'm fine with only fixing files with multiple lines.
How do you know which line ending to choose?
\r\nor\n?
Of course this could be inferred from the other line endings in the file, but what if there is only a single line?
hi there
Just put enter and add a new line and save the file this warning will disappear