Last active
June 14, 2017 17:24
-
-
Save teekaay/df9d215b0f580c8207c704b1d1e8ab98 to your computer and use it in GitHub Desktop.
Personal package.json for ES2015 projects with jest (unit testing), eslint (code quality) and pre-commit (git integration)
This file contains hidden or 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
| { | |
| "parserOptions": { | |
| "ecmaVersion": 6, | |
| "sourceType": "module" | |
| }, | |
| "env": { | |
| "node": true, | |
| "es6": true | |
| }, | |
| "extends": ["eslint:recommended"], | |
| "rules": { | |
| "semi": 2 | |
| } | |
| } |
This file contains hidden or 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
| #!/usr/bin/env bash | |
| # Bootstraps a node.js project. | |
| # https://gist.github.com/teekaay/df9d215b0f580c8207c704b1d1e8ab98 | |
| # | |
| # Generates the following folder structure: | |
| # package.json | |
| # README.md | |
| # .gitignore | |
| # .eslintrc | |
| # lib | |
| # |- index.js | |
| # | |
| # Installed packages: eslint, jest, pre-commit | |
| PKG_JSON_GIST='https://gist.githubusercontent.com/teekaay/df9d215b0f580c8207c704b1d1e8ab98/raw/7ce302d067af2215715cbe6b5d3cd71282f72fe8/package.json' | |
| ESLINT_GIST='https://gist.githubusercontent.com/teekaay/df9d215b0f580c8207c704b1d1e8ab98/raw/7ce302d067af2215715cbe6b5d3cd71282f72fe8/.eslintrc' | |
| PROJECT_NAME="${1}" | |
| if [ -z "$1" ]; then | |
| echo "Usage: $(basename "$0") <project-name>" | |
| exit 1 | |
| fi | |
| if [ -d "${PROJECT_NAME}" ]; then | |
| echo "Project ${PROJECT_NAME} already exists" | |
| exit 1 | |
| fi | |
| mkdir "${PROJECT_NAME}" | |
| pushd "${PROJECT_NAME}" | |
| curl -O "${PKG_JSON_GIST}" | |
| curl -O "${ESLINT_GIST}" | |
| npm install | |
| mkdir lib | |
| touch lib/index.js | |
| touch .gitignore | |
| echo "node_modules" >> .gitignore | |
| echo "coverage" >> .gitignore | |
| touch README.md | |
| echo "# ${PROJECT_NAME}" >> README.md |
This file contains hidden or 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
| { | |
| "name": "sample-project", | |
| "version": "1.0.0", | |
| "description": "", | |
| "author": "Thomas Klinger", | |
| "license": "MIT", | |
| "main": "index.js", | |
| "pre-commit": [ | |
| "test", | |
| "lint" | |
| ], | |
| "scripts": { | |
| "test": "./node_modules/.bin/jest", | |
| "test:watch": "npm run test -- --watchAll", | |
| "test:cov": "npm run test -- --coverage", | |
| "lint": "./node_modules/.bin/eslint lib/**/*.js -f table --ignore-pattern 'lib/**/*-test.js'" | |
| }, | |
| "devDependencies": { | |
| "eslint": "^4.0.0", | |
| "jest": "^20.0.4", | |
| "pre-commit": "^1.2.2" | |
| }, | |
| "jest": { | |
| "bail": true, | |
| "verbose": true, | |
| "notify": true, | |
| "testRegex": ".*-test.js$" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment