JonathanWolfe / prettier-eslint-formatter

VSCode plugin to format code with Prettier then ESLint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Prettier Eslint Formatter

Formats your file first through Prettier then with ESLint.

Requirements

  1. You must have Prettier (>= v1.13.0) and ESLint (>= v4.0.0) installed (either locally in your project, or globally).

3rd Party Tools Used

  1. eslint_d
  2. @fsouza/prettierd

Usage

Set this plugin as the default formatter for your filetype(s) in your workspace's or user settings.json. Disable the eslint source action (source.fixAll.eslint) on editor.codeActionsOnSave so that the ESLint vscode plugin does not format your file twice.

{
  "[javascript]": {
    "editor.defaultFormatter": "jonwolfe.prettier-eslint-formatter",
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": false
    }
  },
  "[javascriptreact]": {
    "editor.defaultFormatter": "jonwolfe.prettier-eslint-formatter",
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": false
    }
  },
  "[typescript]": {
    "editor.defaultFormatter": "jonwolfe.prettier-eslint-formatter",
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": false
    }
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "jonwolfe.prettier-eslint-formatter",
    "editor.codeActionsOnSave": {
      "source.fixAll.eslint": false
    }
  }
}

FAQ

  • "Do I need the prettier extension installed too?"
    • A: No, unless you want to use prettier by itself for some files (additional configuration like the provided example will need to be used)
  • "Do I need the eslint extension installed too?"
    • A: No, but you should anyway
  • "Can I set options for prettier or eslint like in their respective plugins?"
    • A: No, use config files like normal humans please. đź‘˝
  • "Sometimes it doesn't work?"
    • A: You might need to restart your vscode editor (> Developer: Reload Window in the command pallete). If the issue continues, then contact me.

Prior Art

About

VSCode plugin to format code with Prettier then ESLint

License:MIT License


Languages

Language:TypeScript 97.2%Language:JavaScript 2.8%