git init
or
| #!/bin/bash | |
| for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$') | |
| do | |
| git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes | |
| if [ $? -ne 0 ]; then | |
| echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint." | |
| exit 1 # exit with failure status | |
| fi | |
| done |
| var fs = require('fs'); | |
| var EventEmitter = require('events').EventEmitter; | |
| var pos = 0; | |
| var messenger = new EventEmitter(); | |
| messenger.on('message', function(msg) { console.log(++pos + " message:" + msg); | |
| }); | |
| console.log(++pos + " first"); |
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
const Article = require('../../../../app/models/article');Those suck for maintenance and they're ugly.