Skip to content

Instantly share code, notes, and snippets.

@luisliuchao
Last active October 3, 2017 01:01
Show Gist options
  • Save luisliuchao/a9964c58e0c22096e983179993b8bd10 to your computer and use it in GitHub Desktop.
Save luisliuchao/a9964c58e0c22096e983179993b8bd10 to your computer and use it in GitHub Desktop.
Automatically add /* eslint-disable */ at the beginning of all *.js files excluding node_modules and bower_components
function addEslintDisable {
filepath="$1"
if [ -d $filepath ] && [[ $filepath != node_modules ]] && [[ $filepath != bower_components ]]
then
for file in $(ls $filepath | cat); do
newfilepath="$filepath/$file"
$(addEslintDisable $newfilepath)
done
elif [[ $filepath = *.js ]]
then
sed -i '' '1s/^/\/\/ remove eslint disable comment when you edit this file\'$'\n/' $filepath
sed -i '' '1s/^/\/\* eslint-disable \*\/\'$'\n/' $filepath
fi
}
addEslintDisable $1
@luisliuchao
Copy link
Author

luisliuchao commented Oct 3, 2017

run sh sk-eslint-disable.sh $filepath

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