Skip to content

Instantly share code, notes, and snippets.

@TyIsI
Last active December 23, 2022 01:20
Show Gist options
  • Save TyIsI/f9d772dc71409435d73db380a567a89e to your computer and use it in GitHub Desktop.
Save TyIsI/f9d772dc71409435d73db380a567a89e to your computer and use it in GitHub Desktop.
Open all the broken files!
#!/bin/bash
TMPFILE=$(mktemp)
TMPFORMATTER=$(mktemp)
{
echo 'module.exports = (results) => {'
echo ' return results'
echo ' .filter(result => result.messages.length > 0)'
echo " .map(result => \`\${result.messages.length}\\t\${result.filePath.replace(/.*(src\/.*)/, '\$1')}\`).join('\\n')"
echo '}'
} > ${TMPFORMATTER}
yarn eslint -f ${TMPFORMATTER} -o ${TMPFILE} src > /dev/null 2>&1
cat ${TMPFILE} | egrep -v 'Attic|\.types\.ts' | sort -nr | awk '{ print $2 }' | while read SRCFILE; do
echo "Opening ${SRCFILE}"
code --wait ${SRCFILE}
done
rm ${TMPFILE} ${TMPFORMATTER}
@TyIsI
Copy link
Author

TyIsI commented Dec 23, 2022

When you really don't know where to start with fixing all your broken files after an update.

Based on eslint, this script makes a list of files and error counts and one-by-one opens the most broken files first.

Assumes that everything is in the src directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment