prettier / tslint-plugin-prettier

Runs Prettier as a TSLint rule and reports differences as individual TSLint issues

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto fix needs to be run several times to fix formatting

TimonVS opened this issue · comments

I sometimes have to run auto fix several times to fix code formatting.

Video demonstrating the bug: https://www.dropbox.com/s/7dy0pshmwx25nbk/tslint-autofix.mov?dl=0

I'm not sure if this is a tslint-plugin-prettier bug or a TSLint bug.

commented

Things to confirm:

  • Are there only tslint-plugin-prettier issues reported?
    • it might be suppressed by other rules if they report on the same place
  • Can you run prettier CLI directly to see if it's a prettier unstable problem?
  • Can you share the code snippet here so I can copy-paste to reproduce the issue?

Can you run prettier CLI directly to see if it's a prettier unstable problem?

Running prettier directly works fine: https://www.dropbox.com/s/kfv7694qfksrzaj/prettier.mov?dl=0

Can you share the code snippet here so I can copy-paste to reproduce the issue?

tslint.json:

{
  "defaultSeverity": "error",
  "extends": ["tslint-config-prettier"],
  "jsRules": {},
  "rulesDirectory": [
    "tslint-plugin-prettier"
  ],
  "rules": {
    "no-var-requires": false,
    "interface-name": false,
    "no-console": false,
    "curly": false,
    "object-literal-sort-keys": false,
    "prettier": {
      "severity": "warning"
    }
  }
}

.prettierrc

{
    "semi": false,
    "singleQuote": true
}

Code snippet:

function bar () {
  console.log("bar");

  console.log("bar");
}

class Hello {
  constructor () {





  }

  someMethod () {



    
  }
}

This is what happens, step for step:

function foo () {
  console.log("bar");


  console.log("bar"        );


  ^ cursor is here
}

After first auto fix:

function foo () {
  console.log("bar");


  console.log("bar"        );


^ cursor is here
}

After second auto fix:

function bar() {
  console.log('bar')

  console.log('bar')
}

class Hello {
  constructor() {}

  someMethod() {}
}

function foo() {
  console.log('bar')

  console.log('bar')
}
commented

Sorry, I cannot reproduce the issue.

kapture 2017-10-05 at 18 21 39

kapture 2017-10-05 at 18 25 38

That's so weird, I disabled all plugins except for TSLint and created a new workspace with just the config and code from above and I'm still having the issue :/.

This is my package.json by the way:

{
  "devDependencies": {
    "prettier": "^1.7.4",
    "tslint": "^5.7.0",
    "tslint-plugin-prettier": "^1.3.0",
    "typescript": "^2.5.3"
  }
}

Maybe we're using different versions of TSLint or Prettier?

commented

Looks like the same, weird.

{
  "dependencies": {
    "prettier": "^1.7.4",
    "tslint": "^5.7.0",
    "tslint-config-prettier": "^1.5.0",
    "tslint-plugin-prettier": "^1.3.0",
    "typescript": "^2.5.3"
  }
}

VSCode 1.16.1
TSLint extension: eg2.tslint v1.0.9

Yep, same plugin and VSCode version. And I don't have any formatting settings in my personal preferences. I'll check if coworkers are having the same issue.

I know this doesn't help much- but I've seen the same issue.

commented

Closing this issue for housekeeping purposes but feel free to open a new issue or comment here if you found how to reproduce.