From 6fb140c80050f02c2c82a4ea0136ec4a41ed229d Mon Sep 17 00:00:00 2001 From: Teon L Brooks Date: Thu, 5 Mar 2026 23:54:13 -0500 Subject: [PATCH] linting and prettier --- eslint.config.mjs | 15 +++ keys.js | 2 - package-lock.json | 2 +- package.json | 20 +-- src/main/index.ts | 53 ++++---- src/preload/index.ts | 6 +- src/preload/viewer.ts | 4 +- src/renderer/actions/deviceActions.ts | 2 +- src/renderer/actions/experimentActions.ts | 2 +- src/renderer/actions/pyodideActions.ts | 2 +- src/renderer/app.global.css | 15 ++- src/renderer/components/AnalyzeComponent.tsx | 15 +-- .../CollectComponent/HelpSidebar.tsx | 1 - .../DesignComponent/StimuliDesignColumn.tsx | 3 +- .../components/DesignComponent/index.tsx | 5 +- .../components/HomeComponent/index.tsx | 10 +- .../components/TopNavComponent/index.tsx | 2 +- .../components/styles/topnavbar.module.css | 4 +- src/renderer/constants/constants.ts | 5 +- src/renderer/epics/experimentEpics.ts | 6 +- src/renderer/experiments/custom/experiment.js | 6 +- .../experiments/faces_houses/experiment.ts | 5 +- .../experiments/multitasking/experiment.ts | 86 ++++-------- .../experiments/multitasking/utils.ts | 5 +- src/renderer/experiments/search/experiment.ts | 5 +- src/renderer/experiments/search/utils.ts | 2 +- src/renderer/experiments/stroop/experiment.ts | 8 +- src/renderer/index.html | 2 +- src/renderer/utils/eeg/cortex.js | 2 - src/renderer/utils/filesystem/select.ts | 5 +- src/renderer/utils/filesystem/storage.ts | 24 ++-- src/renderer/utils/labjs/scripts/custom.js | 124 +++++++++--------- src/renderer/viewer.html | 6 +- tsconfig.json | 12 +- 34 files changed, 213 insertions(+), 253 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 116779a..43a1df1 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -156,6 +156,21 @@ export default [ }, }, + // --- Root-level Node.js scripts (e.g. keys.js) --- + { + files: ['*.js', '*.mjs'], + languageOptions: { + globals: { + ...globals.node, + ...globals.es2020, + }, + }, + rules: { + 'no-console': 'off', + '@typescript-eslint/no-require-imports': 'off', + }, + }, + // --- Internals scripts — Node.js, more relaxed --- { files: ['internals/**/*.{js,mjs,ts}'], diff --git a/keys.js b/keys.js index ac6caff..7a9b681 100644 --- a/keys.js +++ b/keys.js @@ -5,6 +5,4 @@ const CLIENT_ID = process.env.CLIENT_ID; // Created through Cortex Apps page on const CLIENT_SECRET = process.env.CLIENT_SECRET; // Created through Cortex Apps page on Emotiv.com const LICENSE_ID = process.env.LICENSE_ID; // Visible on My Account page of Emotiv.com -const envVars = { CLIENT_ID, CLIENT_SECRET, LICENSE_ID }; - module.exports = { CLIENT_ID, CLIENT_SECRET, LICENSE_ID }; diff --git a/package-lock.json b/package-lock.json index acfa871..718b7d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,7 +98,7 @@ "vite": "^7.3.1" }, "engines": { - "node": ">=18.x", + "node": "^20.19.0 || >=22.12.0", "npm": ">=8.x" } }, diff --git a/package.json b/package.json index 86f1f55..285e68e 100644 --- a/package.json +++ b/package.json @@ -136,9 +136,6 @@ "homepage": "https://github.com/makebrainwaves/BrainWaves/", "jest": { "testEnvironment": "node", - "testEnvironmentOptions": { - "url": "http://localhost/" - }, "moduleNameMapper": { "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/internals/mocks/fileMock.js", "\\.(css|less|sass|scss)$": "identity-obj-proxy" @@ -243,22 +240,10 @@ "ws": "^8.19.0" }, "engines": { - "node": ">=18.x", + "node": "^20.19.0 || >=22.12.0", "npm": ">=8.x" }, "prettier": { - "overrides": [ - { - "files": [ - ".prettierrc", - ".eslintrc", - ".stylelintrc" - ], - "options": { - "parser": "json" - } - } - ], "singleQuote": true, "trailingComma": "es5" }, @@ -266,6 +251,5 @@ "extends": [ "stylelint-config-standard" ] - }, - "husky": {} + } } diff --git a/src/main/index.ts b/src/main/index.ts index 744ef4a..1afee37 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -37,8 +37,6 @@ export default class AppUpdater { let mainWindow: BrowserWindow | null = null; - - const installExtensions = async () => { const forceDownload = !!process.env.UPGRADE_EXTENSIONS; const sess = session.defaultSession; @@ -47,7 +45,9 @@ const installExtensions = async () => { const loadExt = async (id: string) => { const extPath = path.join(extDir, id); if (!fs.existsSync(extPath)) return; - const existing = sess.extensions.getAllExtensions().find((e) => e.id === id); + const existing = sess.extensions + .getAllExtensions() + .find((e) => e.id === id); if (existing && !forceDownload) return; if (existing) { sess.removeExtension(id); @@ -115,9 +115,7 @@ ipcMain.handle('shell:moveItemToTrash', (_event, fullPath) => ); // Workspace management -ipcMain.handle('fs:getWorkspaceDir', (_event, title) => - getWorkspaceDir(title) -); +ipcMain.handle('fs:getWorkspaceDir', (_event, title) => getWorkspaceDir(title)); ipcMain.handle('fs:createWorkspaceDir', (_event, title) => { mkdirPathSync(getWorkspaceDir(title)); @@ -173,7 +171,9 @@ ipcMain.handle('fs:restoreExperimentState', (_event, state: any) => { ipcMain.handle('fs:readWorkspaceRawEEGData', (_event, title) => { try { - const files = fs.readdirSync(getWorkspaceDir(title), { recursive: true }) as string[]; + const files = fs.readdirSync(getWorkspaceDir(title), { + recursive: true, + }) as string[]; return files .filter((filepath) => filepath.slice(-7).includes('raw.csv')) .map((filepath) => { @@ -188,7 +188,9 @@ ipcMain.handle('fs:readWorkspaceRawEEGData', (_event, title) => { ipcMain.handle('fs:readWorkspaceCleanedEEGData', (_event, title) => { try { - const files = fs.readdirSync(getWorkspaceDir(title), { recursive: true }) as string[]; + const files = fs.readdirSync(getWorkspaceDir(title), { + recursive: true, + }) as string[]; return files .filter((filepath) => filepath.slice(-7).includes('epo.fif')) .map((filepath) => { @@ -203,7 +205,9 @@ ipcMain.handle('fs:readWorkspaceCleanedEEGData', (_event, title) => { ipcMain.handle('fs:readWorkspaceBehaviorData', (_event, title) => { try { - const files = fs.readdirSync(getWorkspaceDir(title), { recursive: true }) as string[]; + const files = fs.readdirSync(getWorkspaceDir(title), { + recursive: true, + }) as string[]; return files .filter((filepath) => filepath.slice(-12).includes('behavior.csv')) .map((filepath) => { @@ -219,12 +223,7 @@ ipcMain.handle('fs:readWorkspaceBehaviorData', (_event, title) => { ipcMain.handle( 'fs:storeBehavioralData', (_event, csv, title, subject, group, session) => { - const dir = path.join( - getWorkspaceDir(title), - 'Data', - subject, - 'Behavior' - ); + const dir = path.join(getWorkspaceDir(title), 'Data', subject, 'Behavior'); const filename = `${subject}-${group}-${session}-behavior.csv`; mkdirPathSync(dir); return new Promise((resolve, reject) => { @@ -310,19 +309,16 @@ ipcMain.handle( } ); -ipcMain.handle( - 'fs:checkFileExists', - (_event, title, subject, filename) => { - const file = path.join( - getWorkspaceDir(title), - 'Data', - subject, - 'Behavior', - filename - ); - return fs.existsSync(file); - } -); +ipcMain.handle('fs:checkFileExists', (_event, title, subject, filename) => { + const file = path.join( + getWorkspaceDir(title), + 'Data', + subject, + 'Behavior', + filename + ); + return fs.existsSync(file); +}); ipcMain.handle('fs:readFiles', (_event, filePathsArray: string[]) => { return filePathsArray.map((filePath) => { @@ -455,7 +451,6 @@ const createWindow = async () => { const menuBuilder = new MenuBuilder(mainWindow); menuBuilder.buildMenu(); - // eslint-disable-next-line new AppUpdater(); }; diff --git a/src/preload/index.ts b/src/preload/index.ts index a3977a5..f140c9a 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -143,9 +143,7 @@ contextBridge.exposeInMainWorld('electronAPI', { // ------------------------------------------------------------------ // Misc // ------------------------------------------------------------------ - getResourcePath: (): Promise => - ipcRenderer.invoke('getResourcePath'), + getResourcePath: (): Promise => ipcRenderer.invoke('getResourcePath'), - getViewerUrl: (): Promise => - ipcRenderer.invoke('getViewerUrl'), + getViewerUrl: (): Promise => ipcRenderer.invoke('getViewerUrl'), }); diff --git a/src/preload/viewer.ts b/src/preload/viewer.ts index 165bb2e..5c7793a 100644 --- a/src/preload/viewer.ts +++ b/src/preload/viewer.ts @@ -26,7 +26,9 @@ contextBridge.exposeInMainWorld('viewerAPI', { ipcRenderer.on('updateDomain', (_event, message) => callback(message)), onUpdateDownsampling: (callback: (message: unknown) => void) => - ipcRenderer.on('updateDownsampling', (_event, message) => callback(message)), + ipcRenderer.on('updateDownsampling', (_event, message) => + callback(message) + ), onAutoScale: (callback: () => void) => ipcRenderer.on('autoScale', () => callback()), diff --git a/src/renderer/actions/deviceActions.ts b/src/renderer/actions/deviceActions.ts index 52945a5..9338b0f 100644 --- a/src/renderer/actions/deviceActions.ts +++ b/src/renderer/actions/deviceActions.ts @@ -37,5 +37,5 @@ export const DeviceActions = { } as const; export type DeviceActionType = ActionType< - typeof DeviceActions[keyof typeof DeviceActions] + (typeof DeviceActions)[keyof typeof DeviceActions] >; diff --git a/src/renderer/actions/experimentActions.ts b/src/renderer/actions/experimentActions.ts index fa32551..43edfba 100644 --- a/src/renderer/actions/experimentActions.ts +++ b/src/renderer/actions/experimentActions.ts @@ -41,5 +41,5 @@ export const ExperimentActions = { } as const; export type ExperimentActionType = ActionType< - typeof ExperimentActions[keyof typeof ExperimentActions] + (typeof ExperimentActions)[keyof typeof ExperimentActions] >; diff --git a/src/renderer/actions/pyodideActions.ts b/src/renderer/actions/pyodideActions.ts index 69d7678..1a953f4 100644 --- a/src/renderer/actions/pyodideActions.ts +++ b/src/renderer/actions/pyodideActions.ts @@ -32,5 +32,5 @@ export const PyodideActions = { } as const; export type PyodideActionType = ActionType< - typeof PyodideActions[keyof typeof PyodideActions] + (typeof PyodideActions)[keyof typeof PyodideActions] >; diff --git a/src/renderer/app.global.css b/src/renderer/app.global.css index 0ba17f5..101516a 100644 --- a/src/renderer/app.global.css +++ b/src/renderer/app.global.css @@ -7,7 +7,10 @@ body { position: relative; height: 100vh; background: rgba(255, 255, 255, 0.2); - font-family: Lato, Helvetica Neue, sans-serif; + font-family: + Lato, + Helvetica Neue, + sans-serif; overflow-y: hidden; } @@ -183,12 +186,18 @@ button:active { .ui.sidebar { box-shadow: none !important; border: 2px solid #e6e6e6 !important; - transition: width 0.5s ease, transform 0.5s ease, -webkit-transform 0.5s ease !important; + transition: + width 0.5s ease, + transform 0.5s ease, + -webkit-transform 0.5s ease !important; } .pusher { width: 100%; - transition: width 0.5s ease, transform 0.5s ease, -webkit-transform 0.5s ease !important; + transition: + width 0.5s ease, + transform 0.5s ease, + -webkit-transform 0.5s ease !important; float: right; } diff --git a/src/renderer/components/AnalyzeComponent.tsx b/src/renderer/components/AnalyzeComponent.tsx index 7c11739..19d4083 100644 --- a/src/renderer/components/AnalyzeComponent.tsx +++ b/src/renderer/components/AnalyzeComponent.tsx @@ -137,21 +137,18 @@ export default class Analyze extends Component { }; this.handleChannelSelect = this.handleChannelSelect.bind(this); this.handleDatasetChange = this.handleDatasetChange.bind(this); - this.handleBehaviorDatasetChange = this.handleBehaviorDatasetChange.bind( - this - ); - this.handleDependentVariableChange = this.handleDependentVariableChange.bind( - this - ); + this.handleBehaviorDatasetChange = + this.handleBehaviorDatasetChange.bind(this); + this.handleDependentVariableChange = + this.handleDependentVariableChange.bind(this); this.handleRemoveOutliers = this.handleRemoveOutliers.bind(this); this.handleDisplayModeChange = this.handleDisplayModeChange.bind(this); this.handleDataPoints = this.handleDataPoints.bind(this); this.saveSelectedDatasets = this.saveSelectedDatasets.bind(this); this.handleStepClick = this.handleStepClick.bind(this); this.handleDropdownClick = this.handleDropdownClick.bind(this); - this.toggleDisplayInfoVisibility = this.toggleDisplayInfoVisibility.bind( - this - ); + this.toggleDisplayInfoVisibility = + this.toggleDisplayInfoVisibility.bind(this); } async componentDidMount() { diff --git a/src/renderer/components/CollectComponent/HelpSidebar.tsx b/src/renderer/components/CollectComponent/HelpSidebar.tsx index 91d9484..c36129d 100644 --- a/src/renderer/components/CollectComponent/HelpSidebar.tsx +++ b/src/renderer/components/CollectComponent/HelpSidebar.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/no-multi-comp */ import React, { Component } from 'react'; import { Segment, Header, Menu, Icon, Button, Grid } from 'semantic-ui-react'; import styles from '../styles/common.module.css'; diff --git a/src/renderer/components/DesignComponent/StimuliDesignColumn.tsx b/src/renderer/components/DesignComponent/StimuliDesignColumn.tsx index 08fe8e0..5ec4b84 100644 --- a/src/renderer/components/DesignComponent/StimuliDesignColumn.tsx +++ b/src/renderer/components/DesignComponent/StimuliDesignColumn.tsx @@ -119,7 +119,8 @@ export default class StimuliDesignColumn extends Component { this.props.dir.split(path.sep).slice(-1).join(' / ')}
- ( {this.state.numberImages || this.props.numberImages} images ){' '} + ( {this.state.numberImages || this.props.numberImages} images + ){' '}
diff --git a/src/renderer/components/DesignComponent/index.tsx b/src/renderer/components/DesignComponent/index.tsx index 49d47eb..6f3800a 100644 --- a/src/renderer/components/DesignComponent/index.tsx +++ b/src/renderer/components/DesignComponent/index.tsx @@ -79,9 +79,8 @@ export default class Design extends Component { this.handleStepClick = this.handleStepClick.bind(this); this.handleStartExperiment = this.handleStartExperiment.bind(this); this.handleCustomizeExperiment = this.handleCustomizeExperiment.bind(this); - this.handleLoadCustomExperiment = this.handleLoadCustomExperiment.bind( - this - ); + this.handleLoadCustomExperiment = + this.handleLoadCustomExperiment.bind(this); this.handlePreview = this.handlePreview.bind(this); this.endPreview = this.endPreview.bind(this); this.handleEEGEnabled = this.handleEEGEnabled.bind(this); diff --git a/src/renderer/components/HomeComponent/index.tsx b/src/renderer/components/HomeComponent/index.tsx index 59c29a3..7838d05 100644 --- a/src/renderer/components/HomeComponent/index.tsx +++ b/src/renderer/components/HomeComponent/index.tsx @@ -88,9 +88,8 @@ export default class Home extends Component { }; this.handleStepClick = this.handleStepClick.bind(this); this.handleNewExperiment = this.handleNewExperiment.bind(this); - this.handleLoadCustomExperiment = this.handleLoadCustomExperiment.bind( - this - ); + this.handleLoadCustomExperiment = + this.handleLoadCustomExperiment.bind(this); this.handleOpenOverview = this.handleOpenOverview.bind(this); this.handleCloseOverview = this.handleCloseOverview.bind(this); this.handleDeleteWorkspace = this.handleDeleteWorkspace.bind(this); @@ -237,8 +236,7 @@ export default class Home extends Component { {dir} - {dateModified && - dayjs(dateModified).fromNow()} + {dateModified && dayjs(dateModified).fromNow()}