diff options
author | Claudio André <claudioandre.br@gmail.com> | 2018-03-05 11:18:56 -0300 |
---|---|---|
committer | Claudio André <claudioandre.br@gmail.com> | 2018-03-05 11:45:10 -0300 |
commit | 4ba83649f83b6fc3785216b2b9f250dc11425744 (patch) | |
tree | f5f4e9e432385523f5352b5a1c975bf4d9fac24a | |
parent | 00f0e79d3fdb9b955a775a730d7177337193b454 (diff) | |
download | gjs-4ba83649f83b6fc3785216b2b9f250dc11425744.tar.gz |
CI: add Javascript eslint
-rw-r--r-- | .eslintignore | 2 | ||||
-rw-r--r-- | .eslintrc.json | 43 | ||||
-rw-r--r-- | .gitlab-ci.yml | 8 | ||||
-rwxr-xr-x | test/test-ci.sh | 27 |
4 files changed, 80 insertions, 0 deletions
diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..2949f272 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +installed-tests/js/jasmine.js +modules/jsUnit.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..8cade1cb --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,43 @@ +{ + "env": { + "es6": true, + "jasmine": true + }, + "extends": "eslint:recommended", + "rules": { + "indent": [ + "error", + 4, + { + "MemberExpression": "off" + } + ], + "linebreak-style": [ + "error", + "unix" + ], + "quotes": [ + "error", + "single", + { + "avoidEscape": true + } + ], + "semi": [ + "error", + "always" + ] + }, + "globals": { + "imports": false, + "ARGV": false, + "print": false, + "printerr": false, + "window": false, + "log": false, + "logError": false + }, + "parserOptions": { + "ecmaVersion": 2017 + } +}
\ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5688d2f4..9645aec5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,6 +20,7 @@ stages: - $(pwd)/coverage/ - $(pwd)/cppcheck/ - $(pwd)/cpplint/ + - $(pwd)/eslint/ - $(pwd)/tokei/ script: @@ -134,6 +135,13 @@ cpplint: variables: CODECHECK: "CPPLINT" +eslint: + <<: *build + stage: static_analysis + image: claudioandre/spidermonkey:fedora.dev.gcc + variables: + CODECHECK: "ESLINT" + code_statistics: <<: *build stage: static_analysis diff --git a/test/test-ci.sh b/test/test-ci.sh index e5a9d812..b1a85b2e 100755 --- a/test/test-ci.sh +++ b/test/test-ci.sh @@ -94,6 +94,7 @@ save_dir="$(pwd)" mkdir -p "$save_dir"/coverage; touch "$save_dir"/coverage/doing-"$1" mkdir -p "$save_dir"/cppcheck; touch "$save_dir"/cppcheck/doing-"$1" mkdir -p "$save_dir"/cpplint; touch "$save_dir"/cpplint/doing-"$1" +mkdir -p "$save_dir"/eslint; touch "$save_dir"/eslint/doing-"$1" mkdir -p "$save_dir"/tokei; touch "$save_dir"/tokei/doing-"$1" if [[ $1 == "GJS" ]]; then @@ -188,6 +189,32 @@ elif [[ $1 == "CPPLINT" ]]; then # Compare the report with master and fail if new warnings are found do_Compare_With_Upstream_Master "cppLint" +elif [[ $1 == "ESLINT" ]]; then + # Install needed packages + npm install -g eslint + + echo + echo '-- Javascript linter report --' + eslint examples installed-tests modules --format unix 2>&1 | \ + tee "$save_dir"/eslint/current-report.txt | \ + sed -E -e 's/:[0-9]+:[0-9]+:/:LINE:COL:/' -e 's/[0-9]+ problems//' -e 's/\/root\/tmp-upstream//' -e 's/\/builds\/claudioandre//' | \ + tee /cwd/current-report.txt + echo + + # Get the code committed at upstream master + do_Get_Upstream_Master + cp "$save_dir"/.eslint* . + + echo '-- Master Javascript linter report --' + eslint examples installed-tests modules --format unix 2>&1 | \ + tee "$save_dir"/eslint/master-report.txt | \ + sed -E -e 's/:[0-9]+:[0-9]+:/:LINE:COL:/' -e 's/[0-9]+ problems//' -e 's/\/root\/tmp-upstream//' -e 's/\/builds\/claudioandre//' | \ + tee /cwd/master-report.txt + echo + + # Compare the report with master and fail if new warnings are found + do_Compare_With_Upstream_Master "esLint" + elif [[ $1 == "TOKEI" ]]; then echo echo '-- Project statistics --' |