-
Notifications
You must be signed in to change notification settings - Fork 889
Add fixer for max-line-length rule #3585
Comments
Probably not what you want to hear, but you may use Prettier in addition to your rules. |
In my setup I use Originally, I thought this should be handled by But since:
I believe that |
Just a heads up, I've mentioned this in other threads (#2814 (comment), #3395 (comment)), but my general advice to users looking for formatting has been to redirect them to prettier. It's pretty easy to use as a tslint plugin if you don't want to have to think about another CLI or editor plugin. I've gone ahead and filed an issue to signal this intent to TSLint users: #3592. Judging by how hard it's been to implement #3395 (still not yet merged), I think a fixer for |
Thanks for reply, I see your idea. But currently there's a problem with using the |
yeah, fair point. but part of the idea of prettier is that it's opinionated so you can't have much config. in practice it's less than 10 lines, for example https://github.com/palantir/blueprint/blob/master/packages/tslint-config/index.js#L60-L66 |
I agree, this would be awesome to have and would be trivial to implement. Some of us don't have the freedom to use Prettier in our projects, as much as we'd want it. |
My problem with Prettier is that I cannot use it for max-width reformatting without it also forcing 'else' statements to be on the same line as the closing brackets from the previous block while supporting newer typescript language features properly.
Since the team at prettier have rejected multiple repeated requests to permit customising/overriding the People at work have come to hate the way prettier inserts semi-colons in random places any time they save a file with an accidental syntax error (prettier starts inserting semis into random bits of jsx statements, completely screwing the file up - often turning a single syntax error into a dozen syntax errors), and the only alternatives are to set prettier to rip all semi-colons out instead (also extremely undesirable) or to simply stop using prettier. So there's a fairly strong desire to dump prettier entirely. Max width reformatting (aka 'condense to all as one line if it fits, or split to one line per field/item if not') is pretty much the only thing that prettier still offers us that can't be done with tslint alone. |
Given #4534 and the lack of activity on this issue for the last year, closing as out of scope. There are only two part-time TSLint maintainers and our efforts are not focused on formatting rules. If you need this, you can always fork the core TSLint Again, we understand that not everyone can or wants to be on Prettier, but we just don't have the bandwidth to support this fixer. |
Bug Report
TypeScript code being linted
with
tslint.json
configuration:Actual behavior
TSLint
gives[tslint] Exceeds maximum line length of 140 (max-line-length)
error, but does not provide any fixers.Expected behavior
It would be great if
TSLint
could provide ability to break a line into separate lines, where possible. For a given example ts line, the fix should convert it to something like:The text was updated successfully, but these errors were encountered: