diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 720ddada29..54bd9ee3fb 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -7,15 +7,6 @@ var your => (code) => here; ``` -### Babylon/Babel Configuration - - -```js -{ - "your": { "config": "here" } -} -``` - ### Expected Behavior @@ -23,13 +14,3 @@ var your => (code) => here; ### Current Behavior - -### Your Environment - - -| software | version -| ---------------- | ------- -| Babylon | -| node | -| npm | -| Operating System | diff --git a/.gitignore b/.gitignore index 4dfb35cc7a..b48cbbc6ac 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ coverage lib node_modules npm-debug.log +lerna-debug.log diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 4ead0e1daf..0000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,13 +0,0 @@ -# Contributor Code of Conduct - -As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. - -We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion. - -Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. - -Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team. - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/) diff --git a/README.md b/README.md index a8de191c4d..8ecf084a25 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ -# babylon-lightscript +# @oigroup/babylon-lightscript + +> NB: This is a fork of babylon-lightscript which implements language changes that are not necessarily endorsed by upstream. Generally speaking, our intent is to closely follow the upstream language -- however, there may be notable deviations which are documented below. The parser for [LightScript](http://lightscript.org). -To be used with [babel-plugin-lightscript](https://github.com/lightscript/babel-plugin-lightscript). +To be used with [@oigroup/babel-plugin-lightscript](https://github.com/wcjohnson/babel-plugin-lightscript). A minimally-invasive fork of [Babylon](https://github.com/babel/babylon). With the exception of a few reserved keywords, it parses JS as JS unless the `"lightscript"` plugin is passed. - ### Contributing yarn @@ -17,3 +18,7 @@ it parses JS as JS unless the `"lightscript"` plugin is passed. New tests should go in the [lightscript](https://github.com/lightscript/babylon-lightscript/tree/lightscript/test/fixtures/lightscript) directory. + +### Deviations from LightScript proper + +None so far! diff --git a/package.json b/package.json index 2021894d0b..1a49cff2b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "babylon-lightscript", - "version": "0.4.1", + "name": "@oigroup/babylon-lightscript", + "version": "0.4.3", "description": "A LightScript parser, based on babylon (a JavaScript parser)", "author": "Alex Rattray ", "homepage": "http://lightscript.org/", diff --git a/src/plugins/lightscript.js b/src/plugins/lightscript.js index c33f34e6ca..96af4b709f 100644 --- a/src/plugins/lightscript.js +++ b/src/plugins/lightscript.js @@ -168,7 +168,7 @@ pp.parseNumericLiteralMember = function () { // c/p parseBlock -pp.parseWhiteBlock = function (allowDirectives?, isIfExpression?) { +pp.parseWhiteBlock = function (allowDirectives?, isIfExpression?, isArrowBody?) { const node = this.startNode(), indentLevel = this.state.indentLevel; // must start with colon or arrow @@ -197,7 +197,8 @@ pp.parseWhiteBlock = function (allowDirectives?, isIfExpression?) { // never parse directives if curly braces aren't used (TODO: document) this.parseBlockBody(node, false, false, indentLevel); this.addExtra(node, "curly", false); - if (!node.body.length) this.unexpected(node.start, "Expected an Indent or Statement"); + if (!isArrowBody && !node.body.length) + this.unexpected(node.start, "Expected an Indent or Statement"); return this.finishNode(node, "BlockStatement"); }; @@ -333,7 +334,7 @@ pp.parseArrowFunctionBody = function (node) { this.state.labels = []; this.state.inFunction = true; - node.body = this.parseWhiteBlock(true); + node.body = this.parseWhiteBlock(true, false, true); if (node.body.type !== "BlockStatement") { node.expression = true; diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/actual.js b/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/actual.js similarity index 100% rename from test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/actual.js rename to test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/actual.js diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json b/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json new file mode 100644 index 0000000000..8da8ceb211 --- /dev/null +++ b/test/fixtures/lightscript/named-arrow-functions/skinny-white-empty/expected.json @@ -0,0 +1,123 @@ +{ + "type": "File", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 9, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "sourceType": "script", + "body": [ + { + "type": "NamedArrowDeclaration", + "start": 0, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "id": { + "type": "Identifier", + "start": 0, + "end": 2, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 2 + }, + "identifierName": "fn" + }, + "name": "fn" + }, + "generator": false, + "expression": false, + "async": false, + "params": [], + "skinny": true, + "body": { + "type": "BlockStatement", + "start": 5, + "end": 7, + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 7 + } + }, + "body": [], + "directives": [], + "extra": { + "curly": false + } + } + }, + { + "type": "ExpressionStatement", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + } + }, + "expression": { + "type": "Identifier", + "start": 8, + "end": 9, + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 1 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json b/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json deleted file mode 100644 index f568ef6fed..0000000000 --- a/test/fixtures/lightscript/named-arrow-functions/skinny-white-malformed-dedent/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Expected an Indent or Statement (1:5)" -}