JavaScript Linter

General discussion for players of Oolite.

Moderators: another_commander, winston

User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

phkb wrote: Sun Dec 10, 2023 10:15 pm
First thing to note:

Code: Select all

"ecmaVersion": "latest"
I think we're at ecma version 5.0 based on line 652 of oolite-debug-console.js:

Code: Select all

	 // ECMAScript 5 keywords.
hiran wrote: Tue Dec 19, 2023 7:20 pm
phkb wrote: Tue Dec 19, 2023 8:25 am
This is the line

Code: Select all

	var [key, value] = string.getOneToken();
It’s a form I’ve never seen before, taking the array return object (from getOneToken) and assigning the sub elements inside the brackets. I mean, obviously it works, but I would have written like this
var ary = string.getOneToken();
var key = ary[0], value = ary[1];
But... is this valid JavaScript? Or is this one of the customizations that were done for Oolite?
I wonder why eslint did not recognize that line.
Ok, it seems we are NOT on ECMASCRIPT 5. As per the eslint issue I opened this 'destructuring syntax' has been introduced in ECMASCRIPT 6. Confirmed by JavaScript Refrence. So I reconfigured the linter. Here is what we've got now:

Code: Select all

oolite/DebugOXP/Debug.oxp/Scripts/oolite-debug-console.js
  223:40  error  'prettifyArray' is not defined                                           no-undef
  224:23  error  'prettifyObject' is not defined                                          no-undef
  226:22  error  'prettify' is not defined                                                no-undef
  228:2   error  'consoleMessage' is not defined                                          no-undef
  265:2   error  'console' is not defined                                                 no-undef
  267:2   error  'consoleMessage' is not defined                                          no-undef
  290:24  error  'console' is not defined                                                 no-undef
  290:55  error  'console' is not defined                                                 no-undef
  293:4   error  'consoleMessage' is not defined                                          no-undef
  302:4   error  'consoleMessage' is not defined                                          no-undef
  308:3   error  'consoleMessage' is not defined                                          no-undef
  324:13  error  'prettifyElement' is not defined                                         no-undef
  356:7   error  'isClassicIdentifier' is not defined                                     no-undef
  359:20  error  'prettifyElement' is not defined                                         no-undef
  404:11  error  'prettifyFunction' is not defined                                        no-undef
  407:37  error  'prettifyArray' is not defined                                           no-undef
  412:11  error  'prettifyObject' is not defined                                          no-undef
  416:11  error  'prettifyArray' is not defined                                           no-undef
  438:9   error  'prettify' is not defined                                                no-undef
  450:6   error  'defaultMacros' is not defined                                           no-undef
  452:3   error  'consoleMessage' is not defined                                          no-undef
  458:3   error  'macros' is not defined                                                  no-undef
  459:3   error  'console' is not defined                                                 no-undef
  459:32  error  'macros' is not defined                                                  no-undef
  461:3   error  'consoleMessage' is not defined                                          no-undef
  465:3   error  'consoleMessage' is not defined                                          no-undef
  478:6   error  'defaultMacros' is not defined                                           no-undef
  480:3   error  'consoleMessage' is not defined                                          no-undef
  484:6   error  'macros' is not defined                                                  no-undef
  486:10  error  'macros' is not defined                                                  no-undef
  487:3   error  'console' is not defined                                                 no-undef
  487:32  error  'macros' is not defined                                                  no-undef
  489:3   error  'consoleMessage' is not defined                                          no-undef
  493:3   error  'consoleMessage' is not defined                                          no-undef
  501:19  error  'defaultMacros' is not defined                                           no-undef
  508:11  error  'prop' is already defined                                                no-redeclare
  508:19  error  'macros' is not defined                                                  no-undef
  510:8   error  'defaultMacros' is not defined                                           no-undef
  513:2   error  'consoleMessage' is not defined                                          no-undef
  519:6   error  'defaultMacros' is not defined                                           no-undef
  519:35  error  'defaultMacros' is not defined                                           no-undef
  520:12  error  'macros' is not defined                                                  no-undef
  520:34  error  'macros' is not defined                                                  no-undef
  533:14  error  'resolveMacro' is not defined                                            no-undef
  536:3   error  'consoleMessage' is not defined                                          no-undef
  540:3   error  'consoleMessage' is not defined                                          no-undef
  554:18  error  'resolveMacro' is not defined                                            no-undef
  564:3   error  'consoleMessage' is not defined                                          no-undef
  571:3   error  'consoleMessage' is not defined                                          no-undef
  624:26  error  Unexpected control character(s) in regular expression: \x08              no-control-regex
  630:27  error  Unnecessary escape character: \'                                         no-useless-escape
  631:27  error  Unnecessary escape character: \"                                         no-useless-escape
  647:11  error  Unnecessary escape character: \$                                         no-useless-escape
  720:56  error  'console' is not defined                                                 no-undef
  721:1   error  'console' is not defined                                                 no-undef
  725:5   error  'console' is not defined                                                 no-undef
  725:48  error  'console' is not defined                                                 no-undef
  726:5   error  'console' is not defined                                                 no-undef
  726:63  error  'console' is not defined                                                 no-undef
  730:23  error  'console' is not defined                                                 no-undef
  732:28  error  'console' is not defined                                                 no-undef
  733:27  error  'console' is not defined                                                 no-undef
  733:70  error  'console' is not defined                                                 no-undef
  736:1   error  'console' is not defined                                                 no-undef
  736:32  error  'console' is not defined                                                 no-undef
  740:23  error  'console' is not defined                                                 no-undef
  742:28  error  'console' is not defined                                                 no-undef
  743:27  error  'console' is not defined                                                 no-undef
  749:23  error  'console' is not defined                                                 no-undef
  751:28  error  'console' is not defined                                                 no-undef
  752:27  error  'console' is not defined                                                 no-undef
  752:71  error  'console' is not defined                                                 no-undef
  755:1   error  'console' is not defined                                                 no-undef
  755:32  error  'console' is not defined                                                 no-undef
  759:23  error  'console' is not defined                                                 no-undef
  761:28  error  'console' is not defined                                                 no-undef
  762:27  error  'console' is not defined                                                 no-undef
  762:73  error  'console' is not defined                                                 no-undef
  765:1   error  'console' is not defined                                                 no-undef
  765:34  error  'console' is not defined                                                 no-undef
  781:2   error  'console' is not defined                                                 no-undef
  781:31  error  'console' is not defined                                                 no-undef
  788:2   error  'console' is not defined                                                 no-undef
  813:12  error  'console' is not defined                                                 no-undef
  815:2   error  'console' is not defined                                                 no-undef
  837:44  error  'PARAM' is defined but never used. Allowed unused args must match /^_/u  no-unused-vars
  839:27  error  'console' is not defined                                                 no-undef
  840:2   error  'console' is not defined                                                 no-undef
  840:33  error  'console' is not defined                                                 no-undef
  848:59  error  'console' is not defined                                                 no-undef
  851:2   error  'console' is not defined                                                 no-undef
  857:3   error  'consoleMessage' is not defined                                          no-undef
  857:36  error  'prettify' is not defined                                                no-undef
  863:30  error  'special' is not defined                                                 no-undef

