gnome-shell/.gitlab-ci/eslint-coding-style.sh
Florian Müllner 98464868c7 docs: Move HACKING
Start consolidating project-wide documentation in the docs/ folder.

While at it, change the name `js-coding-style`, which is both less
ominous and allows for an accompanying `c-coding-style`.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3122>
2024-01-27 22:23:10 +01:00

44 lines
914 B
Bash
Executable File

#!/bin/bash
SRCDIR=$(realpath $(dirname $0)/..)
OUTDIR=$(mktemp --directory --tmpdir=$SRCDIR)
trap "rm -rf $OUTDIR" EXIT
# Turn ```javascript``` code snippets in the
# style guide into .js files in $OUTDIR
awk --assign dir=$OUTDIR -- '
BEGIN {
do_print = 0;
cur = 0;
}
# end of code snippet
/```$/ {
do_print = 0;
cur++;
}
do_print {
# remove one level of indent
sub(" ","")
# the following are class snippets, turn them
# into functions to not confuse eslint
sub("moveActor","function moveActor")
sub("desaturateActor","function desaturateActor")
# finally, append to the currently generated .js file
print >> dir "/" cur ".js";
}
# start of code snippet
/```javascript$/ {
do_print = 1;
}
' docs/js-coding-style.md
eslint \
--rule 'no-undef: off' \
--rule 'no-unused-vars: off' \
--rule 'no-invalid-this: off' $OUTDIR/*.js