Skip to content

Commit

Permalink
add lint-staged - lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
boopathi committed Jan 20, 2018
1 parent 6ceffb8 commit 71b0b88
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 4 deletions.
8 changes: 8 additions & 0 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ To fix formatting and other auto-fixable eslint errors,
yarn fix
```

## Check Staged Files

Lint and Test staged files

```sh
yarn lint-staged
```

## Test

To run all tests,
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"jest-cli": "^22.0.3",
"lerna": "^2.5.1",
"lerna-changelog": "^0.7.0",
"lint-staged": "^6.0.1",
"markdown-table": "^1.1.1",
"minimist": "^1.2.0",
"prettier": "^1.9.2",
Expand Down Expand Up @@ -76,6 +77,13 @@
"/lib/"
]
},
"lint-staged": {
"*.js": [
"eslint --fix",
"./scripts/test-files.sh",
"git add"
]
},
"workspaces": [
"packages/*",
"utils/*"
Expand Down
21 changes: 21 additions & 0 deletions scripts/test-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR/..

normalize() {
node -e "console.log(require('path').normalize('$1'))"
}

PACKAGES_DIR=$(normalize $(pwd)/packages/)

FILES=""

for _file in $@; do
file=$(normalize $_file)
if [[ "${file##${PACKAGES_DIR}}" != "$file" ]]; then
FILES="$FILES $(dirname $(dirname $file))"
fi
done

yarn test --passWithNoTests $FILES
Loading

0 comments on commit 71b0b88

Please sign in to comment.