Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tslint: Max-line-length not fixed by prettier

I'm using VSCode with prettier plugin and typescript and also tslint.

Leaving aside the convenience to use this configuration, I get a

[tslint] Exceeds maximum line length of 120 (max-line-length)

For a line like this:

import { MyComponent } from "../../some_very_long_path";

I've prettier configured with a print-width of 100, so I was expecting that on Format Document this line would be refactored into something like this:

import { MyComponent } 
  from "../../some_very_long_path";

or like this:

import {
  MyComponent
} from "../../some_very_long_path";

But it is not. Any ideas why?

like image 789
David Avatar asked Jan 22 '18 15:01

David


2 Answers

You can add exception for specific regex. Prettier will have the lead for managing imports and exports, since it has a special way to deal with them.

// edit your tslint.json
"max-line-length": [
     true, 
    { 
        "limit": 140, 
        "ignore-pattern": "^import |^export {(.*?)}" 
    }
],
like image 102
merlosy Avatar answered Sep 28 '22 05:09

merlosy


Prettier is not breaking down imports and the best thing you can do is to remove all the stylistic errors (including the max-line-length) from tslint rules and let Prettier to handle those and tslint the code related ones.

like image 23
Lipis Avatar answered Sep 28 '22 07:09

Lipis