├── .babelrc ├── .eslintrc ├── .flowconfig ├── .gitignore ├── README.md ├── circle.yml ├── node_modules ├── src └── test ├── package.json ├── public └── index.html ├── src ├── decls │ └── externs.js ├── index.js └── package.json └── test ├── index-test.js ├── mocha.opts └── test-helper.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"], 3 | "plugins": [ 4 | "syntax-flow", 5 | "transform-flow-strip-types", 6 | "babel-plugin-syntax-jsx", 7 | "babel-plugin-inferno" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "node": true, 6 | "mocha": true, 7 | "jquery": true, 8 | "es6": true 9 | }, 10 | "globals": { 11 | }, 12 | "ecmaFeatures": { 13 | "generators": true, 14 | "forOf": true, 15 | "binaryLiterals": true, 16 | "classes": true, 17 | "defaultParams": true, 18 | "modules": true, 19 | "templateStrings": true, 20 | "unicodeCodePointEscapes": true, 21 | "objectLiteralDuplicateProperties": true, 22 | "objectLiteralShorthandProperties": true, 23 | "octalLiterals": true, 24 | "jsx": true, 25 | "destructuring": true, 26 | "objectLiteralComputedProperties": true, 27 | "arrowFunctions": true, 28 | "spread": true, 29 | "globalReturn": true, 30 | "objectLiteralShorthandMethods": true, 31 | "regexUFlag": true, 32 | "superInFunctions": true, 33 | "blockBindings": true, 34 | "regexYFlag": true 35 | }, 36 | "rules": { 37 | "strict": 0, 38 | "no-var": 2 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/.* 3 | 4 | [include] 5 | 6 | [libs] 7 | ./src/decls 8 | 9 | [options] 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/* 2 | !node_modules/src 3 | !node_modules/ui 4 | !node_modules/application 5 | !node_modules/domain 6 | !node_modules/framework 7 | !node_modules/test 8 | public/bundle.js 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Modern js project example recommended by mizchi 2 | 3 | - babel 4 | - flowtype 5 | - eslint 6 | - Test with mocha/power-assert 7 | - circle ci 8 | 9 | ## Install 10 | 11 | ```sh 12 | $ brew install flow # or other way to install flowtype 13 | 14 | $ npm install 15 | 16 | # run 17 | $ npm run watch # to develop 18 | # open public/index.html 19 | 20 | # develop 21 | npm test # to run test 22 | npm run lint # eslint 23 | npm run typecheck # flow 24 | ``` 25 | 26 | ## Recommended Env (mizchi's env) 27 | 28 | - Atom 29 | - linter-flow 30 | - linter-eslint 31 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | timezone: Asia/Tokyo 3 | node: 4 | version: 4 5 | dependencies: 6 | pre: 7 | - npm install 8 | cache_directories: 9 | - node_modules 10 | test: 11 | override: 12 | - npm run test:all:ci 13 | - npm run build 14 | general: 15 | branches: 16 | ignore: 17 | - gh-pages # list of branches to ignore 18 | -------------------------------------------------------------------------------- /node_modules/src: -------------------------------------------------------------------------------- 1 | ../src -------------------------------------------------------------------------------- /node_modules/test: -------------------------------------------------------------------------------- 1 | ../test -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "modern-js-stack-example", 3 | "version": "1.0.0", 4 | "description": "mizchi's stack", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "$(npm bin)/mocha", 8 | "test:all": "npm run typecheck && npm run lint && npm test", 9 | "test:all:ci": "npm run typecheck:ci && npm run lint && npm test", 10 | "typecheck": "flow", 11 | "typecheck:ci": "$(npm bin)/flow", 12 | "lint": "$(npm bin)/eslint src test", 13 | "watch": "$(npm bin)/watchify -v -t babelify -o public/bundle.js -d src/index.js", 14 | "build": "$(npm bin)/browserify -t babelify -o public/bundle.js src/index.js" 15 | }, 16 | "author": "mizchi", 17 | "license": "MIT", 18 | "devDependencies": { 19 | "babel-eslint": "^5.0.0", 20 | "babel-plugin-inferno": "^0.2.11", 21 | "babel-plugin-syntax-flow": "^6.5.0", 22 | "babel-plugin-syntax-jsx": "^6.5.0", 23 | "babel-plugin-transform-flow-strip-types": "^6.5.0", 24 | "babel-preset-es2015": "^6.6.0", 25 | "babelify": "^7.2.0", 26 | "browserify": "^13.0.0", 27 | "eslint": "^2.4.0", 28 | "espower-babel": "^4.0.1", 29 | "estraverse": "^4.2.0", 30 | "estraverse-fb": "^1.3.1", 31 | "flow-bin": "^0.22.1", 32 | "istanbul": "^0.4.2", 33 | "mocha": "^2.4.5", 34 | "power-assert": "^1.3.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/decls/externs.js: -------------------------------------------------------------------------------- 1 | // Ignore type check example 2 | declare var jQuery: any; 3 | declare var it: any; 4 | declare var xit: any; 5 | declare var context: any; 6 | declare var describe: any; 7 | declare var assert: any; 8 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | export function foo(x: number): number { 4 | return x * 10; 5 | } 6 | // this code causes type error 7 | // foo('Hello, world!'); 8 | 9 | console.log("hello world") 10 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "browserify": { 4 | "transform": "babelify" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /test/index-test.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | import {foo} from "../src/index" 3 | 4 | it ("multiply 10", () => { 5 | assert(foo(10) === 100); 6 | }) 7 | -------------------------------------------------------------------------------- /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --compilers js:espower-babel/guess 2 | --ui bdd 3 | --reporter dot 4 | --timeout 5000 5 | --recursive 6 | -------------------------------------------------------------------------------- /test/test-helper.js: -------------------------------------------------------------------------------- 1 | global.assert = require("power-assert"); 2 | --------------------------------------------------------------------------------