ci: lint .jison files for any console.log()

Converts the *.jison files into .js, then lints them using just
the `no-console` rule.

To keep things simple, I've just made this run only on CI.

If we want to do more complex linting on `*.jison` files, it might
be worth making an `eslint-plugin-jison`, so that we can directly
parse jison in ESLint.
This commit is contained in:
Alois Klink 2022-09-06 03:22:18 +01:00
parent 106672bc75
commit 22d20cc76e

View File

@ -37,3 +37,17 @@ jobs:
- name: Run Linting
run: yarn lint
- name: Check no `console.log()` in .jison files
# ESLint can't parse .jison files directly
# In the future, it might be worth making a `eslint-plugin-jison`, so
# that this will be built into the `yarn lint` command.
run: |
shopt -s globstar
mkdir -p tmp/
for jison_file in src/**/*.jison; do
outfile="tmp/$(basename -- "$jison_file" .jison)-jison.js"
echo "Converting $jison_file to $outfile"
# default module-type (CJS) always adds a console.log()
yarn jison "$jison_file" --outfile "$outfile" --module-type "amd"
done
yarn eslint --no-eslintrc --rule no-console:error --parser "@babel/eslint-parser" "./tmp/*-jison.js"