Surya Hebbar has uploaded a new patch set (#8). ( http://gerrit.cloudera.org:8080/21970 )
Change subject: IMPALA-13473: Add support for JS code analysis and linting with ESLint ...................................................................... IMPALA-13473: Add support for JS code analysis and linting with ESLint This patch adds support for JS code analysis and linting to webUI scripts using ESLint. Support to enforce code style and quality is partcularly beneficial, as the codebase for client-side scripts is consistently growing. This has been implemented to work alongside other code style enforcement rules present within 'critique-gerrit-review.py', which runs on the existing jenkins job 'gerrit-auto-critic', to produce gerrit comments. In the case of webUI scripts, ESLint's code analysis and linting checks are performed to produce these comments. As a shared NodeJS installation can be used for JS tests as well as linting, a seperate common script "bin/nodejs/setup_nodejs.sh" has been added for assiting with the NodeJS installation. To ensure quicker run times for the jenkins job, NodeJS tarball is cached within "${HOME}/.cache" directory, after the initial installation. ESLint's packages and dependencies have been made to be cached using NPM's own package management and are also cached locally. NodeJS and ESLint dependencies are retrieved and executed, only if there are any changes within ".js" files within the patchset, and run with minimal overhead. After analysis, comments are generated for all the violations according to the specified rules. A custom formatter has been added to extract, format and filter the violations in JSON form. These generated code style violations are formatted into the required JSON form according to gerrit's REST API, similar to comments generated by flake8. These are then posted to gerrit as comments on the respective patchset from jenkins over SSH. The following code style and quality rules have been added using ESLint. - Disallow unused variables - Enforce strict equality (=== and !==) - Require curly braces for all control statements (if, while, etc.) - Enforce semicolons at the end of statements - Enforce double quotes for strings - Set maximum line length to 90 - Disallow `var`, use `let` or `const` - Prefer `const` where possible - Disallow multiple empty lines - Enforce spacing around infix operators (eg. +, =) - Disallow the use of undeclared variables - Require parentheses around arrow function arguments - Require a space before blocks - Enforce consistent spacing inside braces - Disallow shadowing variables declared in the outer scope - Disallow constant conditions in if statements, loops, etc - Disallow unnecessary parentheses in expressions - Disallow duplicate arguments in function definitions - Disallow duplicate keys in object literals - Disallow unreachable code after return, throw, continue, etc - Disallow reassigning function parameters - Require functions to always consistently return or not return at all - Enforce consistent use of dot notation wherever possible - Disallow multiple empty lines - Enforce spacing around the colon in object literal properties - Disallow optional chaining, where undefined values are not allowed The required linting packages have been added as dependencies in the "www/scripts" directory. All the test scripts and related dependencies have been moved to - $IMPALA_HOME/tests/webui/js_tests. All the custom ESLint formatter scripts and related dependencies have been moved to - $IMPALA_HOME/tests/webui/linting. A combination of NodeJS's 'prefix' argument and NODE_PATH environmental variable is being used to seperate the dependencies and webUI scripts. To support running the tests from a remote directory(i.e. tests/webui), by modifying the required base paths. Change-Id: Ieb3d0a9221738e2ac6fefd60087eaeee4366e33f --- M bin/jenkins/critique-gerrit-review.py A bin/nodejs/setup_nodejs.sh D tests/run-js-tests.sh R tests/webui/js_tests/.gitignore R tests/webui/js_tests/package.json R tests/webui/js_tests/queries/profileParseWorker.test.js R tests/webui/js_tests/query_timeline/chart_commons.test.js R tests/webui/js_tests/query_timeline/fragment_diagram.test.js R tests/webui/js_tests/query_timeline/fragment_metrics_diagram.test.js R tests/webui/js_tests/query_timeline/host_utilization_diagram.test.js A tests/webui/linting/.gitignore A tests/webui/linting/eslint.config.js A tests/webui/linting/eslint/eslint_custom_output_formatter.js A tests/webui/linting/package.json A tests/webui/run-js-tests.sh M www/scripts/query_timeline/package.json 16 files changed, 271 insertions(+), 83 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/70/21970/8 -- To view, visit http://gerrit.cloudera.org:8080/21970 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: newpatchset Gerrit-Change-Id: Ieb3d0a9221738e2ac6fefd60087eaeee4366e33f Gerrit-Change-Number: 21970 Gerrit-PatchSet: 8 Gerrit-Owner: Surya Hebbar <sheb...@cloudera.com> Gerrit-Reviewer: Impala Public Jenkins <impala-public-jenk...@cloudera.com> Gerrit-Reviewer: Kurt Deschler <kdesc...@cloudera.com> Gerrit-Reviewer: Michael Smith <michael.sm...@cloudera.com> Gerrit-Reviewer: Riza Suminto <riza.sumi...@cloudera.com> Gerrit-Reviewer: Surya Hebbar <sheb...@cloudera.com>