├── .babelrc ├── CHANGELOG.md ├── .npmignore ├── .gitignore ├── .travis.yml ├── .eslintrc ├── src └── index.js ├── test └── Counter.spec.js ├── README.md └── package.json /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | presets: ["es2015", "stage-0"] 3 | } -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 0.1.0 / 2015-11-22 2 | ================== 3 | - Add description here 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.log 3 | node_modules 4 | src 5 | test 6 | examples 7 | coverage 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log 3 | *.pid 4 | *.seed 5 | .DS_Store 6 | lib 7 | coverage 8 | logs 9 | pids 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "5" 4 | - "4" 5 | script: 6 | - npm run lint 7 | - npm test 8 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | root: true 2 | 3 | env: 4 | es6: true 5 | node: true 6 | browser: true 7 | mocha: true 8 | 9 | ecmaFeatures: 10 | modules: true 11 | 12 | extends: 13 | "airbnb" 14 | 15 | rules: 16 | quotes: 0 17 | func-names: 0 18 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | class Person { 2 | constructor(name, age) { 3 | this.name = name; 4 | this.age = age; 5 | } 6 | 7 | getName() { 8 | return this.name; 9 | } 10 | 11 | getAge() { 12 | return this.age; 13 | } 14 | } 15 | 16 | export default Person; 17 | -------------------------------------------------------------------------------- /test/Counter.spec.js: -------------------------------------------------------------------------------- 1 | import { expect } from 'chai'; 2 | import Person from '../src/index.js'; 3 | 4 | describe("Person", () => { 5 | let person; 6 | 7 | before(() => { 8 | person = new Person('Cam', 99); 9 | }); 10 | 11 | after(() => { 12 | person = undefined; 13 | }); 14 | 15 | it("should return name", function() { 16 | expect(person.getName()).to.equal('Cam'); 17 | }); 18 | 19 | it("should return age", function() { 20 | expect(person.getAge()).to.equal(99); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # babel-npm-boilerplate [![Build Status](https://travis-ci.org/camsong/babel-npm-boilerplate.svg)](https://travis-ci.org/camsong/babel-npm-boilerplate) [![npm version](https://badge.fury.io/js/babel-npm-boilerplate.svg)](http://badge.fury.io/js/babel-npm-boilerplate) 2 | 3 | A Boilerplate for creating NPM packages using Babel, ESLint, Mocha and Chai 4 | 5 | 6 | ## What's inside 7 | 8 | Minimal structure for a npm package source. 9 | 10 | * Babel 6 11 | * Mocha 12 | * ESLint 13 | * Isparta 14 | 15 | ## Installation 16 | 17 | Clone this repo or download using `npm` 18 | 19 | ``` 20 | npm install babel-npm-boilerplate --save 21 | ``` 22 | 23 | ## Usage 24 | 25 | * `npm run test` to run tests 26 | * `npm run test-cov` to generate test coverage 27 | * `npm run build` to transform es6/es7 to es5 by Babel 28 | * `npm run clean` to clean `build/` directory 29 | * `npm run lint` to lint js using ESLint in Airbnb's Javascript style 30 | 31 | ## Liscense 32 | 33 | MIT 34 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-npm-boilerplate", 3 | "author": "Cam Song", 4 | "version": "0.2.0", 5 | "description": "A Boilerplate for creating NPM packages using Babel, ESLint, Mocha and Chai", 6 | "main": "build/index.js", 7 | "keywords": [ 8 | "es6", 9 | "babel", 10 | "eslint", 11 | "npm package" 12 | ], 13 | "scripts": { 14 | "test": "mocha --compilers js:babel-core/register --recursive", 15 | "test-cov": "babel-node isparta cover --report html --report text node_modules/.bin/_mocha", 16 | "build": "babel src --out-dir build", 17 | "clean": "rm -rf build", 18 | "lint": "eslint src test" 19 | }, 20 | "dependencies": {}, 21 | "devDependencies": { 22 | "babel-core": "^6.1.21", 23 | "babel-eslint": "^4.1.5", 24 | "babel-preset-es2015": "^6.1.18", 25 | "babel-preset-stage-0": "^6.1.18", 26 | "chai": "^3.4.1", 27 | "eslint": "^1.9.0", 28 | "eslint-config-airbnb": "^1.0.0", 29 | "eslint-plugin-react": "^3.10.0", 30 | "isparta": "^4.0.0", 31 | "mocha": "^2.3.4" 32 | }, 33 | "repository": { 34 | "type": "git", 35 | "url": "git+https://github.com/camsong/babel-npm-boilerplate.git" 36 | }, 37 | "bugs": { 38 | "url": "https://github.com/camsong/babel-npm-boilerplate/issues" 39 | }, 40 | "homepage": "https://github.com/camsong/babel-npm-boilerplate#readme", 41 | "license": "MIT" 42 | } 43 | --------------------------------------------------------------------------------