Skip to content

Instantly share code, notes, and snippets.

@fforres
Last active March 3, 2018 23:39
Show Gist options
  • Save fforres/c29a973e047e171e14946938bf0a49f1 to your computer and use it in GitHub Desktop.
Save fforres/c29a973e047e171e14946938bf0a49f1 to your computer and use it in GitHub Desktop.
New nodejs projects setup
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# next.js build output
.next
  • npm init --force
  • yarn add eslint lint-staged husky prettier cross-env nodemon eslint-plugin-prettier eslint-config-prettier
  • touch .gitignore
  • npx eslint --init

Add to package.json

 "scripts": {
    (...),
    "precommit": "lint-staged",
    "start": "cross-env NODE_ENV=production node ./src/index.js",
    "dev": "nodemon ./src/index.js"
 }
 
 
 "lint-staged": {
    "*.js": [
      "prettier --write --single-quote --no-semi",
      "eslint --fix",
      "git add"
    ],
    "*.json": [
      "prettier --write --single-quote --no-semi",
      "git add"
    ]
  },
  "prettier": {
    "semi": true,
    "singleQuote": true
  },

add to .eslintrc

{
 "extends": ["plugin:prettier/recommended"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment