Skip to content

Instantly share code, notes, and snippets.

@wtnabe
Last active December 8, 2021 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wtnabe/a954065be1defa3861f723cb7440c3cc to your computer and use it in GitHub Desktop.
Save wtnabe/a954065be1defa3861f723cb7440c3cc to your computer and use it in GitHub Desktop.
ESLintの設定でうっかり新しい記法が許されていた場合に警告する
#! /bin/sh
target_version=2017
main () {
config_file=$1
if [ -z "$config_version" ]; then
cat <<EOD
eslint config file not specified
ex) ./limit-ecma-version.sh .eslintrc.js
EOD
else
echo "start checking with " $config_file
do_check $config_file
fi
}
do_check () {
config_file=$1
yarn run -s eslint --print-config $config_file | jq .env | awk -v target_version=$target_version '{
if (match($0, /es([0-9]+)/) && /true/) {
version = substr($0, RSTART + 2, RLENGTH - 2)
if (version + 0 > target_version) {
print "CAUTION ! this config may break not-most-modern browsers."
print
exit 1
}
}
}
'
}
main $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment