Is there a way to configure ESLint w/ Prettier to enforce the max-len / printWidth rule but not require it? That is to say, allow you to add line breaks as you see fit?
// eslintrc.js
"max-len": [0, 160, 2, { ignoreUrls: true }],
// prettier.config.js
module.exports = {
trailingComma: "all",
tabWidth: 2,
semi: true,
singleQuote: false,
printWidth: 160,
};
It just does not seem to recognize any sort of printWidth at all (i.e. max-len rule ). My ESLint config extends airbnb, so it should infer 100.
Set print-width to 999 in prettier to turn it off, then set the eslint max-len rule to be a warning at what ever your preferred value is.
You are ready to use Prettier and ESLint in your project without worrying about any conflicts. ESLint knows about all your Prettier rules by integrating all the rules that are enforced by it and removing all the rules that could conflict with it. Now there shouldn't be anything in your way for an improved code style and structure.
However, when humans write code, they don’t strive to reach the maximum number of columns on every line. Developers often use whitespace to break up long lines for readability. In practice, the average line length often ends up well below the maximum. Prettier’s printWidth option does not work the same way.
Set print-width
to 999 in prettier to turn it off, then set the eslint max-len
rule to be a warning at what ever your preferred value is.
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