Project

General

Profile

Feature #11318

Consider integrating a built-time checker for JS code

Added by Alexandru Lungu 4 months ago. Updated 3 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

Related issues

Related to Build and Source Control - Bug #11396: Consider integrating a Java static analyzer New

History

#1 Updated by Alexandru Lungu 4 months ago

This task should lead to:
  • an effort searching of a proper tool to test JS syntax errors to avoid run-time bugs.
  • evaluate ESLint as a possible solution
  • investigate other possible tools
  • check if we can have more capability for such tool useful for FWD

#3 Updated by Șerban Bursuc 4 months ago

Alex you are completely right, to compile the files with NodeJS you would need browser dependencies, so the best we can is do static analysis.

I made a test with ESLint and the results look legit, although with trunk/10860a there are a bunch of failures, excluding soft ones like unused vars.

Hynek, this is the perfect task for an agentic AI. Considering you've recently updated the build tools for gradle, can you also implement ESLint properly?

sb@sb-Yoga-Pro-7-14APH8:~/gcd/trunk$ ./gradlew checkJs
To honour the JVM settings for this build a single-use Daemon process will be forked. For more on this, please refer to https://docs.gradle.org/9.2.1/userguide/gradle_daemon.html#sec:disabling_the_daemon in the Gradle documentation.
Daemon will be stopped at the end of the build 

> Configure project :
Grammar not found. Skipping antlr4ProgressLexer.
Grammar not found. Skipping antlr4ProgressParser.
Grammar not found. Skipping antlr4ExpressionEvaluatorParser.
Grammar not found. Skipping antlr4ExpressionEvaluatorLexer.
Grammar not found. Skipping antlr4ExpressionCompilerParser.
Grammar not found. Skipping antlr4ExpressionCompilerLexer.
Grammar not found. Skipping antlr4TextParser.
Grammar not found. Skipping antlr4TextLexer.
Grammar not found. Skipping antlr4BracesParser.
Grammar not found. Skipping antlr4BracesLexer.
Grammar not found. Skipping antlr4HqlParser.
Grammar not found. Skipping antlr4HqlLexer.
Grammar not found. Skipping antlr4FqlParser.
Grammar not found. Skipping antlr4FqlLexer.
Grammar not found. Skipping antlr4E4glParser.
Grammar not found. Skipping antlr4E4glLexer.
Grammar not found. Skipping antlr4Schema.

> Task :checkJs FAILED

/home/sb/gcd/trunk/src/com/goldencode/p2j/aspects/ltw/web/trace.js
   77:5   error  'currentData' is not defined  no-undef
   77:19  error  'traceData' is not defined    no-undef
   79:52  error  'currentData' is not defined  no-undef
   80:53  error  'currentData' is not defined  no-undef
   81:54  error  'currentData' is not defined  no-undef
   83:18  error  'currentData' is not defined  no-undef
  120:52  error  'elapsed' is not defined      no-undef
  123:25  error  'buckets' is not defined      no-undef
  127:26  error  'buckets' is not defined      no-undef
  129:22  error  'buckets' is not defined      no-undef
  145:22  error  'buckets' is not defined      no-undef
  150:25  error  'roots' is not defined        no-undef
  154:26  error  'roots' is not defined        no-undef
  156:22  error  'roots' is not defined        no-undef
  171:24  error  'roots' is not defined        no-undef

/home/sb/gcd/trunk/src/com/goldencode/p2j/ui/client/driver/web/res/p2j.clipboard.js
  170:28  error  'text' is not defined  no-undef

/home/sb/gcd/trunk/src/com/goldencode/p2j/ui/client/driver/web/res/p2j.js
  2213:39  error  'labelDiv' is not defined  no-undef

/home/sb/gcd/trunk/src/com/goldencode/p2j/ui/client/driver/web/res/p2j.keyboard.js
  778:14  error  'keyCode' is not defined  no-undef
  783:30  error  'keyCode' is not defined  no-undef
  811:14  error  'keyCode' is not defined  no-undef
  837:23  error  'keyCode' is not defined  no-undef
  844:20  error  'keyCode' is not defined  no-undef

/home/sb/gcd/trunk/src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js
  7075:27  error  'openShadowDomBrowser' is not defined  no-undef

✖ 23 problems (23 errors, 0 warnings)

[Incubating] Problems report is available at: file:///home/sb/gcd/trunk/build/reports/problems/problems-report.html

FAILURE: Build failed with an exception.

* Where:
Build file '/home/sb/gcd/trunk/build.gradle' line: 430

* What went wrong:
Execution failed for task ':checkJs'.
> [checkJs] ESLint reported errors in JS sources. See build/reports/checkJs/result.txt for details.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to generate a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/9.2.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

BUILD FAILED in 9s
2 actionable tasks: 1 executed, 1 up-to-date

#4 Updated by Alexandru Lungu 4 months ago

I made a test with ESLint and the results look legit, although with trunk/10860a there are a bunch of failures, excluding soft ones like unused vars.

ESLint is a tool that is highly customizable to set what is actually an error/warning, to set-up the checks, etc. For instance, you can disable "no-undef" or set another level of failure. I do not say to do this, but it would be right to convey on certain rules relying on current coding standards.

#5 Updated by Alexandru Lungu 3 months ago

  • Project changed from User Interface to Build and Source Control

#7 Updated by Alexandru Lungu 3 months ago

  • Related to Bug #11396: Consider integrating a Java static analyzer added

Also available in: Atom PDF