oolite/Resources/Scripts/oolite-contracts-cargo.js
  281:7  error  Empty block statement           no-empty
  285:7  error  Empty block statement           no-empty
  908:9  error  'spareSafe' is already defined  no-redeclare

oolite/Resources/Scripts/oolite-contracts-passengers.js
  319:14  error  'j' is already defined  no-redeclare

oolite/Resources/Scripts/oolite-global-prefix.js
   47:12  error  'special' is defined but never used. Allowed unused args must match /^_/u  no-unused-vars
  186:1   error  'Script' is not defined                                                    no-undef
  209:4   error  'special' is not defined                                                   no-undef

oolite/Resources/Scripts/oolite-locale-functions.js
   53:10  error  'defineMethod' is defined but never used  no-unused-vars
   95:7   error  'result' is already defined               no-redeclare
  110:6   error  'value' is already defined                no-redeclare

oolite/Resources/Scripts/oolite-nova-mission.js
  361:11  error  Expected a conditional expression and instead saw an assignment  no-cond-assign

oolite/Resources/Scripts/oolite-populator.js
   148:7   error  'rocks' is assigned a value but never used                                no-unused-vars
   491:7   error  'hmediumremote' is assigned a value but never used                        no-unused-vars
   492:7   error  'hheavyremote' is assigned a value but never used                         no-unused-vars
   579:3   error  'hunters' is assigned a value but never used                              no-unused-vars
   863:12  error  'i' is already defined                                                    no-redeclare
  1464:7   error  't' is already defined                                                    no-redeclare
  1471:3   error  The update clause in this loop moves the variable in the wrong direction  for-direction
  1537:7   error  't' is already defined                                                    no-redeclare
  1636:7   error  't' is already defined                                                    no-redeclare
  1742:7   error  'asst' is already defined                                                 no-redeclare
  1801:7   error  'lead' is already defined                                                 no-redeclare
  1813:11  error  'i' is already defined                                                    no-redeclare
  1817:11  error  'i' is already defined                                                    no-redeclare
  1821:11  error  'i' is already defined                                                    no-redeclare
  1849:12  error  'i' is already defined                                                    no-redeclare
  2018:7   error  'g' is already defined                                                    no-redeclare
  2027:8   error  'extras' is already defined                                               no-redeclare
  2367:7   error  'result' is already defined                                               no-redeclare

oolite/Resources/Scripts/oolite-primable-equipment-manager.js
  175:11  error  'i' is already defined  no-redeclare

