ESLint-Formatter for Sublime Text 3
Sublime Text 3 Plugin to autoformat your javascript code according to the ESLint configuration files you already have.
This plugin formats but does not lint your code. To also enable linting, use this plugin in conjuction with SublimeLinter-eslint.
This Sublime Text Plugin depends on a valid installation of eslint version 3 or higher. To install eslint
, follow the getting started guide: http://eslint.org/docs/user-guide/getting-started.
Please use Package Control to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.
To install via Package Control, do the following:
-
Within Sublime Text, bring up the Command Palette and type
install
. Among the commands you should seePackage Control: Install Package
. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins. -
When the plugin list appears, type
eslint format
. Among the entries you should seeESLint-Formatter
. If that entry is not highlighted, use the keyboard or mouse to select it.
Command palette:
- ESLintFormatter: Format this file
Shortcut key:
- Linux/Windows: [Ctrl + Shift + H]
- Mac: [Cmd + Shift + H]
The formatting will be applied to the last saved state of a file, not the current buffer.
If not using the format_on_save: true
option, you have to save your file first and then run the command.
By default, ESLintFormatter will supply the following settings:
- Modify any settings within the
Preferences -> Package Settings -> ESLint-Formatter -> Settings - User
file.
Project-specific settings override
To override global plugin configuration for a specific project, add a settings object with a ESLint-Formatter
key in your .sublime-project
. This file is accessible via Project -> Edit Project
.
For example:
{
"folders": [
{
"path": "."
}
],
"settings": {
"ESLint-Formatter": {
"format_on_save": true
}
}
}
If you experience performance issues, it may be worth taking a look at eslint_d
. You can modify the settings to point to the eslint_d
binary instead of eslint
.
For example:
{
"local_eslint_path": {
"osx": "node_modules/.bin/eslint_d"
}
}
If you find any bugs feel free to report them here.
Pull requests are also encouraged.