-
Notifications
You must be signed in to change notification settings - Fork 117
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
feat: allow explicitly fixing for lines_longer_than_80_chars #1334
Comments
I'm not sure what you have in mind here. The formatter's main job is to address that lint as best as it is able. You don't need to use |
Thanks @munificent for the quick reply. Let me try and rephrase and give a use-case for this. As far as I am concerned, doing
As for the use-case, say you have a Dart template generator, that you give inputs such as the project name. The output of the template generator will be some Dart code based on those inputs. For example, the generated code might include a class with a name based on the project name input. This might make, in some cases, the generated code surpass the 80 chars limit. Now consider the maintenance of the template generator, you would like to check that the template itself is well formatted (makes the maintenance of it much easier since it makes it "look nice to most human readers") but ignore/tolerate those longer lines due to the arbitrarily long input project name. There are different ways one could resolve the above use-case. A possible solution would be to fix only those lines longer than 80 chars after the generation, and consequently use the |
Trailing commas aren't the best example here since the formatter will be treating those as whitespace at some point (#1253), but in general, yes, if you just run
I'm sorry, I didn't quite follow this. Presumably the template has some concrete placeholder project name with some actual length. If you format the template with that placeholder name, the formatter will do whatever it needs to do to make the code look nice. Later, when an actual project name is substituted into the template, just format the result of that too. That might wrap some lines differently depending on whether the actual project name is longer or shorter than the placeholder was. Either way, it's fine. Just let the formatter do its thing on any code after you've transformed it, and the result will be as nice as the formatter can make it. |
Thanks again @munificent for the quick reply. I'm sorry the example use case wasn't clear enough. I can work around with the current Ideally, I would like to be explicit on what rule I'm trying to resolve with I understand than this might be quite complex if the changes made by rules overlap. Feel free to close this issue completely or in favour of #1333 🙌 |
Ah, OK. Yes, there are several lints that fire based on whitespace, and it's reasonable to maybe want to fix some but not others. But, in practice, supporting that would add a lot of complexity to the formatter (especially testing it, which is already quite hard). So even though it's reasonable, I don't think it would be worth the considerable engineering effort. In practice, almost all users just want the formatter to do everything it can do at once. |
Description
There is no option in
FormatCommand
to explicitly and only solve for thelines_longer_than_80_chars
linter rule.Additional Context
FormatCommand
#1333The text was updated successfully, but these errors were encountered: