Skip to content

Firefly-2100: Fix ESLint identified errors with behavioral impacts - #2024

Merged
aventura121 merged 1 commit into
devfrom
FIREFLY-2100-eslint-identified-bugs-clean
Sep 29, 2026
Merged

aventura121 merged 1 commit into
devfrom
FIREFLY-2100-eslint-identified-bugs-clean

Conversation

@aventura121

@aventura121 aventura121 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Firefly-2100: "Triage (or Fix) ESLint-Identified Javascript/React Issues"

Description

This PR fixes ESLint identified errors with potential behavioral impacts.

Except for react-hooks/rules-of-hooks, these rules come from js.configs.recommended, which our ESLint config doesn't yet enable. I've included the command that reproduces its error on dev below; on this branch the same command should not report the specific error. The commands are run from the repo root.

Builds

Firefly: https://firefly-2100-eslint-identified-bugs-clean-2.irsakubedev.ipac.caltech.edu/firefly

Finder Chart: https://firefly-2100-eslint-identified-bugs-clean.irsakubedev.ipac.caltech.edu/applications/finderchart
Irsa Viewer: https://firefly-2100-eslint-identified-bugs-clean.irsakubedev.ipac.caltech.edu/irsaviewer
SphereX: https://firefly-2100-eslint-identified-bugs-clean.irsakubedev.ipac.caltech.edu/applications/spherex

Testing

1. no-async-promise-executor in src/firefly/js/Firefly.js:444

  • Reproduce: npx eslint --rule 'no-async-promise-executor: error' src/firefly/js/Firefly.js
  • Error/Fix: The nested promise within a promise is dropped; bootstrap() is now async instead.
  • Validation: This code runs when the page loads; open the test build.

2. no-useless-escape in src/firefly/js/charts/ChartUtil.js:1198

  • Reproduce: npx eslint --rule 'no-useless-escape: error' src/firefly/js/charts/ChartUtil.js
  • Error/Fix: In Javascript \d resolves to the letter d. Change \d to 0-9.
  • Unit test, in src/firefly/js/charts/__tests__/ChartUtil-test.js:
    • formatColExpr does not treat a digit as the edge of a column name
  • Validation: npx jest --config src/firefly/jest.config.js src/firefly/js/charts/__tests__/ChartUtil-test.js

3. no-fallthrough in src/firefly/js/util/expr/Expr.js:234

  • Reproduce: npx eslint --rule 'no-fallthrough: error' src/firefly/js/util/expr/Expr.js
  • Error/Fix: No return; added the missing return to case NVL2.
  • Unit test, in src/firefly/js/util/__tests__/Expression-test.js:
    • nvl2
  • Validation: npx jest --config src/firefly/jest.config.js src/firefly/js/util/__tests__/Expression-test.js -t nvl2

4. no-unsafe-optional-chaining in src/firefly/js/tables/HpxIndexCntlr.js:801, 810

  • Reproduce: npx eslint --rule 'no-unsafe-optional-chaining: error' src/firefly/js/tables/HpxIndexCntlr.js
  • Error/Fix: This code can spread undefined; the change falls back to [] before spreading, and added the !orderData guard that getKeysForOrder lacked.
  • Unit tests, in src/firefly/js/tables/__tests__/HpxIndexCntlr-test.js:
    • getValuesForOrder and getKeysForOrder return the tile entries of an order
    • getValuesForOrder and getKeysForOrder return an empty array for a missing order
    • getKeysForOrder returns an empty array without orderData
  • Validation: npx jest --config src/firefly/jest.config.js src/firefly/js/tables/__tests__/HpxIndexCntlr-test.js

