Skip to content

Commit

Permalink
[change] Switch to prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
youhaveme9 committed Dec 24, 2024
1 parent 8ad7519 commit 754625c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions openwisp-qa-check
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ show_help() {
printf "ReStructuredText check options:\n"
printf " --skip-checkrst\t\t: Skip ReStructuredText check\n"
printf "CSSlinter check options:\n"
printf " --csslinter\t\t\t: Runs stylelint check\n"
printf " --csslinter\t\t\t: Runs prettier check on css files\n"
printf "Jslinter check options:\n"
printf " --jslinter\t\t\t: Runs jshint check\n"
printf " --jslinter\t\t\t: Runs prettier check on javascript files\n"
}

echoerr() { echo "$@" 1>&2; }
Expand All @@ -67,13 +67,13 @@ runcheckendline() {
fi
}

runstylelintcheck() {
package='stylelint'
if which stylelint > /dev/null; then
stylelint verbose $(find . -type f -name "*.css") &&
echo "SUCCESS: Stylelint check successful!" ||
runcssprettiercheck() {
package='prettier'
if which prettier > /dev/null; then
prettier $(find . -type f -name "*.css") --check &&
echo "SUCCESS: Prettier check successful!" ||
{
echoerr "ERROR: Stylelint check failed! Hint: did you forget to run openwisp-qa-format?"
echoerr "ERROR: Prettier check failed! Hint: did you forget to run openwisp-qa-format?"
FAILURE=1
}
else
Expand All @@ -82,13 +82,13 @@ runstylelintcheck() {
fi
}

runjshintcheck() {
package='jshint'
if which jshint > /dev/null; then
jshint --verbose $(find . -type f -name "*.js" -a ! -path "*vendor/*.js") &&
echo "SUCCESS: Jshint check successful!" ||
runjsprettiercheck() {
package='prettier'
if which prettier > /dev/null; then
prettier $(find . -type f -name "*.js" -a ! -path "*vendor/*.js") --check &&
echo "SUCCESS: Prettier check successful!" ||
{
echoerr "ERROR: Jshint check failed! Hint: please follow js code conventions. Visit: https://openwisp.io/docs/developer/contributing.html#javascript-code-conventions"
echoerr "ERROR: Prettier check failed! Hint: please follow js code conventions. Visit: https://openwisp.io/docs/developer/contributing.html#javascript-code-conventions"
FAILURE=1
}
else
Expand Down Expand Up @@ -283,11 +283,11 @@ if ! $SKIP_FLAKE8; then
fi

if ! $SKIP_CSS_LINTER; then
runstylelintcheck
runcssprettiercheck
fi

if ! $SKIP_JS_LINTER; then
runjshintcheck
runjsprettiercheck
fi

if ! $SKIP_RSTCHECK; then
Expand Down
6 changes: 3 additions & 3 deletions openwisp-qa-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ isort .
black -S .
docstrfmt --no-docstring-trailing-line --ignore-cache --line-length 74 .

if which stylelint > /dev/null; then
stylelint $(find . -type f -name "*.css") --fix
if which prettier > /dev/null; then
prettier $(find . -type f -name "*.css") --write
else
echo "SKIPPED CSS FILES: Please install stylelint"
echo "SKIPPED CSS FILES: Please install prettier"
fi

0 comments on commit 754625c

Please sign in to comment.