{"name":"esformatter-jsx","version":"8.0.0","description":"esformatter plugin: format javascript files that contain React JSX Elements","repository":{"type":"git","url":"git+https://github.com/royriojas/esformatter-jsx.git"},"license":"MIT","author":{"name":"Roy Riojas","url":"http://royriojas.com"},"main":"lib/plugin.js","files":["lib/"],"engines":{"node":">=0.10.0"},"prepush":["npm run test"],"precommit":["npm run test"],"scripts":{"autofix":"npm run eslint -- --fix","_lint":"eslint --cache --cache-location='.cache/' -f 'node_modules/eslint-friendly-formatter' ","eslint":"npm run _lint -- 'src/**/*.js' 'specs/**/*.spec.js' ","test":"npm run verify && babel-node node_modules/.bin/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' npm run cover","verify":"npm run eslint","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 test","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 && babel-node runner.js","prepublish":"npm run build","build":"babel src/ -d lib/"},"keywords":["esformatter-plugin","esformatter","jsx","react jsx","AST","codestyle","react jsx"],"peerDependencies":{},"dependencies":{"babylon":"6.14.1","esformatter-ignore":"^0.1.3","extend":"3.0.0","js-beautify":"1.6.12","js-beautify-ejsx":"1.6.12"},"devDependencies":{"babel-cli":"6.18.0","babel-eslint":"7.1.1","babel-plugin-add-module-exports":"0.2.1","babel-plugin-transform-decorators-legacy":"1.3.4","babel-polyfill":"6.16.0","babel-preset-es2015":"6.18.0","babel-preset-react":"6.16.0","babel-preset-stage-0":"6.16.0","chalk":"^1.1.3","changelogx":"^1.0.18","colors":"^1.1.2","diff":"^2.2.3","esbeautifier":"^3.2.0","esformatter":"^0.9.5","esformatter-quotes":"^1.1.0","eslint":"3.11.0","eslint-config-airbnb":"13.0.0","eslint-friendly-formatter":"2.0.6","eslint-plugin-import":"2.2.0","eslint-plugin-jsx-a11y":"2.2.3","eslint-plugin-mocha":"4.7.0","eslint-plugin-react":"6.7.1","istanbul":"^0.3.17","mkdirp":"^0.5.1","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":"b96c0df97bd8e594c165f9423de9785e44c185da","bugs":{"url":"https://github.com/royriojas/esformatter-jsx/issues"},"homepage":"https://github.com/royriojas/esformatter-jsx#readme","_id":"esformatter-jsx@8.0.0","_shasum":"eaca04a14e394bd8ec8f8a0dfaeea1547205d903","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"royriojas","email":"royriojas@gmail.com"},"dist":{"shasum":"eaca04a14e394bd8ec8f8a0dfaeea1547205d903","tarball":"http://registry-npm.ywwl.com/esformatter-jsx/download/esformatter-jsx-8.0.0.tgz","integrity":"sha512-F5E7gq2QhLkpXwFpxlEPcYmqygf+zdoYyHC7neupNpAC/xV8IlrIbMLK26GJwIhH0ffBuvi+Yg+YndZpD8aUaQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEXpzipjkeTVg5j0FyB/RGBnfQQG639lvGDrzK3/6ZMaAiEA1QNduY9mzQRXazHohkvCdx1Xob7YT3g2Bss5HG/zvCY="}],"size":18124,"noattachment":false,"key":"/esformatter-jsx/-/esformatter-jsx-8.0.0.tgz"},"maintainers":[{"name":"royriojas","email":"royriojas@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/esformatter-jsx-8.0.0.tgz_1492039956401_0.040643201442435384"},"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":1492039957143,"_cnpm_publish_time":1492039957143,"dist-tags":{"latest":"8.0.1"}}