ESLint / Prettier -- enforce max-len / printWidth, but don't require it?

11,743

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.

Share:
11,743
Kirk Ross
Author by

Kirk Ross

I'm a singer/songwriter and web designer living in Pasadena, CA. Ironic trivia: my brother plays Gavin Belson on Silicon Valley.

Updated on June 27, 2022

Comments

  • Kirk Ross
    Kirk Ross almost 2 years

    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,
    };
    
  • JohnDoe
    JohnDoe over 3 years
    Your max-len rule should be formatted like this 'max-len': [1, { code: 100 }], for instance to set the line width of code, where 1 tells eslint to warn when longer than 100