oolite/Resources/Scripts/oolite-priorityai.js
   179:10  error  'branch' is already defined                no-redeclare
   194:3   error  Unnecessary semicolon                      no-extra-semi
   226:3   error  Unnecessary semicolon                      no-extra-semi
   240:3   error  Unnecessary semicolon                      no-extra-semi
   279:12  error  'i' is already defined                     no-redeclare
   388:9   error  'message' is already defined               no-redeclare
   756:7   error  'gs' is already defined                    no-redeclare
   761:12  error  'i' is already defined                     no-redeclare
   763:8   error  'spd' is already defined                   no-redeclare
   815:9   error  'crew' is assigned a value but never used  no-unused-vars
  1123:7   error  'gs' is already defined                    no-redeclare
  1143:7   error  'gs' is already defined                    no-redeclare
  1155:7   error  'gs' is already defined                    no-redeclare
  1548:12  error  'i' is already defined                     no-redeclare
  1558:7   error  'gs' is already defined                    no-redeclare
  1559:12  error  'i' is already defined                     no-redeclare
  2472:6   error  'gs' is already defined                    no-redeclare
  2473:11  error  'i' is already defined                     no-redeclare
  3110:9   error  'launchpos' is already defined             no-redeclare
  3267:13  error  'i' is already defined                     no-redeclare
  3297:7   error  'rt' is already defined                    no-redeclare
  4006:12  error  'i' is already defined                     no-redeclare
  4020:7   error  'gs' is already defined                    no-redeclare
  4021:12  error  'i' is already defined                     no-redeclare
  4122:12  error  'i' is already defined                     no-redeclare
  4136:7   error  'gs' is already defined                    no-redeclare
  4137:12  error  'i' is already defined                     no-redeclare

oolite/Resources/Scripts/oolite-tutorial.js
   277:7  error  '$blockTorus' is not defined               no-undef
   828:7  error  'buoy' is assigned a value but never used  no-unused-vars
  1284:7  error  'buoy' is assigned a value but never used  no-unused-vars
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: JavaScript Linter

Post by phkb »

hiran wrote: Wed Dec 20, 2023 10:47 pm
Here is what we've got now:
And we're back to here:
phkb wrote: Sun Dec 10, 2023 10:15 pm
For instance:

Code: Select all

2023-12-09T22:42:35.6920378Z   224:23  error  'prettifyObject' is not defined                              no-undef
But in the file we have:

Code: Select all

this.prettifyObject = function prettifyObject(value, indent)
So, not really an error. I'm not sure why eslist can't see the function declaration.
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

phkb wrote: Wed Dec 20, 2023 11:47 pm
hiran wrote: Wed Dec 20, 2023 10:47 pm
Here is what we've got now:
And we're back to here:
phkb wrote: Sun Dec 10, 2023 10:15 pm
For instance:

Code: Select all

2023-12-09T22:42:35.6920378Z   224:23  error  'prettifyObject' is not defined                              no-undef
But in the file we have:

Code: Select all

this.prettifyObject = function prettifyObject(value, indent)
So, not really an error. I'm not sure why eslist can't see the function declaration.
We are not entirely back. That file had the parsing error before, so the linter never got that far.
But yes, this is again for discussion why this.identifier is not recognized as identifier. So far I have no response but cim's to add an assignment into the code.
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: JavaScript Linter

Post by phkb »

Maybe what we have is ECMAscript version 5.something. ie somewhere between 5 and 6. Which is why we can use a feature from 6, but we generally have v5.

Personally, I think it would be easier to set the linter to use v5, and then either accept the error from v6, or apply my code revision to be v5 compatible. I mean, we *know* all these scripts work, so the only reason to do this is to satisfy an external tool. And the primary goal here is to offer a tool OXP devs can use to check their code prior to release, correct?
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

phkb wrote: Thu Dec 21, 2023 12:13 am
Maybe what we have is ECMAscript version 5.something. ie somewhere between 5 and 6. Which is why we can use a feature from 6, but we generally have v5.

Personally, I think it would be easier to set the linter to use v5, and then either accept the error from v6, or apply my code revision to be v5 compatible. I mean, we *know* all these scripts work, so the only reason to do this is to satisfy an external tool. And the primary goal here is to offer a tool OXP devs can use to check their code prior to release, correct?
Currently there is no problem with the files we are looking at. Yet with v5 setting the linter does not even scan the whole file. With v6 settings it finds more potential issues. And then it would not spot issues that arise between v5 and v6.

I guess the optimal solution would be to run a custom parser that expects v5 and allows that one expression. Until then we'd just have to decide which of the two compromises is better for OXP linting.

And I agree that we should give v5 a try.
Sunshine - Moonlight - Good Times - Oolite
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

hiran wrote: Thu Dec 21, 2023 11:48 am
phkb wrote: Thu Dec 21, 2023 12:13 am
Maybe what we have is ECMAscript version 5.something. ie somewhere between 5 and 6. Which is why we can use a feature from 6, but we generally have v5.
I guess the optimal solution would be to run a custom parser that expects v5 and allows that one expression. Until then we'd just have to decide which of the two compromises is better for OXP linting.
I was told there is a plugin implementing additional rules that allows to error on single language features.
With that I was able to configure the parser for ECMAscript 6 and then limit new features from v6 except for the destructuring syntax.
And we have the perfectly customized linter we need!

With these settings, here is the current output:

Code: Select all

/home/runner/work/oolite/oolite/oolite/DebugOXP/Debug.oxp/Scripts/oolite-debug-console.js
  223:40  error  'prettifyArray' is not defined                                           no-undef
  224:23  error  'prettifyObject' is not defined                                          no-undef
  226:22  error  'prettify' is not defined                                                no-undef
  228:2   error  'consoleMessage' is not defined                                          no-undef
  265:2   error  'console' is not defined                                                 no-undef
  267:2   error  'consoleMessage' is not defined                                          no-undef
  290:24  error  'console' is not defined                                                 no-undef
  290:55  error  'console' is not defined                                                 no-undef
  293:4   error  'consoleMessage' is not defined                                          no-undef
  302:4   error  'consoleMessage' is not defined                                          no-undef
  308:3   error  'consoleMessage' is not defined                                          no-undef
  324:13  error  'prettifyElement' is not defined                                         no-undef
  356:7   error  'isClassicIdentifier' is not defined                                     no-undef
  359:20  error  'prettifyElement' is not defined                                         no-undef
  404:11  error  'prettifyFunction' is not defined                                        no-undef
  407:37  error  'prettifyArray' is not defined                                           no-undef
  412:11  error  'prettifyObject' is not defined                                          no-undef
  416:11  error  'prettifyArray' is not defined                                           no-undef
  438:9   error  'prettify' is not defined                                                no-undef
  450:6   error  'defaultMacros' is not defined                                           no-undef
  452:3   error  'consoleMessage' is not defined                                          no-undef
  458:3   error  'macros' is not defined                                                  no-undef
  459:3   error  'console' is not defined                                                 no-undef
  459:32  error  'macros' is not defined                                                  no-undef
  461:3   error  'consoleMessage' is not defined                                          no-undef
  465:3   error  'consoleMessage' is not defined                                          no-undef
  478:6   error  'defaultMacros' is not defined                                           no-undef
  480:3   error  'consoleMessage' is not defined                                          no-undef
  484:6   error  'macros' is not defined                                                  no-undef
  486:10  error  'macros' is not defined                                                  no-undef
  487:3   error  'console' is not defined                                                 no-undef
  487:32  error  'macros' is not defined                                                  no-undef
  489:3   error  'consoleMessage' is not defined                                          no-undef
  493:3   error  'consoleMessage' is not defined                                          no-undef
  501:19  error  'defaultMacros' is not defined                                           no-undef
  508:11  error  'prop' is already defined                                                no-redeclare
  508:19  error  'macros' is not defined                                                  no-undef
  510:8   error  'defaultMacros' is not defined                                           no-undef
  513:2   error  'consoleMessage' is not defined                                          no-undef
  519:6   error  'defaultMacros' is not defined                                           no-undef
  519:35  error  'defaultMacros' is not defined                                           no-undef
  520:12  error  'macros' is not defined                                                  no-undef
  520:34  error  'macros' is not defined                                                  no-undef
  533:14  error  'resolveMacro' is not defined                                            no-undef
  536:3   error  'consoleMessage' is not defined                                          no-undef
  540:3   error  'consoleMessage' is not defined                                          no-undef
  554:18  error  'resolveMacro' is not defined                                            no-undef
  564:3   error  'consoleMessage' is not defined                                          no-undef
  571:3   error  'consoleMessage' is not defined                                          no-undef
  624:26  error  Unexpected control character(s) in regular expression: \x08              no-control-regex
  630:27  error  Unnecessary escape character: \'                                         no-useless-escape
  631:27  error  Unnecessary escape character: \"                                         no-useless-escape
  647:11  error  Unnecessary escape character: \$                                         no-useless-escape
  720:56  error  'console' is not defined                                                 no-undef
  721:1   error  'console' is not defined                                                 no-undef
  725:5   error  'console' is not defined                                                 no-undef
  725:48  error  'console' is not defined                                                 no-undef
  726:5   error  'console' is not defined                                                 no-undef
  726:63  error  'console' is not defined                                                 no-undef
  730:23  error  'console' is not defined                                                 no-undef
  732:28  error  'console' is not defined                                                 no-undef
  733:27  error  'console' is not defined                                                 no-undef
  733:70  error  'console' is not defined                                                 no-undef
  736:1   error  'console' is not defined                                                 no-undef
  736:32  error  'console' is not defined                                                 no-undef
  740:23  error  'console' is not defined                                                 no-undef
  742:28  error  'console' is not defined                                                 no-undef
  743:27  error  'console' is not defined                                                 no-undef
  749:23  error  'console' is not defined                                                 no-undef
  751:28  error  'console' is not defined                                                 no-undef
  752:27  error  'console' is not defined                                                 no-undef
  752:71  error  'console' is not defined                                                 no-undef
  755:1   error  'console' is not defined                                                 no-undef
  755:32  error  'console' is not defined                                                 no-undef
  759:23  error  'console' is not defined                                                 no-undef
  761:28  error  'console' is not defined                                                 no-undef
  762:27  error  'console' is not defined                                                 no-undef
  762:73  error  'console' is not defined                                                 no-undef
  765:1   error  'console' is not defined                                                 no-undef
  765:34  error  'console' is not defined                                                 no-undef
  781:2   error  'console' is not defined                                                 no-undef
  781:31  error  'console' is not defined                                                 no-undef
  788:2   error  'console' is not defined                                                 no-undef
  813:12  error  'console' is not defined                                                 no-undef
  815:2   error  'console' is not defined                                                 no-undef
  837:44  error  'PARAM' is defined but never used. Allowed unused args must match /^_/u  no-unused-vars
  839:27  error  'console' is not defined                                                 no-undef
  840:2   error  'console' is not defined                                                 no-undef
  840:33  error  'console' is not defined                                                 no-undef
  848:59  error  'console' is not defined                                                 no-undef
  851:2   error  'console' is not defined                                                 no-undef
  857:3   error  'consoleMessage' is not defined                                          no-undef
  857:36  error  'prettify' is not defined                                                no-undef
  863:30  error  'special' is not defined                                                 no-undef

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-contracts-cargo.js
  281:7  error  Empty block statement           no-empty
  285:7  error  Empty block statement           no-empty
  908:9  error  'spareSafe' is already defined  no-redeclare

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-contracts-passengers.js
  319:14  error  'j' is already defined  no-redeclare

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-global-prefix.js
   47:12  error  'special' is defined but never used. Allowed unused args must match /^_/u  no-unused-vars
  165:1   error  ES2015 block-scoped variables are forbidden                                es-x/no-block-scoped-variables
  182:1   error  ES2015 block-scoped variables are forbidden                                es-x/no-block-scoped-variables
  183:1   error  ES2015 block-scoped variables are forbidden                                es-x/no-block-scoped-variables
  186:1   error  'Script' is not defined                                                    no-undef
  209:4   error  'special' is not defined                                                   no-undef

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-locale-functions.js
   43:1   error  ES2015 block-scoped variables are forbidden  es-x/no-block-scoped-variables
   44:1   error  ES2015 block-scoped variables are forbidden  es-x/no-block-scoped-variables
   45:1   error  ES2015 block-scoped variables are forbidden  es-x/no-block-scoped-variables
   46:1   error  ES2015 block-scoped variables are forbidden  es-x/no-block-scoped-variables
   47:1   error  ES2015 block-scoped variables are forbidden  es-x/no-block-scoped-variables
   48:1   error  ES2015 block-scoped variables are forbidden  es-x/no-block-scoped-variables
   53:10  error  'defineMethod' is defined but never used     no-unused-vars
   95:7   error  'result' is already defined                  no-redeclare
  110:6   error  'value' is already defined                   no-redeclare

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-nova-mission.js
  361:11  error  Expected a conditional expression and instead saw an assignment  no-cond-assign

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-populator.js
   148:7   error  'rocks' is assigned a value but never used                                no-unused-vars
   491:7   error  'hmediumremote' is assigned a value but never used                        no-unused-vars
   492:7   error  'hheavyremote' is assigned a value but never used                         no-unused-vars
   579:3   error  'hunters' is assigned a value but never used                              no-unused-vars
   863:12  error  'i' is already defined                                                    no-redeclare
  1464:7   error  't' is already defined                                                    no-redeclare
  1471:3   error  The update clause in this loop moves the variable in the wrong direction  for-direction
  1537:7   error  't' is already defined                                                    no-redeclare
  1636:7   error  't' is already defined                                                    no-redeclare
  1742:7   error  'asst' is already defined                                                 no-redeclare
  1801:7   error  'lead' is already defined                                                 no-redeclare
  1813:11  error  'i' is already defined                                                    no-redeclare
  1817:11  error  'i' is already defined                                                    no-redeclare
  1821:11  error  'i' is already defined                                                    no-redeclare
  1849:12  error  'i' is already defined                                                    no-redeclare
  2018:7   error  'g' is already defined                                                    no-redeclare
  2027:8   error  'extras' is already defined                                               no-redeclare
  2357:4   error  ES2015 block-scoped variables are forbidden                               es-x/no-block-scoped-variables
  2367:7   error  'result' is already defined                                               no-redeclare

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-primable-equipment-manager.js
  175:11  error  'i' is already defined  no-redeclare

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-priorityai.js
   179:10  error  'branch' is already defined                no-redeclare
   194:3   error  Unnecessary semicolon                      no-extra-semi
   226:3   error  Unnecessary semicolon                      no-extra-semi
   240:3   error  Unnecessary semicolon                      no-extra-semi
   279:12  error  'i' is already defined                     no-redeclare
   388:9   error  'message' is already defined               no-redeclare
   756:7   error  'gs' is already defined                    no-redeclare
   761:12  error  'i' is already defined                     no-redeclare
   763:8   error  'spd' is already defined                   no-redeclare
   815:9   error  'crew' is assigned a value but never used  no-unused-vars
  1123:7   error  'gs' is already defined                    no-redeclare
  1143:7   error  'gs' is already defined                    no-redeclare
  1155:7   error  'gs' is already defined                    no-redeclare
  1548:12  error  'i' is already defined                     no-redeclare
  1558:7   error  'gs' is already defined                    no-redeclare
  1559:12  error  'i' is already defined                     no-redeclare
  2472:6   error  'gs' is already defined                    no-redeclare
  2473:11  error  'i' is already defined                     no-redeclare
  3110:9   error  'launchpos' is already defined             no-redeclare
  3267:13  error  'i' is already defined                     no-redeclare
  3297:7   error  'rt' is already defined                    no-redeclare
  4006:12  error  'i' is already defined                     no-redeclare
  4020:7   error  'gs' is already defined                    no-redeclare
  4021:12  error  'i' is already defined                     no-redeclare
  4122:12  error  'i' is already defined                     no-redeclare
  4136:7   error  'gs' is already defined                    no-redeclare
  4137:12  error  'i' is already defined                     no-redeclare

/home/runner/work/oolite/oolite/oolite/Resources/Scripts/oolite-tutorial.js
   277:7  error  '$blockTorus' is not defined               no-undef
   828:7  error  'buoy' is assigned a value but never used  no-unused-vars
  1284:7  error  'buoy' is assigned a value but never used  no-unused-vars

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/JSInterfaceTests/JavaScript Interface Tests.oxp/Scripts/oolite-class-test-SoundSource.js
   41:2  error  ES2015 block-scoped variables are forbidden                 es-x/no-block-scoped-variables
   42:2  error  ES2015 block-scoped variables are forbidden                 es-x/no-block-scoped-variables
  103:7  error  'testStillPlayingTimer' is assigned a value but never used  no-unused-vars
  110:7  error  'testTimer' is assigned a value but never used              no-unused-vars

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/JSInterfaceTests/JavaScript Interface Tests.oxp/Scripts/oolite-class-test-Timer.js
  40:17  error  'zeroTimer' is assigned a value but never used  no-unused-vars
  40:28  error  'reportTimer' is defined but never used         no-unused-vars

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/JSInterfaceTests/JavaScript Interface Tests.oxp/Scripts/oolite-script-test-rig.js
  208:3   error  'consoleMessage' is not defined            no-undef
  212:3   error  'consoleMessage' is not defined            no-undef
  244:3   error  'consoleMessage' is not defined            no-undef
  248:3   error  'consoleMessage' is not defined            no-undef
  271:4   error  'consoleMessage' is not defined            no-undef
  275:6   error  'console' is not defined                   no-undef
  275:31  error  'console' is not defined                   no-undef
  277:14  error  'console' is not defined                   no-undef
  287:10  error  'reportSuccess' is defined but never used  no-unused-vars
  294:10  error  'reportFailure' is defined but never used  no-unused-vars
  305:3   error  'consoleMessage' is not defined            no-undef
  311:3   error  'consoleMessage' is not defined            no-undef
  325:4   error  'consoleMessage' is not defined            no-undef

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/JSInterfaceTests/JavaScript Interface Tests.oxp/Scripts/oolite-test-frameCallbacks.js
   42:6   error  Unexpected constant condition                                            no-constant-condition
   43:12  error  'fcbLog' is already defined                                              no-redeclare
   47:3   error  ES2015 block-scoped variables are forbidden                              es-x/no-block-scoped-variables
   61:7   error  'testTimer' is assigned a value but never used                           no-unused-vars
  111:41  error  'delta' is defined but never used. Allowed unused args must match /^_/u  no-unused-vars
  126:39  error  'delta' is defined but never used. Allowed unused args must match /^_/u  no-unused-vars
  153:7   error  'testTimer' is assigned a value but never used                           no-unused-vars

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/PNGTestSuite/PNGTestSuite.oxp/Config/script.js
   40:7   error  'console' is assigned a value but never used  no-unused-vars
   40:17  error  'debugConsole' is not defined                 no-undef
   49:2   error  ES2015 block-scoped variables are forbidden   es-x/no-block-scoped-variables
   56:4   error  'debugConsole' is not defined                 no-undef
   80:6   error  'debugConsole' is not defined                 no-undef
   82:3   error  'debugConsole' is not defined                 no-undef
  101:19  error  'debugConsole' is not defined                 no-undef

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/RetroMissions/RetroMissions.oxp/Scripts/ahruman-reaper.js
  14:2   error  ES2015 block-scoped variables are forbidden                                es-x/no-block-scoped-variables
  23:7   error  ES2015 block-scoped variables are forbidden                                es-x/no-block-scoped-variables
  25:3   error  ES2015 block-scoped variables are forbidden                                es-x/no-block-scoped-variables
  38:8   error  'prop' is not defined                                                      no-undef
  40:15  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins
  40:30  error  'prop' is not defined                                                      no-undef
  42:19  error  'prop' is not defined                                                      no-undef

