Search code examples
formatwebstormeslintprettierprettier-eslint

Apply ESLint / Prettier to selected lines only


I'm working with WebStorm and there is only two possibilities to use ESLint :

  • Apply ESLint to file
  • Apply ESLint to a line

Isn't there a possibility to apply ESLint to a selection of multiple lines ?


Solution

  • There is no way to apply ESLint fix to selection in WebStorm, ESLint itself doesn't support range formatting/fixing. But you can import your code style preferences from .eslintrc and then use the built-in formatter (Code | Reformat Code) to format the selection.

    Note also that you can set up Prettier as your default formatter and then use it to format a selection with Code | Reformat Code