-
Notifications
You must be signed in to change notification settings - Fork 17
Firefly-2100: Fix ESLint identified errors with behavioral impacts #2024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -434,58 +434,53 @@ export const firefly = { | |
| * @param {AppProps} props - application properties | ||
| * @param {FireflyOptions} clientAppSpecificOptions - firefly options specific to this client | ||
| * @param {Array.<WebApiCommand>} webApiCommands | ||
| * @returns {Promise.<boolean>} | ||
| * @returns {Promise.<void>} | ||
| */ | ||
| function bootstrap(props, clientAppSpecificOptions, webApiCommands) { | ||
| async function bootstrap(props, clientAppSpecificOptions, webApiCommands) { | ||
|
|
||
| if (window?.firefly?.initialized) return Promise.resolve(); // if initialized, don't run it again. | ||
| if (window?.firefly?.initialized) return; // if initialized, don't run it again. | ||
|
|
||
| set(window, 'firefly.initialized', true); | ||
| return new Promise(async (resolve) => { | ||
|
|
||
| const processDecor= (process) => (rawAction) => { | ||
| getOrCreateWsConn().catch(() => { | ||
| if (!getConnectionStatus()?.lost) { // set lost status only when it's not already set, to avoid circular dispatches | ||
| dispatchConnectionStatus({lost: true, reason: 'You are no longer connected to the server'}); | ||
| } | ||
| }); | ||
| process(rawAction); | ||
| recordHistory(rawAction); | ||
| }; | ||
|
|
||
| bootstrapRedux( getBootstrapRegistry(), processDecor); | ||
| flux.process( {type : APP_LOAD} ); // setup initial store/state | ||
| const processDecor= (process) => (rawAction) => { | ||
| getOrCreateWsConn().catch(() => { | ||
| if (!getConnectionStatus()?.lost) { // set lost status only when it's not already set, to avoid circular dispatches | ||
| dispatchConnectionStatus({lost: true, reason: 'You are no longer connected to the server'}); | ||
| } | ||
| }); | ||
| process(rawAction); | ||
| recordHistory(rawAction); | ||
| }; | ||
|
|
||
| let srvAppSpecificOptions={}; | ||
| try { | ||
| srvAppSpecificOptions= await getJsonProperty('FIREFLY_OPTIONS'); | ||
| } | ||
| catch (err) { | ||
| logger.error('could not retrieve valid server options'); | ||
| } | ||
| // const appSpecificOptions = mergeObjectOnly(clientAppSpecificOptions, srvAppSpecificOptions); | ||
| const appSpecificOptions = mergeAppOptions(clientAppSpecificOptions, srvAppSpecificOptions); | ||
| bootstrapRedux( getBootstrapRegistry(), processDecor); | ||
| flux.process( {type : APP_LOAD} ); // setup initial store/state | ||
|
|
||
| const client= await getOrCreateWsConn(); // establish websocket connection first before doing anything else. | ||
| let srvAppSpecificOptions={}; | ||
| try { | ||
| srvAppSpecificOptions= await getJsonProperty('FIREFLY_OPTIONS'); | ||
| } | ||
| catch (err) { | ||
| logger.error('could not retrieve valid server options'); | ||
| } | ||
| // const appSpecificOptions = mergeObjectOnly(clientAppSpecificOptions, srvAppSpecificOptions); | ||
| const appSpecificOptions = mergeAppOptions(clientAppSpecificOptions, srvAppSpecificOptions); | ||
|
|
||
| fireflyInit(props, appSpecificOptions, webApiCommands); | ||
| const client= await getOrCreateWsConn(); // establish websocket connection first before doing anything else. | ||
|
|
||
| client.addListener(ActionEventHandler); | ||
| window.firefly.wsClient = client; | ||
| notifyServerAppInit({spaName:`${props.appTitle||''}--${props.template?props.template:'api'}`}); | ||
| loadAllJobs(); | ||
| resolve?.(); | ||
| fireflyInit(props, appSpecificOptions, webApiCommands); | ||
|
|
||
| client.addListener(ActionEventHandler); | ||
| window.firefly.wsClient = client; | ||
| notifyServerAppInit({spaName:`${props.appTitle||''}--${props.template?props.template:'api'}`}); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| loadAllJobs(); | ||
|
|
||
| }).then(() => { | ||
| // when all is done, mark app as 'ready' | ||
| defer(() => { | ||
| setTimeout(() => { | ||
| dispatchUpdateAppData({isReady: true}); | ||
| },3); | ||
| }); | ||
| initWorkerContext(); | ||
| // when all is done, mark app as 'ready' | ||
| defer(() => { | ||
| setTimeout(() => { | ||
| dispatchUpdateAppData({isReady: true}); | ||
| },3); | ||
|
Comment on lines
+478
to
+481
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| }); | ||
| initWorkerContext(); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1195,7 +1195,7 @@ export function formatColExpr({colOrExpr, quoted, colNames}) { | |
| // quote columns, assuming column names are alpha-numeric | ||
| 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'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could have changed to |
||
| while (colOrExpr.match(re)) { // while is needed to handle cases like v*v | ||
| colOrExpr = colOrExpr.replace(re, '$1"$2"$3'); // add quotes | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /*eslint-env node, jest */ | ||
| import {formatColExpr} from 'firefly/charts/ChartUtil.js'; | ||
|
|
||
|
|
||
| describe('ChartUtil', () => { | ||
| test('formatColExpr does not treat a digit as the edge of a column name', () => { | ||
| const colNames = ['val', 'val2']; | ||
| expect(formatColExpr({colOrExpr: 'val + val2', quoted: true, colNames})).toBe('"val"+"val2"'); | ||
| expect(formatColExpr({colOrExpr: 'val2 + val', quoted: true, colNames})).toBe('"val2"+"val"'); | ||
|
|
||
| // the digits around e belong to the number 1e5 | ||
| expect(formatColExpr({colOrExpr: '1e5*e', quoted: true, colNames: ['e']})).toBe('1e5*"e"'); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import {getKeysForOrder, getValuesForOrder} from '../HpxIndexCntlr.js'; | ||
|
|
||
|
|
||
| describe('HpxIndexCntlr', () => { | ||
| const orderData = {5: {norder: 5, tiles: [new Map([[1, 'a'], [2, 'b']])]}}; | ||
|
|
||
| test('getValuesForOrder and getKeysForOrder return the tile entries of an order', () => { | ||
| expect(getValuesForOrder(orderData, 5)).toEqual(['a', 'b']); | ||
| expect(getKeysForOrder(orderData, 5)).toEqual([1, 2]); | ||
| }); | ||
|
|
||
| test('getValuesForOrder and getKeysForOrder return an empty array for a missing order', () => { | ||
| expect(getValuesForOrder(orderData, 1)).toEqual([]); | ||
| expect(getKeysForOrder(orderData, 1)).toEqual([]); | ||
| }); | ||
|
|
||
| test('getKeysForOrder returns an empty array without orderData', () => { | ||
| expect(getKeysForOrder(undefined, 4)).toEqual([]); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -461,7 +461,7 @@ export const WebPlot= { | |
| const relatedData = cubeCtx ? cubeCtx.relatedData : wpInit.relatedData; | ||
| const plotState= PlotState.makePlotStateWithJson(wpInit.plotState,request0, rv0); | ||
| if (!request0) request0= plotState.getWebPlotRequest(); | ||
| const colorTableId= request0?.getInitialColorTable()+'' ?? '0'; | ||
| const colorTableId= String(request0?.getInitialColorTable() ?? '0'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is fine but I think Also, I don't think ESlint was returning an issue here. |
||
|
|
||
| const {processHeader, wlData, wlDataAry, headerAry, header, zeroHeader, | ||
| allWCSMap, allWlMap}= getAllHeaderAndWlInfo(cubeCtx,wpInit,plotState); | ||
|
|
||
There was a problem hiding this comment.
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.