diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..571b24c --- /dev/null +++ b/.babelrc @@ -0,0 +1,11 @@ +{ + "presets": [ + ["env", { + "targets": { + "browsers": ["last 2 versions"] + } + }], + "stage-0", + "flow" + ] +} diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..1fd98d2 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,33 @@ +{ + "parser": "babel-eslint", + "extends": "eslint:recommended", + + "plugins": [ + "import", + "flowtype" + ], + + "parserOptions": { + "sourceType": "module" + }, + + "globals": { + "require": true, + "console": true, + "document": true, + "process": true, + "module": true, + "__dirname": true + }, + + "env": { + "es6": true, + "jest": true, + "browser": true, + "node": true + }, + + "rules": { + "strict": [2, "never"] + } +} diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 0000000..2c569e0 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,23 @@ +[ignore] +/node_modules/.* +/dist/.* +.*\.config.* +.*\.test.* + +[include] +/src + +[libs] + +[options] +all=true +emoji=true +esproposal.class_instance_fields=ignore +esproposal.class_static_fields=ignore +esproposal.decorators=ignore +experimental.const_params=true +module.file_ext=.js +module.system.node.resolve_dirname=node_modules +module.system.node.resolve_dirname=src +module.system=node +module.use_strict=true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d665654 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +*.log +coverage +dist +doc +flow-typed +node_modules +package-lock.json +yarn.lock + +.* +!.babelrc +!.eslintrc +!.flowconfig +!.git* +!.tern-project +!.travis.yml diff --git a/.tern-project b/.tern-project new file mode 100644 index 0000000..7c5d468 --- /dev/null +++ b/.tern-project @@ -0,0 +1,10 @@ +{ + "libs": [ + "browser" + ], + "plugins": { + "node": {}, + "modules": {}, + "es_modules": {} + } +} diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5b12845 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "node" +after_success: + "npm run coveralls" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f957808 --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2017 Justin Krueger + +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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..d4a809a --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +# Proto ES2017+ + +[![TravisCI](https://img.shields.io/travis/kroogs/proto-es2017.svg)](https://travis-ci.org/kroogs/proto-es2017) +[![Coverage](https://img.shields.io/coveralls/kroogs/proto-es2017.svg)](https://coveralls.io/github/kroogs/proto-es2017) +[![Dependencies](https://img.shields.io/david/kroogs/proto-es2017.svg)](https://david-dm.org/kroogs/proto-es2017) +[![Dev Dependencies](https://img.shields.io/david/dev/kroogs/proto-es2017.svg)](https://david-dm.org/kroogs/proto-es2017?type=dev) +[![MIT License](https://img.shields.io/github/license/kroogs/proto-es2017.svg)](https://github.com/kroogs/proto-es2017/blob/master/LICENSE) + +> Spiffy boilerplate for building and testing with ES2017+. + +## Getting Started + + Clone and cd to `project_name`: + ``` + git clone https://github.com/kroogs/proto-es2017 project_name && cd project_name + ``` + + (Optional) Setup remotes: + ``` + git remote rename origin starter + git remote add origin + ``` + + Install dependencies: + ``` + npm install + ``` + +## Usage + + Watch `src` for changes: + ``` + npm start + ``` + + Run tests: + ``` + npm test + ``` + + Type check, reformat, lint: + ``` + npm run lint + ``` + + Produce minified bundle in `dist`: + ``` + npm run build + ``` diff --git a/package.json b/package.json new file mode 100644 index 0000000..fe37e62 --- /dev/null +++ b/package.json @@ -0,0 +1,64 @@ +{ + "name": "proto-es2017", + "version": "0.0.0", + "description": "Spiffy boilerplate for building and testing with ES2017+.", + "keywords": [], + "homepage": "https://github.com/kroogs/proto-es2017", + "author": "Justin Krueger ", + "contributors": [], + "private": "true", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/kroogs/proto-es2017.git" + }, + "bugs": { + "url": "https://github.com/kroogs/proto-es2017/issues" + }, + "main": "./dist/proto-es2017.js", + "files": [ + "dist", + "src", + "test" + ], + "scripts": { + "start": "webpack-dev-server", + "build": "webpack -p", + "test": "jest --coverage", + "test-dev": "jest --watch --coverage", + "coveralls": "cat ./coverage/lcov.info | coveralls", + "lint": "prettier --no-color --trailing-comma all --no-semi --single-quote --write \"src/**/*.js\" && eslint --fix src", + "prepublishOnly": "npm run lint && npm test && npm run build" + }, + "devDependencies": { + "babel-cli": "^6.24.1", + "babel-core": "^6.25.0", + "babel-eslint": "^7.2.3", + "babel-loader": "^7.1.1", + "babel-preset-env": "^1.6.0", + "babel-preset-flow": "^6.23.0", + "babel-preset-stage-0": "^6.24.1", + "coveralls": "^2.13.1", + "esdoc": "^1.0.1", + "esdoc-flow-plugin": "^1.0.0", + "esdoc-standard-plugin": "^1.0.0", + "eslint": "^4.3.0", + "eslint-plugin-flowtype": "^2.35.0", + "eslint-plugin-import": "^2.7.0", + "file-loader": "^0.11.2", + "flow": "^0.2.3", + "flow-bin": "^0.52.0", + "flow-typed": "^2.1.5", + "jest": "^20.0.4", + "jest-cli": "^20.0.4", + "prettier": "^1.5.3", + "webpack": "^3.4.1", + "webpack-dev-server": "^2.6.1" + }, + "jest": { + "moduleDirectories": [ + "node_modules", + "src" + ] + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..cf34392 --- /dev/null +++ b/src/index.js @@ -0,0 +1,8 @@ +/** + * Return the sum of the arguments. + * @param {...number} args - numbers to sum + * @return {number} + */ +export function sum(...args: number[]): number { + return args.reduce((total, current) => total + current, 0) +} diff --git a/src/index.test.js b/src/index.test.js new file mode 100644 index 0000000..a44c412 --- /dev/null +++ b/src/index.test.js @@ -0,0 +1,7 @@ +import { sum } from './index' + +describe('Proto ES2017+', function() { + test('#sum should add 1, 2, 3, and 4 to equal 10', () => { + expect(sum(1, 2, 3, 4)).toBe(10) + }) +}) diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..65732a9 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,48 @@ +const path = require('path') + +module.exports = { + context: __dirname, + entry: './src/index.js', + devtool: 'source-map', + + output: { + library: 'es2017-starter', + libraryTarget: 'umd', + path: path.resolve('dist'), + filename: 'es2017-starter.js', + }, + + resolve: { + extensions: ['.js'], + modules: [path.resolve('node_modules'), path.resolve('src')], + }, + + module: { + loaders: [ + { + use: ['babel-loader'], + test: /\.js$/, + exclude: [path.resolve('node_modules')], + }, + { + use: 'file-loader', + test: /.*/, + exclude: [/\.js$/], + }, + ], + }, + + watchOptions: { + ignored: /node_modules/, + }, + + devServer: { + port: 3030, + contentBase: path.resolve('src'), + stats: 'errors-only', + overlay: { + warnings: true, + errors: true, + }, + }, +}