2

Is there any code formatter plugin for Atom Editor & Sublime Text that respect .editorconfig & .jscsrc files?

For example, if my .editorconfig has the following settings

# 4 space indentation
[*.js]
indent_style = space
indent_size = 4

and .jscsrc does not state anything about indentation, I would like to see my code being indented with 4 spaces along with other rules specified at .jscsrc when I format the code (not auto format).

I would not prefer to maintain same configuration across multiple config files.

Sarbbottam
  • 5,410
  • 4
  • 30
  • 41

1 Answers1

2

Both Editors have plugins available to both lint and auto fix files according to your .jscsrc and .editorconfig files:


Sublime Text

.editorconfig - EditorConfig will format files automatically.

.jscsrc - SublimeLinter-jscs will do in-line linting for you, and SublimeJSCSFormatter will auto-format with the keyboard shortcuts:

  • Linux/Windows: Ctrl + Shift + H
  • Mac: Cmd + Shift + H

Atom

.editorconfig - EditorConfig will format files automatically (same name as the one for Sublime, different project).

.jscsrc - linter-jscs will do in-line linting for you, and jscs-fixer allows you to auto-format a file:

  • From Command Palette invoke jscs Fixer: Fix
  • Right-click on one of the selected files and choose Fix this file using jscs
  • Use the keyboard shortcut - Ctrl+⌂+J
Nick Bartlett
  • 4,865
  • 2
  • 24
  • 37
  • Thanks for your concerns, does it respect the .editorconfig file too? – Sarbbottam May 08 '15 at 04:39
  • @sarbbottam, added relevant options – Nick Bartlett May 08 '15 at 21:56
  • I have updated the OP with example could you take look? – Sarbbottam May 09 '15 at 17:15
  • The EditorConfig plugin will automatically format the code when you save the file based on your `.editorconfig` file. To format using your `.jscsrc` you currently only have the above options. So your work flow would look something like: 1. write code, 2. use keyboard shortcut to format code according to `.jscsrc`, 3. save file (code is formatted automatically according to `.editorconfig`). Though 2 and 3 are interchangeable. So you wouldn't need to maintain configuration against multiple files; just use either/both depending on the settings you need and there need not be duplicates. – Nick Bartlett May 09 '15 at 17:23