royriojas / esformatter-jsx

esformatter plugin: format jsx files (or js files with Facebook React JSX Syntax)
MIT License
142 stars 25 forks source link

.jsbeautifyrc can't parse correctly #111

Closed derakhshanfar closed 6 years ago

derakhshanfar commented 6 years ago

hi guys. my .jsbeautifyrc is like this but when i want to beautify my file, i get this error: .jsbeautifyrc can't parse correctly


{
  "plugins": [
    "esformatter-jsx"
  ],    
  "jsx": {
      "formatJSX": true, //Duh! that's the default 
      "attrsOnSameLineAsTag": false, // move each attribute to its own line 
      "maxAttrsOnTag": 1, // if lower or equal than 1 attributes, they will be kept on a single line 
      "firstAttributeOnSameLine": false, // keep the first attribute in the same line as the tag 
      "formatJSXExpressions": true, // default true, if false jsxExpressions won't be recursively formatted 
      "JSXExpressionsSingleLine": false, // default true, if false the JSXExpressions might span several lines 
      "alignWithFirstAttribute": false, // do not align attributes with the first tag 
      "spaceInJSXExpressionContainers": "", // default to one space. Make it empty if you don't like spaces between JSXExpressionContainers 
      "removeSpaceBeforeClosingJSX": false, // default false. if true <React.Something /> => <React.Something/> 
      "closingTagOnNewLine": false, // default false. if true attributes on multiple lines will close the tag on a new line 
      "JSXAttributeQuotes": "", // possible values "single" or "double". Leave it as empty string if you don't want to modify the attributes' quotes
      "htmlOptions": { // same as the ones passed to js-beautifier.html 
        "brace_style": "collapse",
        "indent_char": " ",
        "indent_size": 4,
        "max_preserve_newlines": 2,
        "preserve_newlines": true         
      }
  }
}

in developer tools i see that error: r.charCodeAt is not a function

royriojas commented 6 years ago

hi @derakhshanfar,

I'm a bit confused, this is supposed to work with esformatter not jsbeautify the config file for esformatter is usually called esformatter.json.

Any info that you could have about how are u trying to use this plugin will be useful.

derakhshanfar commented 6 years ago

hi @royriojas, this is esformatter config, jsbeautifyrc is just the name of file. i use vs code as editor with react-beautify extension and this extention use jsbeautifyrc as config, but it is just a name. the problem is related to react-beautify package after upgrade my vs code to 1.19.1.