Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vscode format modified lines with eslint

There are several developers working in my current project with different coding styles. Therefore, I need to configure my vscode with settings:

  1. formatted only lines that were changed by me
  2. formatting should run only when saving
  3. possible to switch from eslint to tslint

My current config:

{
  "editor.formatOnPaste": false,
  "editor.formatOnType": false,
  "editor.formatOnSave": false,
  "editor.insertSpaces": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[typescript]": {
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": true
    }
  },
  "[javascript]": {
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": true
    }
  },
  "[json]": {
    "editor.formatOnSave": true
  },
}

Well, I would also hope to hear how developers solve a similar problem when working in Vim (because sometimes I use it). Thank you!

like image 879
Mikita Melnikau Avatar asked Oct 22 '25 22:10

Mikita Melnikau


1 Answers

The August 2020 update came with an option to "Only format modified" https://code.visualstudio.com/updates/v1_49#_only-format-modified-text That should cover 1. and 2. i belive.

If you want to format via eslint --fix, thats something that I'm looking for the answer to as well. only "eslint --fix" modified lines

like image 112
qonf Avatar answered Oct 25 '25 20:10

qonf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!