Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions tools/cleanup-excludelists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,24 @@ if [[ ! -e "$TEMP" ]]; then
fi
trap 'rm "$TEMP"' EXIT

: > "$TEMP"
mapfile -t files_to_lint < <(for f in $(jq -r '.[]' tools/eslint-excludelist.json); do [[ -e "$f" ]] && echo "$f"; done)
pnpm run lint-file --max-warnings=0 --format=json --output-file="$TEMP" "${files_to_lint[@]}" || true
[[ -s "$TEMP" ]] && jq -e '.' < "$TEMP" >/dev/null || die "No JSON data found"
jq --tab -r --arg pwd "$PWD/" '[ .[] | select( .messages[0]?.ruleId ) | .filePath | ltrimstr($pwd) ] | sort' "$TEMP" > tools/eslint-excludelist.json
if [[ ${#files_to_lint[@]} -eq 0 ]]; then
echo "No files are currently excluded in eslint-excludelist.json 🎉"
else
: > "$TEMP"
pnpm run lint-file --max-warnings=0 --format=json --output-file="$TEMP" "${files_to_lint[@]}" || true
[[ -s "$TEMP" ]] && jq -e '.' < "$TEMP" >/dev/null || die "No JSON data found"
jq --tab -r --arg pwd "$PWD/" '[ .[] | select( .messages[0]?.ruleId ) | .filePath | ltrimstr($pwd) ] | sort' "$TEMP" > tools/eslint-excludelist.json
fi

: > "$TEMP"
composer phpcs:lint -- -m --file-list=<(for f in $(jq -r '.[]' tools/phpcs-excludelist.json); do [[ -e "$f" ]] && echo $f; done) --report=json --report-file="$TEMP" || true
[[ -s "$TEMP" ]] && jq -e '.' < "$TEMP" >/dev/null || die "No JSON data found"
jq --tab -r --arg pwd "$PWD/" '[ .files | to_entries | .[] | select( .value.errors > 0 or .value.warnings > 0 ) | .key | ltrimstr($pwd) ] | sort' "$TEMP" > tools/phpcs-excludelist.json
mapfile -t files_to_lint < <(for f in $(jq -r '.[]' tools/phpcs-excludelist.json); do [[ -e "$f" ]] && echo "$f"; done)
if [[ ${#files_to_lint[@]} -eq 0 ]]; then
echo "No files are currently excluded in phpcs-excludelist.json 🎉"
else
: > "$TEMP"
composer phpcs:lint -- -m --file-list=<( printf "%s\n" "${files_to_lint[@]}" ) --report=json --report-file="$TEMP" || true
[[ -s "$TEMP" ]] && jq -e '.' < "$TEMP" >/dev/null || die "No JSON data found"
jq --tab -r --arg pwd "$PWD/" '[ .files | to_entries | .[] | select( .value.errors > 0 or .value.warnings > 0 ) | .key | ltrimstr($pwd) ] | sort' "$TEMP" > tools/phpcs-excludelist.json
fi

git diff tools/eslint-excludelist.json tools/phpcs-excludelist.json
Loading