Fix precommit hook

This commit is contained in:
Oliver Blanthorn 2020-06-17 18:00:24 +01:00
parent 60adf8eff3
commit 08e454724e
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
5 changed files with 13 additions and 4 deletions

View file

@ -26,7 +26,7 @@ module.exports = {
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"project": ["tsconfig.json", "tsconfig.eslint.json"],
"sourceType": "module"
},
"plugins": [

1
.gitignore vendored
View file

@ -13,3 +13,4 @@ tags
compiler/*.js
compiler/**/*.js
.*.generated.ts
.tmp/

View file

@ -7,7 +7,7 @@ otherfiles=$(cachedPrettierFiles)
# Check if any of the files are ugly or contain a console.log call
consoleFiles=$(noisy $jsfiles)
uglyFiles = "$(eslintUgly) $jsfiles"
uglyFiles="$(eslintUgly $jsfiles)"
if [ ! -n "$uglyFiles" ]; then
uglyFiles="$(prettierUgly $otherfiles)"
fi

View file

@ -33,12 +33,14 @@ eslintUgly() {
local acc=""
local IFS=$'\n'
local tmpdir
tmpdir=$(mktemp -d "eslint.XXXXXXXXX")
mkdir -p .tmp
tmpdir=$(mktemp --tmpdir=".tmp/" -d "tslint.XXXXXXXXX")
for jsfile in "$@"; do
tmpfile="$tmpdir/$jsfile"
mkdir -p "$(dirname "$tmpfile")"
staged "$jsfile" > "$tmpfile"
"$(yarn bin)/eslint" --quiet -o /dev/null "$tmpfile" || acc="$jsfile"$'\n'"$acc"
"$(yarn bin)/eslint" --no-ignore --quiet -o /dev/null "$tmpfile" || acc="$jsfile"$'\n'"$acc"
done
rm -rf "$tmpdir"
echo "$acc"

6
tsconfig.eslint.json Normal file
View file

@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"include": [
".tmp/**/*.ts"
]
}