Usage with jsfmt
Roy Riojas edited this page on May 5 2016 · 2 revisions
Pages 2
Clone this wiki locally
Clone in DesktopInstall jsfmt sublime package
Please follow these instructions
Install latest esformatter
# go to the jsfmt package folder
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/jsfmt/
There run
# install both esformatter and esformatter-jsx
npm i esformatter@latest esformatter-jsx@latest
make sure you don't have other esformatter instances
npm ls esformatter
npm ls esformatter-jsx
The output from the commands above should only display the latest esformatter/esformatter-jsx versions.
Add to your JSFMT user settings file
// add to your
{
"extensions":
[
"js",
"jsx",
"sublime-settings"
],
"options": {
"plugins": [
"esformatter-jsx",
],
"jsx": {
"formatJSX": true,
// change these to your preferred values
// refer to https://github.com/royriojas/esformatter-jsx#best-configuration for more options
"attrsOnSameLineAsTag": false,
"maxAttrsOnTag": 1,
"firstAttributeOnSameLine": false,
"alignWithFirstAttribute": true
}
// other esformatter options
}
}
Troubleshooting
Still does not work!
-
Make sure you're using the latest version of
esformatter
andesformatter-jsx
. Make sure there are not other versions of the module in anynode_modules
folder inside thejsfmt
folder -
Make sure you have added the
jsx
block to thejsfmt.sublime-settings
file for the user preferences. -
File a bug in either the
jsfmt
repo oresformatter-jsx
repo. I will happily try to help you make it work!
前端工程师、程序员