-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3d8bcb1
Showing
12 changed files
with
2,529 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": [ | ||
"es2015", | ||
"stage-0" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
|
||
[*.js] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = false | ||
|
||
[.babelrc] | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = false | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = false | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Git | ||
.git/ | ||
|
||
# NPM | ||
node_modules/ | ||
|
||
# Lib | ||
lib/ | ||
|
||
# Coverage | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
language: node_js | ||
node_js: "6" | ||
|
||
cache: | ||
yarn: true | ||
|
||
env: | ||
global: | ||
- "NODE_ENV=test" | ||
- "YARN_VERSION=0.18.1" | ||
|
||
before_install: | ||
# Instal deps | ||
- "npm install -g yarn@${YARN_VERSION}" | ||
- "yarn global add coveralls --no-progress" | ||
- "(NODE_ENV=development && yarn install --ignore-scripts --no-progress)" | ||
- "yarn list" | ||
|
||
script: | ||
# Lint | ||
- "npm run lint" | ||
# Build | ||
- "npm run build" | ||
# Test | ||
- "npm run test-ci" | ||
|
||
after_script: | ||
# coveralls | ||
- "cat ./coverage/lcov.info | coveralls" | ||
|
||
branches: | ||
except: | ||
- gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Alexander Krivoshhekov <SuperPaintmanDeveloper@gmail.com> | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# babel-plugin-syntax-pipeline | ||
|
||
[![Build][travis-image]][travis-url] | ||
[![Test Coverage][coveralls-image]][coveralls-url] | ||
|
||
|
||
> Allow parsing of pipeline operator `|>` | ||
|
||
**Proposal**: [mindeavor/es-pipeline-operator][proposal-url] | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
|
||
## Installation | ||
|
||
```sh | ||
npm install --save-dev babel-plugin-syntax-pipeline | ||
|
||
# or | ||
|
||
yarn add --dev babel-plugin-syntax-pipeline | ||
``` | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
|
||
## Usage | ||
### Via `.babelrc` (Recommended) | ||
|
||
**.babelrc** | ||
|
||
```json | ||
{ | ||
"plugins": ["syntax-pipeline"] | ||
} | ||
``` | ||
|
||
|
||
### Via CLI | ||
|
||
```sh | ||
babel --plugins syntax-pipeline script.js | ||
``` | ||
|
||
### Via Node API | ||
|
||
```javascript | ||
require("babel-core").transform("code", { | ||
plugins: ["syntax-pipeline"] | ||
}); | ||
``` | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
## Build | ||
|
||
```sh | ||
npm run build | ||
``` | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
## Test | ||
|
||
```sh | ||
npm run test | ||
``` | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
|
||
## Contributing | ||
|
||
1. Fork it (<https://github.com/SuperPaintman/babel-plugin-syntax-pipeline/fork>) | ||
2. Create your feature branch (`git checkout -b feature/<feature_name>`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin feature/<feature_name>`) | ||
5. Create a new Pull Request | ||
|
||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
|
||
## Contributors | ||
|
||
- [SuperPaintman](https://github.com/SuperPaintman) SuperPaintman - creator, maintainer | ||
|
||
|
||
-------------------------------------------------------------------------------- | ||
|
||
|
||
## License | ||
|
||
[MIT][license-url] | ||
|
||
|
||
[license-url]: LICENSE | ||
[travis-image]: https://img.shields.io/travis/SuperPaintman/babel-plugin-syntax-pipeline/master.svg?label=linux | ||
[travis-url]: https://travis-ci.org/SuperPaintman/babel-plugin-syntax-pipeline | ||
[coveralls-image]: https://img.shields.io/coveralls/SuperPaintman/babel-plugin-syntax-pipeline/master.svg | ||
[coveralls-url]: https://coveralls.io/r/SuperPaintman/babel-plugin-syntax-pipeline?branch=master | ||
[proposal-url]: https://github.com/mindeavor/es-pipeline-operator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--reporter spec | ||
--timeout 10000 | ||
--slow 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"name": "babel-plugin-syntax-pipeline", | ||
"version": "0.1.0", | ||
"description": "Allow parsing of pipeline operator", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel src -d lib -s", | ||
"build:watch": "babel src -d lib -s -w", | ||
"lint": "echo 'TODO add linter'", | ||
"test": "mocha --opts ./mocha.opts ./lib/**/test.js", | ||
"test:watch": "mocha --opts ./mocha.opts --watch ./lib/**/test.js", | ||
"test-ci": "istanbul cover ./node_modules/mocha/bin/_mocha -- --opts ./mocha.opts ./lib/**/test.js", | ||
"prepublish": "npm run lint && npm run build && npm run test", | ||
"prepush": "npm run prepublish", | ||
"precommit": "npm run lint" | ||
}, | ||
"author": { | ||
"name": "SuperPaintman", | ||
"email": "SuperPaintmanDeveloper@gmail.com", | ||
"url": "https://superpaintman.com/" | ||
}, | ||
"license": "MIT", | ||
"keywords": [ | ||
"babel", | ||
"babel-plugin", | ||
"pipeline", | ||
"pipeline-operator" | ||
], | ||
"files": [ | ||
"LICENSE", | ||
"README.md", | ||
"lib/" | ||
], | ||
"dependencies": { | ||
"babylon": "6.13.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "6.24.0", | ||
"babel-core": "6.24.0", | ||
"babel-preset-es2015": "6.24.0", | ||
"babel-preset-stage-0": "6.22.0", | ||
"chai": "3.5.0", | ||
"husky": "0.13.2", | ||
"istanbul": "0.4.5", | ||
"mocha": "3.2.0", | ||
"source-map-support": "0.4.14" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/SuperPaintman/babel-plugin-syntax-pipeline.git" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
/** Imports */ | ||
import Parser, { plugins } from 'babylon/lib/parser'; | ||
import { TokenType, types as tt } from 'babylon/lib/tokenizer/types'; | ||
|
||
/** Constants */ | ||
const CHAR_CODES = '|>'.split('').map((c) => c.charCodeAt(0)); | ||
const PLUGIN_NAME = 'pipeline'; | ||
|
||
const beforeExpr = true; | ||
|
||
|
||
/** Types */ | ||
tt.pipeline = new TokenType('|>', { beforeExpr, binop: 12 }); | ||
|
||
|
||
/** Parser */ | ||
const pp = Parser.prototype; | ||
|
||
pp.readToken_pipeline = function readToken_pipeline(code) { | ||
return this.finishOp(tt.pipeline, 2); | ||
}; | ||
|
||
|
||
|
||
/** Plugin */ | ||
function plugin(instance) { | ||
instance.extend('readToken', (inner) => function readToken(code) { | ||
const next = this.input.charCodeAt(this.state.pos + 1); | ||
|
||
if (!(code === CHAR_CODES[0] && next === CHAR_CODES[1])) { | ||
return inner.call(this, code); | ||
} | ||
|
||
return this.readToken_pipeline(code); | ||
}); | ||
} | ||
|
||
|
||
/** Export */ | ||
plugins[PLUGIN_NAME] = plugin; | ||
|
||
export default function () { | ||
return { | ||
manipulateOptions(opts, parserOpts) { | ||
parserOpts.plugins.push(PLUGIN_NAME); | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
/** Imports */ | ||
import 'source-map-support/register'; | ||
|
||
process.env.NODE_ENV = 'test'; |
Oops, something went wrong.