Coder Social home page Coder Social logo

astring-jsx's Introduction

astring-jsx

This module wraps astring to provide support for JSX syntax.

Docs

see: astring


Copyright (c) 2016 Stephen Belanger

Licensed under MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

astring-jsx's People

Contributors

qard avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

astring-jsx's Issues

Action required: Greenkeeper could not be activated šŸšØ

šŸšØ You need to enable Continuous Integration on all branches of this repository. šŸšØ

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you donā€™t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, youā€™ll need to re-trigger Greenkeeperā€™s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integrationā€™s white list on Github. You'll find this list on your repo or organizationā€™s settings page, under Installed GitHub Apps.

Action required: Greenkeeper could not be activated šŸšØ

šŸšØ You need to enable Continuous Integration on Greenkeeper branches of this repository. šŸšØ

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didnā€™t receive a CI status on the greenkeeper/initial branch, itā€™s possible that you donā€™t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how itā€™s configured. Make sure it is set to run on all new branches. If you donā€™t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, youā€™ll need to re-trigger Greenkeeperā€™s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Action required: Greenkeeper could not be activated šŸšØ

šŸšØ You need to enable Continuous Integration on all branches of this repository. šŸšØ

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you donā€™t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, youā€™ll need to re-trigger Greenkeeperā€™s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integrationā€™s white list on Github. You'll find this list on your repo or organizationā€™s settings page, under Installed GitHub Apps.

Add JSXText, JSXFragment, JSXEmptyExpression

Thanks for your work on this project! šŸ‘šŸ¼

We seem to be missing JSXText and JSXFragment helpers, which is what the diff below adds, let me know if you'd want to go ahead with a PR?

diff --git a/node_modules/astring-jsx/index.js b/node_modules/astring-jsx/index.js
index 809b217..b058268 100644
--- a/node_modules/astring-jsx/index.js
+++ b/node_modules/astring-jsx/index.js
@@ -54,6 +54,10 @@ var generator = Object.assign({
     output.write('=');
     this[node.value.type](node.value, state);
   },
+  JSXText: function JSXText(node,state){
+    var output = state.output;
+    output.write(node.value);
+  },
   // namespaced:attr="something"
   JSXNamespacedName: function JSXNamespacedName(node, state) {
     var output = state.output;
@@ -65,9 +69,21 @@ var generator = Object.assign({
   JSXExpressionContainer: function JSXExpressionContainer(node, state) {
     var output = state.output;
     output.write('{');
+    console.log({node});
     this[node.expression.type](node.expression, state);
     output.write('}');
   },
+  JSXEmptyExpression: function JSXEmptyExpression(node,state){
+    // do nothing
+  },
+  JSXFragment: function JSXFragment(node, state) {
+    var output = state.output
+    output.write("<>")
+    for (child of node.children){
+      this[child.type](child,state)
+    }
+    output.write("</>")
+  },
 }, astring.defaultGenerator);
 
 function astringJsx (ast, options) {

Missing JSXText method

/node_modules/astring-jsx/index.js:14
        this[child.type](child, state);
                        ^

TypeError: this[child.type] is not a function
    at Object.JSXElement (/node_modules/astring-jsx/index.js:14:25)
    at Object.ReturnStatement (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:421:28)
    at Object.BlockStatement (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:300:25)
    at Object.MethodDefinition (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:664:29)
    at Object.BlockStatement (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:300:25)
    at Object.ClassDeclaration (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:549:8)
    at Object.Program (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:274:24)
    at astring (/node_modules/astring-jsx/node_modules/astring/dist/astring.js:1021:28)
    at astringJsx (/node_modules/astring-jsx/index.js:74:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.