Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Commit

Permalink
Merge pull request #28 from magopian/27-prettier-with-useful-output
Browse files Browse the repository at this point in the history
Better output when running lint:prettier
  • Loading branch information
magopian committed Mar 9, 2018
2 parents 5050b01 + 912dfc5 commit 814d1e0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions lint_problems.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -eo pipefail

prelude() {
echo "
You have prettier linting errors!
----------------------------------
The following files would turn out different if you process them with prettier.
"
}

any=false
first=true
while read line
do
$first && prelude
echo "To fix:"
echo " prettier --write ${line}"
echo "To see:"
echo " prettier ${line} | diff ${line} -"
echo ""
# echo "$line"
any=true
first=false
done < "${1:-/dev/stdin}"


$any && echo "
If you're not interested in how they're different, consider running:
yarn run lint:prettierfix
"

$any && exit 1 || exit 0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"eject": "react-scripts eject",
"lint:flow": "flow",
"lint:less": "stylelint 'src/**/*.less' --config .stylelintrc",
"lint:prettier": "prettier src/**/*.js",
"lint:prettier": "prettier --list-different src/**/*.js | ./lint_problems.sh",
"lint:prettierfix": "prettier src/**/*.js --write",
"lint": "yarn run lint:flow && yarn run lint:prettier && yarn run lint:less"
},
Expand Down

0 comments on commit 814d1e0

Please sign in to comment.