exit 1;
}
+#https://prettier.io/docs/en/install.html
+command -v prettier >/dev/null 2>&1 || {
+
+ echo >&2 "prettier is required, but it's not installed";
+ echo "-------------------------------------------------------------------------------------";
+ echo "To install prettier on Debian/Ubuntu, execute the following commands."
+ echo "sudo npm install -g prettier"
+ echo "-------------------------------------------------------------------------------------";
+ exit 1;
+}
+
script_path="$( cd "$(dirname "$0")" ; pwd -P )";
config_file="$script_path/eslintrc_mandatory_4spaces.js"
+prettier_config_file="$script_path/prettier.config.js"
formatJSDirectory() {
ls $1/*.js &>/dev/null
if [[ $? -eq 0 ]]; then
- formatJSFile $1;
+ for f in $(ls $1/*.js)
+ do
+ formatJSFile $f;
+ done
fi
}
formatJSFile() {
printf "."
+ # fixing line breaks using prettier
+ prettier --config "$prettier_config_file" "$1" --write
# using eslint for fixing some js issues
eslint --no-eslintrc -c "$config_file" $1 --fix
# issues that are not fixed, will be printed fur the user to take care of them