mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 22:10:15 +03:00
Fix all eslint errors (#6267)
Fixes all eslint errors - now `npx eslint .` in `app/ide-desktop` should show no errors and no warnings. Also fixes an incorrect lint rule (the rule to catch early returns (?) did not work properly for `try-catch`) # Important Notes This changes quite a few files (unfortunately) so QA should be done to check all affected files
This commit is contained in:
parent
f3873f9768
commit
3e5a3dc468
@ -102,7 +102,7 @@ const RESTRICTED_SYNTAXES = [
|
||||
},
|
||||
{
|
||||
selector:
|
||||
':not(:matches(FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, SwitchStatement, SwitchCase, IfStatement:has(.consequent > :matches(ReturnStatement, ThrowStatement)):has(.alternate :matches(ReturnStatement, ThrowStatement)), TryStatement:has(.block > :matches(ReturnStatement, ThrowStatement)):has(:matches([handler=null], .handler :matches(ReturnStatement, ThrowStatement))):has(:matches([finalizer=null], .finalizer :matches(ReturnStatement, ThrowStatement))))) > * > :matches(ReturnStatement, ThrowStatement)',
|
||||
':not(:matches(FunctionDeclaration, FunctionExpression, ArrowFunctionExpression, SwitchStatement, SwitchCase, IfStatement:has(.consequent > :matches(ReturnStatement, ThrowStatement)):has(.alternate :matches(ReturnStatement, ThrowStatement)), Program > TryStatement, Program > TryStatement > .handler, TryStatement:has(.block > :matches(ReturnStatement, ThrowStatement)):has(:matches([handler=null], .handler :matches(ReturnStatement, ThrowStatement))), TryStatement:has(.block > :matches(ReturnStatement, ThrowStatement)):has(:matches([handler=null], .handler :matches(ReturnStatement, ThrowStatement))) > .handler)) > * > :matches(ReturnStatement, ThrowStatement)',
|
||||
message: 'No early returns',
|
||||
},
|
||||
{
|
||||
|
@ -17,9 +17,9 @@ import yargs from 'yargs'
|
||||
|
||||
import * as common from 'enso-common'
|
||||
|
||||
import * as paths from './paths.js'
|
||||
import signArchivesMacOs from './tasks/signArchivesMacOs.js'
|
||||
import { BUNDLED_PROJECT_EXTENSION, SOURCE_FILE_EXTENSION } from './file-associations.js'
|
||||
import * as fileAssociations from './file-associations'
|
||||
import * as paths from './paths'
|
||||
import signArchivesMacOs from './tasks/signArchivesMacOs'
|
||||
|
||||
import BUILD_INFO from '../../build.json' assert { type: 'json' }
|
||||
|
||||
@ -157,12 +157,12 @@ export function createElectronBuilderConfig(passedArgs: Arguments): electronBuil
|
||||
],
|
||||
fileAssociations: [
|
||||
{
|
||||
ext: SOURCE_FILE_EXTENSION,
|
||||
ext: fileAssociations.SOURCE_FILE_EXTENSION,
|
||||
name: `${common.PRODUCT_NAME} Source File`,
|
||||
role: 'Editor',
|
||||
},
|
||||
{
|
||||
ext: BUNDLED_PROJECT_EXTENSION,
|
||||
ext: fileAssociations.BUNDLED_PROJECT_EXTENSION,
|
||||
name: `${common.PRODUCT_NAME} Project Bundle`,
|
||||
role: 'Editor',
|
||||
},
|
||||
|
@ -72,12 +72,13 @@
|
||||
* {@link URL} to redirect the user to the dashboard, to the page specified in the {@link URL}'s
|
||||
* `pathname`. */
|
||||
|
||||
import * as electron from 'electron'
|
||||
import opener from 'opener'
|
||||
import * as fs from 'node:fs'
|
||||
import * as os from 'node:os'
|
||||
import * as path from 'node:path'
|
||||
|
||||
import * as electron from 'electron'
|
||||
import opener from 'opener'
|
||||
|
||||
import * as common from 'enso-common'
|
||||
import * as contentConfig from 'enso-content-config'
|
||||
|
||||
@ -158,15 +159,15 @@ function initSaveAccessTokenListener() {
|
||||
/** System agnostic credentials directory home path. */
|
||||
const ensoCredentialsHomePath = path.join(os.homedir(), ensoCredentialsDirectoryName)
|
||||
|
||||
fs.mkdir(ensoCredentialsHomePath, { recursive: true }, err => {
|
||||
if (err) {
|
||||
fs.mkdir(ensoCredentialsHomePath, { recursive: true }, error => {
|
||||
if (error) {
|
||||
logger.error(`Couldn't create ${ensoCredentialsDirectoryName} directory.`)
|
||||
} else {
|
||||
fs.writeFile(
|
||||
path.join(ensoCredentialsHomePath, ensoCredentialsFileName),
|
||||
accessToken,
|
||||
err => {
|
||||
if (err) {
|
||||
innerError => {
|
||||
if (innerError) {
|
||||
logger.error(`Could not write to ${ensoCredentialsFileName} file.`)
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,9 @@ export function pathOrPanic(args: config.Args): string {
|
||||
const binExists = fsSync.existsSync(binPath)
|
||||
if (!binExists) {
|
||||
throw new Error(`Could not find the project manager binary at ${binPath}.`)
|
||||
} else {
|
||||
return binPath
|
||||
}
|
||||
return binPath
|
||||
}
|
||||
|
||||
/** Executes the Project Manager with given arguments. */
|
||||
|
@ -136,16 +136,16 @@ export function onFileOpened(event: Event, path: string) {
|
||||
export function handleOpenFile(openedFile: string): string {
|
||||
try {
|
||||
return project.importProjectFromPath(openedFile)
|
||||
} catch (e: unknown) {
|
||||
} catch (error) {
|
||||
// Since the user has explicitly asked us to open a file, in case of an error, we should
|
||||
// display a message box with the error details.
|
||||
let message = `Cannot open file '${openedFile}'.`
|
||||
message += `\n\nReason:\n${e?.toString() ?? 'Unknown error'}`
|
||||
if (e instanceof Error && typeof e.stack !== 'undefined') {
|
||||
message += `\n\nDetails:\n${e.stack}`
|
||||
message += `\n\nReason:\n${error?.toString() ?? 'Unknown error'}`
|
||||
if (error instanceof Error && typeof error.stack !== 'undefined') {
|
||||
message += `\n\nDetails:\n${error.stack}`
|
||||
}
|
||||
logger.error(e)
|
||||
logger.error(error)
|
||||
electron.dialog.showErrorBox(common.PRODUCT_NAME, message)
|
||||
throw e
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
@ -281,9 +281,9 @@ class App {
|
||||
fsSync.writeFileSync(profileOutPath, data)
|
||||
})
|
||||
}
|
||||
electron.ipcMain.on(ipc.Channel.openGpuDebugInfo, _event => {
|
||||
electron.ipcMain.on(ipc.Channel.openGpuDebugInfo, () => {
|
||||
if (this.window != null) {
|
||||
this.window.loadURL('chrome://gpu')
|
||||
void this.window.loadURL('chrome://gpu')
|
||||
}
|
||||
})
|
||||
electron.ipcMain.on(ipc.Channel.quit, () => {
|
||||
|
@ -51,8 +51,9 @@ export function importProjectFromPath(openedPath: string): string {
|
||||
if (rootPath == null) {
|
||||
const message = `File '${openedPath}' does not belong to the ${common.PRODUCT_NAME} project.`
|
||||
throw new Error(message)
|
||||
} else {
|
||||
return importDirectory(rootPath)
|
||||
}
|
||||
return importDirectory(rootPath)
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,13 +100,13 @@ export function importDirectory(rootPath: string): string {
|
||||
if (fsSync.existsSync(targetDirectory)) {
|
||||
const message = `Project directory already exists: ${targetDirectory}.`
|
||||
throw new Error(message)
|
||||
} else {
|
||||
logger.log(`Copying: '${rootPath}' -> '${targetDirectory}'.`)
|
||||
fsSync.cpSync(rootPath, targetDirectory, { recursive: true })
|
||||
// Update the project ID, so we are certain that it is unique. This would be violated, if we imported the same
|
||||
// project multiple times.
|
||||
return updateId(targetDirectory)
|
||||
}
|
||||
|
||||
logger.log(`Copying: '${rootPath}' -> '${targetDirectory}'.`)
|
||||
fsSync.cpSync(rootPath, targetDirectory, { recursive: true })
|
||||
// Update the project ID, so we are certain that it is unique. This would be violated, if we imported the same
|
||||
// project multiple times.
|
||||
return updateId(targetDirectory)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,6 +196,7 @@ class ArchiveToSign implements Signable {
|
||||
console.log(
|
||||
`Successfully repacked ${this.path} to handle signing inner native dependency.`
|
||||
)
|
||||
return
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`Could not repackage ${archiveName}. Please check the ${import.meta.url} task to ` +
|
||||
|
@ -33,6 +33,7 @@ async function bundle() {
|
||||
path.resolve(THIS_PATH, 'src', 'index.tsx')
|
||||
)
|
||||
await esbuild.build(opts)
|
||||
return
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
// The error is being re-thrown.
|
||||
|
@ -360,7 +360,6 @@ export function useAuth() {
|
||||
// === ProtectedLayout ===
|
||||
// =======================
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export function ProtectedLayout() {
|
||||
const { session } = useAuth()
|
||||
|
||||
@ -375,7 +374,6 @@ export function ProtectedLayout() {
|
||||
// === GuestLayout ===
|
||||
// ===================
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
export function GuestLayout() {
|
||||
const { session } = useAuth()
|
||||
|
||||
|
@ -11,6 +11,9 @@ import * as platform from 'enso-authentication/src/platform'
|
||||
const ESBUILD_PATH = '/esbuild'
|
||||
/** SSE event indicating a build has finished. */
|
||||
const ESBUILD_EVENT_NAME = 'change'
|
||||
/** Path to the service worker that resolves all extensionless paths to `/index.html`.
|
||||
* This service worker is required for client-side routing to work when doing local development. */
|
||||
const SERVICE_WORKER_PATH = '/serviceWorker.js'
|
||||
|
||||
// ===================
|
||||
// === Live reload ===
|
||||
@ -20,7 +23,7 @@ if (IS_DEV_MODE) {
|
||||
new EventSource(ESBUILD_PATH).addEventListener(ESBUILD_EVENT_NAME, () => {
|
||||
location.reload()
|
||||
})
|
||||
void navigator.serviceWorker.register('/serviceWorker.js')
|
||||
void navigator.serviceWorker.register(SERVICE_WORKER_PATH)
|
||||
}
|
||||
|
||||
// ===================
|
||||
|
@ -217,8 +217,10 @@ async function main() {
|
||||
throw Error(
|
||||
`Script '${script}' invocation needs to be given an output path either through command line argument or 'ENSO_BUILD_ICONS' environment variable.`
|
||||
)
|
||||
} else {
|
||||
await genIcons(outputDir)
|
||||
return
|
||||
}
|
||||
await genIcons(outputDir)
|
||||
}
|
||||
|
||||
await main()
|
||||
|
Loading…
Reference in New Issue
Block a user