5. react-hooks/rules-of-hooks in src/firefly/js/charts/ui/CombineChart.jsx:119

  • Reproduce: npx eslint src/firefly/js/charts/ui/CombineChart.jsx (this rule is already on)
  • Error/Fix: This violates React's expectation of ordered hooks; moved the early return null below the useStoreConnector hook.
  • Validation: we can load CombinePinnedCharts into the DOM and see it renders:
    1. Open the app build above URL.
    2. Click Upload from the top nav menu.
    3. Select Upload from URL, paste a URL to load spectrum data (e.g. https://firefly-2100-eslint-identified-bugs-clean-2.irsakubedev.ipac.caltech.edu/firefly/demo/SPITZER_S5_3539456_01_merge.tbl).
    4. Click Upload.
    5. Make sure to check "Attempt to interpret tables as spectra."
    6. Click Load Table.
    7. In the chart toolbar, click Pin this chart twice.
    8. Then click the Pinned Charts tab.
    9. You should see the Combine charts button (two overlapping circles) at the left of the toolbar. This is the component.
    10. We can check the dev console for the source to see the change is referenced:
Screenshot combined-pinned

6. no-constant-binary-expression in src/firefly/js/visualize/WebPlot.js:464

  • Reproduce: npx eslint --rule 'no-constant-binary-expression: error' src/firefly/js/visualize/WebPlot.js
  • Error/Fix: This can wrap the string 'undefined'; the fix applies ?? '0' before converting to a string, so a missing plot request gives '0'.
  • Validation: This code runs whenever an image is plotted. We can load a plot and check the source:
Screenshot WebPlot screenshot-webplot

7. no-dupe-else-if in src/firefly/js/visualize/draw/SelectBox.js:201

  • Reproduce: npx eslint --rule 'no-dupe-else-if: error' src/firefly/js/visualize/draw/SelectBox.js
  • Error/Fix: This is a coding/copying oversight. The duplicated circle check is now ellipse.
  • Validation: the lint command.

8. no-cond-assign in src/firefly/js/util/ObsCoreSRegionParser.js:203

  • Reproduce: npx eslint --rule 'no-cond-assign: error' src/firefly/js/util/ObsCoreSRegionParser.js
  • Error/Fix: Assignment is used instead of the check; fix is to change = → === in the BOX length check. Also pass UnitType.ARCSEC instead of the string 'arcsec', since getDim reads toUnit.key.
  • Validation: the lint command (BOX s_region is not used in the app yet, as far as I could find).

@aventura121 aventura121 changed the title Firefly-2100: Fix ESLint identified bug Firefly-2100: Fix ESLint identified behavioral errors Sep 28, 2026
@aventura121 aventura121 self-assigned this Sep 28, 2026
@aventura121 aventura121 added this to the 2026.3 milestone Sep 28, 2026
@aventura121 aventura121 changed the title Firefly-2100: Fix ESLint identified behavioral errors Firefly-2100: Fix ESLint identified errors with behavioral impacts Sep 28, 2026
@aventura121
aventura121 marked this pull request as ready for review September 28, 2026 20:18
@aventura121
aventura121 requested a review from robyww September 28, 2026 20:19

@jaladh-singhal jaladh-singhal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested most of the items in UI, they are working as expected. Also unit-tests were helpful to understand different cases and GA build passes for them!

Code changes looks good too.

expr.getParsedVariables().forEach((v) => {
if (!v.startsWith('"')) {
const re = new RegExp('([^A-Za-z\d_"]|^)(' + v + ')([^A-Za-z\d_"]|$)', 'g');
const re = new RegExp('([^A-Za-z0-9_"]|^)(' + v + ')([^A-Za-z0-9_"]|$)', 'g');

@jaladh-singhal jaladh-singhal Sep 29, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could have changed to \\d but this is fine as well

@robyww robyww left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good and there are some real bugs fixed. The improvement to Firefly.js is a cleanup I had wanted to do.

I think no-constant-binary-expression in src/firefly/js/visualize/WebPlot.js:464 is a false positive but no a big deal.

I am glad to see that you started some new test files that can be built on.

const plotState= PlotState.makePlotStateWithJson(wpInit.plotState,request0, rv0);
if (!request0) request0= plotState.getWebPlotRequest();
const colorTableId= request0?.getInitialColorTable()+'' ?? '0';
const colorTableId= String(request0?.getInitialColorTable() ?? '0');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine but I think request0?.getInitialColorTable() will always return a number and never an undefined or NaN so the the original code is valid.

Also, I don't think ESlint was returning an issue here.

Comment thread src/firefly/js/Firefly.js
* @returns {Promise.<void>}
*/
function bootstrap(props, clientAppSpecificOptions, webApiCommands) {
async function bootstrap(props, clientAppSpecificOptions, webApiCommands) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a good change. Much cleaner.

Comment thread src/firefly/js/Firefly.js

client.addListener(ActionEventHandler);
window.firefly.wsClient = client;
notifyServerAppInit({spaName:`${props.appTitle||''}--${props.template?props.template:'api'}`});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are cleaning up, this probably should be

void notifyServerAppInit({spaName:`${props.appTitle||''}--${props.template?props.template:'api'}`});

to indicate we don't care about the promise.

Comment thread src/firefly/js/Firefly.js
Comment on lines +478 to +481
defer(() => {
setTimeout(() => {
dispatchUpdateAppData({isReady: true});
},3);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I look tat this code, I wonder why we need a double defer. Probably just a setTimeout(f,5) would be fine but I think that is outside of the scope of this PR.

@aventura121
aventura121 force-pushed the FIREFLY-2100-eslint-identified-bugs-clean branch from e5b6d0c to bb2163e Compare September 29, 2026 16:41
@aventura121
aventura121 merged commit cb22577 into dev Sep 29, 2026
1 check passed
@aventura121
aventura121 deleted the FIREFLY-2100-eslint-identified-bugs-clean branch September 29, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants