├── .coveralls.yml ├── .gitignore ├── .npmignore ├── .travis.yml ├── LICENSE ├── README.md ├── package.json └── src ├── .eslintrc ├── index.es6 └── test └── index.es6 /.coveralls.yml: -------------------------------------------------------------------------------- 1 | service_name: travis 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | 30 | #generated source 31 | dist/ 32 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | dist/test/ 3 | coverage/ 4 | .coveralls.yml 5 | .travis.yml 6 | .gitignore 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 7 5 | - 6 6 | - 4 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Vinnie Garcia 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # es6-module-starter 2 | [![npm version](https://badge.fury.io/js/es6-module-starter.svg)](http://badge.fury.io/js/es6-module-starter) 3 | [![travis build information](https://api.travis-ci.org/vinniegarcia/es6-module-starter.svg)](https://travis-ci.org/vinniegarcia/es6-module-starter) 4 | [![Coverage Status](https://coveralls.io/repos/vinniegarcia/es6-module-starter/badge.svg?branch=master)](https://coveralls.io/r/vinniegarcia/es6-module-starter?branch=master) 5 | 6 | Starter kit to create npm modules using ES6 and Babel with sensible defaults. 7 | 8 | ## Why use this? 9 | 10 | Want to create an [npm](https://npmjs.com/) module with [ES6](http://es6rocks.com/)? Don't want to wait for full node support? Don't want to mess around with creating all those directories and setting up babel and npm scripts? Then this is for you. 11 | 12 | ## How to get started 13 | 14 | 0. Install node and npm. 15 | 1. Clone this repo: `git clone https://github.com/vinniegarcia/es6-module-starter.git my-module-name` 16 | 2. Install dependencies: `npm i` 17 | 3. Start hacking like it's 2015! 18 | 19 | ## Modules used/included 20 | 21 | - *babel* - compiles ES6 source to ES5. The `--experimental` flag is also enabled so you can use ES7 features. 22 | - *tape* and *argg* for simple, effective testing with less magic than mocha or jasmine. 23 | - *Istanbul* to report test coverage. 24 | - *eslint* and *babel-eslint* to analyze your code for stylistic issues. 25 | - *plato* to analyze the complexity of your source code. 26 | - *coveralls* to send your test results to coveralls.io. 27 | 28 | These are just defaults. Feel free to swap out eslint for jshint, or tape for mocha, or whatever you use for CI instead of coveralls. 29 | 30 | ## Layout 31 | 32 | - `src/` - Your ES6 source code goes here. Files have a `.es6` extension for syntax highlighting in Sublime Text with [babel-sublime](https://github.com/babel/babel-sublime) 33 | - `src/tests/` - Your ES6 tests go here. 34 | - `src/.eslintrc` - ESLint configuration 35 | - `coverage/` - Code coverage reports are output here. 36 | - `dist/` - Your generated ES5 source is output here. This directory is under gitignore. 37 | - `.gitignore` - a sensible .gitignore file to prevent you from checking in generated source. 38 | - `.npmignore` - preconfigured to publish only the generated source code. 39 | - `package.json` - Customize this to publish your own module. 40 | - `.travis.yml` - Customize this if you use [Travis CI](https://travis-ci.org/) for builds. 41 | - `.coveralls.yml` - Customize this if you use [coveralls](https://coveralls.io/) for code coverage. 42 | - `README.md` - Delete all this and write your own. 43 | 44 | ## npm scripts 45 | 46 | These scripts are the main way to interact with your module as you develop it. 47 | 48 | - `compile` - run [babel](https://babeljs.io/) to compile your ES6 source to ES5. Output goes to the `dist/` directory. 49 | - `lint` - run [ESLint](http://eslint.org/) on your ES6 source and reports any style errors. 50 | - `tape` - test your code. 51 | - `coverage` - run [Istanbul](https://gotwarlost.github.io/istanbul/) on your code to report coverage. Reports output in HTML to the `coverage/istanbul` directory. 52 | - `istanbul` - run Istanbul, but output only lcov files for coveralls to read. 53 | - `coveralls` - run coveralls, using Istanbul's lcov report as input. 54 | - `plato` - run [plato](https://github.com/es-analysis/plato), a code analysis tool, on your generated source (plato doesn't support ES6 at the moment; as soon as it does I'll swap it to analyze ES6 source). 55 | - `test` - run tape, Istanbul, and coveralls. 56 | - `prepublish` - compiles your ES6 source to prepare for publishing to npm. 57 | 58 | ## Questions? 59 | 60 | File an [issue](https://github.com/vinniegarcia/es6-module-starter/issues) and I'll try to answer you. 61 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "es6-module-starter", 3 | "version": "2.0.0", 4 | "description": "Starter kit to create npm modules using ES6 and Babel with sensible defaults", 5 | "main": "dist/index.js", 6 | "scripts": { 7 | "dev": "babel-node src/index.es6", 8 | "lint": "eslint src/**/*.es6", 9 | "compile": "babel --stage 0 -d dist/ src/", 10 | "prepublish": "npm run compile", 11 | "tape": "babel-node node_modules/argg src/test/*.es6", 12 | "istanbul": "npm run compile && istanbul cover --dir coverage/istanbul node_modules/argg dist/test/*.js --report lcovonly", 13 | "coverage": "npm run compile && istanbul cover --dir coverage/istanbul node_modules/argg dist/test/*.js --report html", 14 | "coveralls": "cat ./coverage/istanbul/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", 15 | "plato": "plato -d coverage/plato dist/index.js", 16 | "test": "npm run istanbul && npm run coveralls" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/vinniegarcia/es6-module-starter.git" 21 | }, 22 | "keywords": [ 23 | "module", 24 | "npm", 25 | "starter", 26 | "boilerplate", 27 | "babel", 28 | "es6", 29 | "tape", 30 | "istanbul" 31 | ], 32 | "author": "Vinnie Garcia ", 33 | "license": "MIT", 34 | "devDependencies": { 35 | "argg": "0.0.2", 36 | "babel": "^5", 37 | "babel-eslint": "^4.1.0", 38 | "coveralls": "^2.11.4", 39 | "eslint": "^1.2.1", 40 | "istanbul": "^0.3.18", 41 | "plato": "^1.5.0", 42 | "tape": "^4.2.0" 43 | }, 44 | "dependencies": {} 45 | } 46 | -------------------------------------------------------------------------------- /src/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "parser": "babel-eslint", 4 | "env": { 5 | "browser": false, 6 | "es6": true, 7 | "node": true 8 | }, 9 | 10 | "rules": { 11 | "quotes": [2, "single"], 12 | "eol-last": [0], 13 | "no-mixed-requires": [0], 14 | "no-underscore-dangle": [0] 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/index.es6: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const name = 'ES6 Starter Kit', 4 | version = '1.0'; 5 | 6 | const myObject = { 7 | name, 8 | version 9 | }; 10 | 11 | 12 | export default myObject; 13 | -------------------------------------------------------------------------------- /src/test/index.es6: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | import test from 'tape'; 4 | import myObject from '../index'; 5 | 6 | test('Assert object values', (t) => { 7 | t.plan(2); 8 | t.equal(myObject.name, 'ES6 Starter Kit'); 9 | t.equal(myObject.version, '1.0'); 10 | }); 11 | --------------------------------------------------------------------------------