/home/runner/work/oolite/oolite/oolite/tests/test-oxps/materialTestSuite/Material Test Suite.oxp/Scripts/oolite-material-test-suite.js
   43:7   error  'console' is assigned a value but never used  no-unused-vars
   43:17  error  'debugConsole' is not defined                 no-undef
   54:22  error  'debugConsole' is not defined                 no-undef
   60:4   error  'debugConsole' is not defined                 no-undef
   85:6   error  'debugConsole' is not defined                 no-undef
   87:3   error  'debugConsole' is not defined                 no-undef
   99:30  error  'debugConsole' is not defined                 no-undef
  100:29  error  'debugConsole' is not defined                 no-undef
  113:3   error  'debugConsole' is not defined                 no-undef
  116:31  error  'debugConsole' is not defined                 no-undef
  117:50  error  'debugConsole' is not defined                 no-undef
  118:39  error  'debugConsole' is not defined                 no-undef
  122:54  error  'debugConsole' is not defined                 no-undef
  135:3   error  'debugConsole' is not defined                 no-undef
  136:3   error  'debugConsole' is not defined                 no-undef
  187:24  error  'debugConsole' is not defined                 no-undef
  188:26  error  'debugConsole' is not defined                 no-undef
  189:31  error  'debugConsole' is not defined                 no-undef
  194:5   error  'debugConsole' is not defined                 no-undef
  209:3   error  'debugConsole' is not defined                 no-undef
  210:3   error  'debugConsole' is not defined                 no-undef
  210:30  error  'debugConsole' is not defined                 no-undef
  210:70  error  'debugConsole' is not defined                 no-undef
