I'm running Prettier.js (VSCode plugin)/prettier-eslint-cli
. It formats method arguments that go over the 80 character limit as the following (putting each argument on a new line).
someMethod( argumentOne, argumentTwo, argumentThree, argumentFour, argumentFive, // Hits 80 character word wrap here argumentSix, argumentSeven ) { // Some codes }
Is there a way to modify the options so it formats the arguments to try to fit 80 characters on each row? Instead of just adding them to a new line each time.
someMethod(argumentOne, argumentTwo, argumentThree, argumentFour, argumentFive, argumentSix, argumentSeven) { // Some codes }
Benefits of using Prettier and ESLint As mentioned earlier, whereas Prettier takes care of your code formatting, ESLint takes care of your code style. The former does everything automatically for you. If you have set up Prettier, you can configure it to format your file on saving it.
The printWidth option is more of a guideline to Prettier than a hard rule. It is not the upper allowed line length limit. It is a way to say to Prettier roughly how long you'd like lines to be. Prettier will make both shorter and longer lines, but generally strive to meet the specified print width.
Prettier enforces a consistent code style (i.e. code formatting that won't affect the AST) across your entire codebase because it disregards the original styling* by parsing it away and re-printing the parsed AST with its own rules that take the maximum line length into account, wrapping code when necessary.
As far as I know, for now, there isn't an option for doing so. When your arguments get over the printWidth ( default 80), prettier will break each argument into a separate line.
One way could be to increase the printWidth option so that your arguments stay on the same line. The prettier documentation mentions maximum line length rules are often set to 100 or 120
(https://prettier.io/docs/en/options.html)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With