mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
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:
parent
106672bc75
commit
22d20cc76e
14
.github/workflows/lint.yml
vendored
14
.github/workflows/lint.yml
vendored
@ -37,3 +37,17 @@ jobs:
|
|||||||
|
|
||||||
- name: Run Linting
|
- name: Run Linting
|
||||||
run: yarn lint
|
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"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user