Sunshine - Moonlight - Good Times - Oolite
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

I deactivated the `no-block-scoped-variables` rule, which means we should have achieved the optimal linter configuration.

To not let this covered by the fog of war I'd like to merge the [url=https://github.com/OoliteProject/oolite/tree/eslint]eslint branch[/quote] into master. Linter errors currently just end up in the log however they never break the build.

Any objections?
Sunshine - Moonlight - Good Times - Oolite
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4646
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: JavaScript Linter

Post by phkb »

Looks fine to me
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

phkb wrote: Sat Dec 23, 2023 12:29 am
Looks fine to me
Thank you. It is merged now.
Sunshine - Moonlight - Good Times - Oolite
User avatar
Cholmondely
Archivist
Archivist
Posts: 4999
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: JavaScript Linter

Post by Cholmondely »

Javascript Linters for the AppleMac

I need something which works on an AppleMac (unlike Oolite.v.1.91)!

I've downloaded Atom, Visual Studio Code and SubEthaEdit.

Atom uses far too much jargon. I've no idea how to get it to do anything useful. And the Help seems equally jargon-laden.

SubEthaEdit does not seem to offer me linting as an option for Javascript.

Visual Studio Code asks me to select an environment (?) and then says it needs to download an extension from "the marketplace" but can't seem to find anything.




Plist Linters for the AppleMac

Apple's Terminal "plutil" facility only helps when there is just the one error.
With more than one I seem to get Unexpected character { at line 1 message every time.

Atom has the same issues as above.

SubEthaEdit offers linting as an option (Mode menu) but has a fixed presumption that everything is in XML - and the stuff I'm trying to fix is usually in OpenStep

Visual Studio Code says it needs to download a plist extension from "the marketplace" but can't seem to find anything.



Would anybody have any useful tips for this dumb pilot?
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

Cholmondely wrote: Sun Jan 21, 2024 8:31 am
Javascript Linters for the AppleMac
I believe the best linter to use is eslint - especially since I already created Oolite-specific configuration for it.
Here is how to get started with eslint: https://eslint.org/docs/latest/use/getting-started

However eslint runs in Node.js (invoked via npm), and if you never used that maybe it is not installed on your computer.
To overcome this hurdle, maybe you need https://phoenixnap.com/kb/install-npm-mac
Cholmondely wrote: Sun Jan 21, 2024 8:31 am
Plist Linters for the AppleMac
For linting plist, there is another free linter that apparently also runs on Node.js/npm (see above for Node/npm installation on a mac). I have not tested it, but you might like trying
https://github.com/baleyko/plistlint
Sunshine - Moonlight - Good Times - Oolite
User avatar
Cholmondely
Archivist
Archivist
Posts: 4999
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: JavaScript Linter

Post by Cholmondely »

hiran wrote: Sun Jan 21, 2024 8:44 am
Cholmondely wrote: Sun Jan 21, 2024 8:31 am
Javascript Linters for the AppleMac

I need something which works on an AppleMac (unlike Oolite.v.1.91)!

I've downloaded Atom, Visual Studio Code and SubEthaEdit.

Atom uses far too much jargon. I've no idea how to get it to do anything useful. And the Help seems equally jargon-laden.

SubEthaEdit does not seem to offer me linting as an option for Javascript.

Visual Studio Code asks me to select an environment (?) and then says it needs to download an extension from "the marketplace" but can't seem to find anything.
I believe the best linter to use is eslint - especially since I already created Oolite-specific configuration for it.
Here is how to get started with eslint: https://eslint.org/docs/latest/use/getting-started

However eslint runs in Node.js (invoked via npm), and if you never used that maybe it is not installed on your computer.
To overcome this hurdle, maybe you need https://phoenixnap.com/kb/install-npm-mac
Thank you!

I'll hopefully be able to give it a stab later on today.

Hoping that your dynasty are all doing well!
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
hiran
Theorethicist
Posts: 2056
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: JavaScript Linter

Post by hiran »

Cholmondely wrote: Sun Jan 21, 2024 8:47 am
Thank you!

I'll hopefully be able to give it a stab later on today.

Hoping that your dynasty are all doing well!
All are fine over here, thanks.

Watch out: I updated my post. Somehow I cannot get around the habit of publishing a post, then reread it to find it needs improvement...
Sunshine - Moonlight - Good Times - Oolite
User avatar
Cholmondely
Archivist
Archivist
Posts: 4999
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: JavaScript Linter

Post by Cholmondely »

hiran wrote: Sun Jan 21, 2024 8:50 am
Watch out: I updated my post. Somehow I cannot get around the habit of publishing a post, then reread it to find it needs improvement...
I do exactly the same... alas...
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
User avatar
Cholmondely
Archivist
Archivist
Posts: 4999
Joined: Tue Jul 07, 2020 11:00 am
Location: The Delightful Domains of His Most Britannic Majesty (industrial? agricultural? mainly anything?)
Contact:

Re: JavaScript Linter

Post by Cholmondely »

hiran wrote: Sun Jan 21, 2024 8:44 am
I believe the best linter to use is eslint - especially since I already created Oolite-specific configuration for it.
Here is how to get started with eslint: https://eslint.org/docs/latest/use/getting-started

However eslint runs in Node.js (invoked via npm), and if you never used that maybe it is not installed on your computer.
To overcome this hurdle, maybe you need https://phoenixnap.com/kb/install-npm-mac
I already had node (from dismal attempts at mastering javascript).




I got this:

Command inside AppleMac's "Terminal":

Code: Select all

npm init @eslint/config
resulted in all sorts of on-going fun and games culminating in this:

Code: Select all

npx: installed 43 in 30.559s
file:///~/~/.npm/_npx/46428/lib/node_modules/@eslint/create-config/lib/init/config-initializer.js:400
        throw new Error("A package.json file is necessary to initialize ESLint. Run `npm init` to create a package.json file and try again.");
              ^

Error: A package.json file is necessary to initialize ESLint. Run `npm init` to create a package.json file and try again.
    at promptUser (file:///~/~/.npm/_npx/46428/lib/node_modules/@eslint/create-config/lib/init/config-initializer.js:400:15)
    at initializeConfig (file:///~/~/.npm/_npx/46428/lib/node_modules/@eslint/create-config/lib/init/config-initializer.js:616:12)
    at file:///~/~/.npm/_npx/46428/lib/node_modules/@eslint/create-config/bin/create-config.js:10:1
    at ModuleJob.run (internal/modules/esm/module_job.js:146:23)
    at async Loader.import (internal/modules/esm/loader.js:165:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
Last edited by Cholmondely on Wed Jan 24, 2024 6:26 pm, edited 1 time in total.
Comments wanted:
Missing OXPs? What do you think is missing?
Lore: The economics of ship building How many built for Aronar?
Lore: The Space Traders Flight Training Manual: Cowell & MgRath Do you agree with Redspear?
Post Reply