{"name":"esformatter-jsx","version":"5.0.6","description":"esformatter plugin: format javascript files that contain React JSX blocks","repository":{"type":"git","url":"git+https://github.com/royriojas/esformatter-jsx.git"},"license":"MIT","author":{"name":"Roy Riojas","url":"http://royriojas.com"},"main":"index.js","files":["index.js","lib/"],"engines":{"node":">=0.10.0"},"prepush":["npm run check"],"precommit":["npm run check"],"scripts":{"beautify":"esbeautifier 'index.js' 'lib/**/*.js' 'specs/**/*.spec.js'","beautify-check":"esbeautifier -k 'index.js' 'lib/**/*.js' 'specs/**/*.spec.js'","eslint":"eslinter 'index.js' 'lib/**/*.js' 'specs/**/*.spec.js'","test":"npm run verify && mocha-runner 'specs/**/*.spec.js'","cover":"istanbul cover -x 'specs/**/*.spec.js' mocha-runner 'specs/**/*.spec.js' html text-summary","watch":"npm run cover && watch-spawn -p 'specs/**/*.spec.js' -p 'index.js' -p  npm run cover","lint":"npm run beautify && npm run eslint && npm test","verify":"npm run beautify-check && npm run eslint","check":"npm test","changelog":"changelogx -f markdown -o ./changelog.md","do-changelog":"npm run changelog && git add ./changelog.md && git commit -m 'DOC: Generate changelog' --no-verify","install-hooks":"prepush install && changelogx install-hook && precommit install","pre-v":"npm run check","post-v":"npm run do-changelog && git push --no-verify && git push --tags --no-verify","bump-major":"npm run pre-v && npm version major -m 'BLD: Release v%s' && npm run post-v","bump-minor":"npm run pre-v && npm version minor -m 'BLD: Release v%s' && npm run post-v","bump-patch":"npm run pre-v && npm version patch -m 'BLD: Release v%s' && npm run post-v","exec-demo":"cd demo && node runner.js"},"keywords":["esformatter-plugin","esformatter","jsx","react jsx","AST","codestyle","react jsx"],"peerDependencies":{},"dependencies":{"babylon":"6.1.21","esformatter-ignore":"^0.1.3","extend":"^2.0.1","fresh-falafel":"^1.2.0","js-beautify":"^1.5.10"},"devDependencies":{"changelogx":"^1.0.18","esbeautifier":"^3.2.0","esformatter":"^0.9.3","eslinter":"^3.2.0","istanbul":"^0.3.17","mocha-runner":"^1.1.2","precommit":"^1.2.0","prepush":"^3.1.8","proxyquire":"^1.6.0","read-json-sync":"^1.1.0","watch-spawn":"^1.0.3"},"changelogx":{"ignoreRegExp":["BLD: Release","DOC: Generate Changelog","Generated Changelog"],"issueIDRegExp":"#(\\d+)","commitURL":"https://github.com/royriojas/esformatter-jsx/commit/{0}","authorURL":"https://github.com/{0}","issueIDURL":"https://github.com/royriojas/esformatter-jsx/issues/{0}","projectName":"esformatter-jsx"},"gitHead":"41e38c1d03d7b6f9431a90afc43d95d975b3dca2","bugs":{"url":"https://github.com/royriojas/esformatter-jsx/issues"},"homepage":"https://github.com/royriojas/esformatter-jsx#readme","_id":"esformatter-jsx@5.0.6","_shasum":"1d7e73f15801dc92100b67e41dcc75f250fb1b97","_from":".","_npmVersion":"3.7.3","_nodeVersion":"5.6.0","_npmUser":{"name":"royriojas","email":"royriojas@gmail.com"},"dist":{"shasum":"1d7e73f15801dc92100b67e41dcc75f250fb1b97","tarball":"http://registry-npm.ywwl.com/esformatter-jsx/download/esformatter-jsx-5.0.6.tgz","integrity":"sha512-ilJwvmE203wU3spz7R9MThmsA8lm1JR3proTMHx+JQ3lKJZHA2EnFSa+WfbztW8/r+g32Z7K+8wQqzEOGTwfrQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDbOz5LbCO/GsdATgZHqC04xNVCdP/jGQQnrXx1Yte9/AIgJ5cqS1PS7pDTBxHdnDMTwQ1NvElVxM7BnG1XQN32ZwQ="}],"size":15329,"noattachment":false,"key":"/esformatter-jsx/-/esformatter-jsx-5.0.6.tgz"},"maintainers":[{"name":"royriojas","email":"royriojas@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/esformatter-jsx-5.0.6.tgz_1463996534165_0.33472598623484373"},"directories":{},"readme":"# [esformatter](https://github.com/millermedeiros/esformatter)-jsx\n> esformatter plugin: format javascript files that contain React JSX blocks\n\n[![NPM Version](http://img.shields.io/npm/v/esformatter-jsx.svg?style=flat)](https://npmjs.org/package/esformatter-jsx)\n[![Build Status](http://img.shields.io/travis/royriojas/esformatter-jsx.svg?style=flat)](https://travis-ci.org/royriojas/esformatter-jsx)\n\n## Demo\n\nLive demo: [esformatter-jsx](http://royriojas.com/resources/esformatter-jsx/)\n\n### Usage with [JSFMT](https://github.com/ionutvmi/sublime-jsfmt)\n\ncheck this [guide](https://github.com/royriojas/esformatter-jsx/wiki/Usage-with-jsfmt)\n\n### best configuration\n\nIf you're running into troubles with the formatting applied to your files I found this configuration to work the best:\n\n```javascript\n{\n  \"jsx\": {\n    \"formatJSX\": true, //Duh! that's the default\n    \"attrsOnSameLineAsTag\": false, // move each attribute to its own line\n    \"maxAttrsOnTag\": 3, // if lower or equal than 3 attributes, they will be kept on a single line\n    \"firstAttributeOnSameLine\": true, // keep the first attribute in the same line as the tag\n    \"formatJSXExpressions\": true, // default true, if false jsxExpressions won't be recursively formatted\n    \"JSXExpressionsSingleLine\": true, // default true, if false the JSXExpressions might span several lines\n    \"alignWithFirstAttribute\": false, // do not align attributes with the first tag\n    \"spaceInJSXExpressionContainers\": \" \", // default to one space. Make it empty if you don't like spaces between JSXExpressionContainers\n    \"removeSpaceBeforeClosingJSX\": false, // default false. if true <React.Something /> => <React.Something/>\n    \"closingTagOnNewLine\": false, // default false. if true attributes on multiple lines will close the tag on a new line\n    \"JSXAttributeQuotes\": \"\", // possible values \"single\" or \"double\". Leave it as empty string if you don't want to modify the attributes' quotes\n    \"htmlOptions\": {\n      // put here the options for js-beautify.html\n    }\n  }\n}\n```\n\n## Overview\n\n**Esformatter-jsx** is a plugin for [esformatter](https://github.com/millermedeiros/esformatter) meant to allow the\ncode formatting of jsx files or js files with React code blocks, using [js-beautify](https://www.npmjs.com/package/js-beautify) to\nbeautify the \"html like\" syntax of the react components. **Use at your own risk**. I have tested this against complex JSX structures and seems to be workfing fine, but bugs might appear, so don't blame me :).\n\nIt works for my main use case and I hope it works for you too.\n\nThis plugin is based on [esformatter-jsx-ignore](https://github.com/royriojas/esformatter-jsx-ignore)\n\nIf you want a bit of history about what this plugin was develop, check:\n- https://github.com/millermedeiros/esformatter/issues/242\n- https://github.com/facebook/esprima/issues/74\n\nSo this plugin will turn this:\n```js\nvar React = require('react');\n\nvar Hello = React.createClass({\nrender: function () {\nreturn (<div\n\nclassName=\"hello-div\">{this.props.message}</div>)\n;\n}\n});\n\nReact.render(<Hello\nmessage=\"world\"/>,      document.body);\n```\n\ninto:\n```js\nvar React = require('react');\n\nvar Hello = React.createClass({\n  render: function() {\n    return (\n    <div className=\"hello-div\">\n      {this.props.message}\n    </div>\n    );\n  }\n});\n\nReact.render(<Hello message=\"world\"/>, document.body);\n```\n\n## Installation\n\n```sh\n$ npm install esformatter-jsx --save-dev\n```\n\n## Config\n\nNewest esformatter versions autoload plugins from your `node_modules` [See this](https://github.com/millermedeiros/esformatter#plugins)\n\nAdd to your esformatter config file:\n\nIn order for this to work, this plugin should be the first one! (I Know too picky, but who isn't).\n\n```javascript\n{\n  \"plugins\": [\n    \"esformatter-jsx\"\n  ],\n  // this is the section this plugin will use to store the settings for the jsx formatting\n  \"jsx\": {\n    // whether to recursively format jsx expressions with esformatter\n    // set this to false if you don't want JSXExpressions to be formatted recursively, like when using problematic plugins\n    \"formatJSXExpressions\": true,\n    // By default ObjectExpression and ArrayExpression in JSXExpressions are inlined,\n    // if false, the Expression might expand several lines\n    \"JSXExpressionsSingleLine\": true,\n    // by default is true if set to false it works the same as esformatter-jsx-ignore\n    \"formatJSX\": true,\n    // keep the node attributes on the same line as the open tag. Default is true.\n    // Setting this to false will put each one of the attributes on a single line\n    \"attrsOnSameLineAsTag\": true,\n     // how many attributes should the node have before having to put each\n     // attribute in a new line. Default 1\n    \"maxAttrsOnTag\": 1,\n    // if the attributes are going to be put each one on its own line, then keep the first\n    // on the same line as the open tag\n    \"firstAttributeOnSameLine\": false,\n    // default to one space. Make it empty if you don't like spaces between JSXExpressionContainers\n    \"spaceInJSXExpressionContainers\": \" \",\n    // align the attributes with the first attribute (if the first attribute was kept on the same line as on the open tag)\n    \"alignWithFirstAttribute\": true,\n    \"htmlOptions\": { // same as the ones passed to js-beautifier.html\n      \"brace_style\": \"collapse\",\n      \"indent_char\": \" \",\n      \"indent_size\": 2,\n      \"max_preserve_newlines\": 2,\n      \"preserve_newlines\": true\n      //wrap_line_length: 250\n    }\n  }\n}\n```\n\nThe `htmlOptions` are passed directly to [js-beautify](https://www.npmjs.com/package/js-beautify), please check its\ndocumentation for all the possible options.\n\nOr you can manually register your plugin:\n\n```js\n// register plugin\nesformatter.register(require('esformatter-jsx'));\n```\n\n## Usage\n\n```js\nvar fs = require('fs');\nvar esformatter = require('esformatter');\n//register plugin manually\nesformatter.register(require('esformatter-jsx'));\n\nvar str = fs.readFileSync('someKewlFile.js').toString();\nvar output = esformatter.format(str);\n//-> output will now contain the formatted code\n```\n\nSee [esformatter](https://github.com/millermedeiros/esformatter) for more options and further usage info.\n\n## License\n\n[MIT](License)\n","publish_time":1463996536541,"_cnpm_publish_time":1463996536541,"dist-tags":{"latest":"8.0.1"}}