Prettier auto-correct javascript "import" statement into an one line but then eslitnt 'max-len' rule breaks

Viewed 509

I have eslint setup with Prettier formatter in vscode.

there is this following original line,

import MyCustomComponentsIsThis 
   from 'queries/internal/consumer/MyCustomComponentsIsThis';

Prettier formatter always makes it into a single line as below

import MyCustomComponentsIsThis from 'queries/internal/consumer/MyCustomComponentsIsThis';

But this will break the esLint max-len rule so still shows it as error on vscode. How can i overide prettier to keep this like as above two lines of codes

1 Answers

Add an ignore pattern to your eslint config to ignore import lines:


      rules: {
        "max-len": [
          "error",
          {
            code: 88,
            comments: 86,
            ignoreUrls: true,
            ignoreTemplateLiterals: true,
            ignorePattern: "^import\\s.+\\sfrom\\s.+;$",
          },
        ],
      },
Related