Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions .eslintrc.js

This file was deleted.

60 changes: 60 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["typescript", "import", "react", "vitest"],
"categories": {
"correctness": "error"
},
"env": {
"browser": true,
"node": true,
"es2024": true
},
"rules": {
"no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"caughtErrors": "none"
}
],
"sort-imports": [
"error",
{
"ignoreCase": false,
"ignoreDeclarationSort": true,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"],
"allowSeparatedGroups": true
}
],
"import/default": "error",
"import/no-duplicates": "warn",
"import/no-named-as-default": "warn",
"import/namespace": "off",
"import/no-named-as-default-member": "off",
"react/react-in-jsx-scope": "error",
"react/display-name": "error",
"react/jsx-no-comment-textnodes": "error",
"react/jsx-no-target-blank": "error",
"react/no-unescaped-entities": "error",
"react/no-unknown-property": "error",
"typescript/no-array-constructor": "error",
"typescript/no-namespace": "error",
"typescript/no-unnecessary-type-constraint": "error",
"typescript/no-unsafe-function-type": "error",
"vitest/require-mock-type-parameters": "off",
"react/no-did-mount-set-state": "off",
"vitest/expect-expect": "off",
"vitest/no-conditional-expect": "off",
"vitest/no-standalone-expect": "off",
"vitest/require-to-throw-message": "off"
},
"ignorePatterns": [
"/out",
"/.webpack",
"/coverage",
"/node_modules",
"/.yarn",
"/static"
]
}
18 changes: 3 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"format": "prettier src --check --experimental-cli",
"format:write": "prettier src --write --experimental-cli",
"lint:style": "stylelint \"./src/less/*.less\"",
"lint:ts": "eslint \"./**/*.{ts,tsx}\"",
"lint:js": "eslint \"./**/*.js\"",
"lint:js": "oxlint",
"lint:markdown": "markdownlint-cli2 \"*.md\"",
"lint:templates": "standard \"static/**/*.js\"",
"lint:links": "lint-roller-markdown-links \"*.md\"",
Expand Down Expand Up @@ -99,20 +98,12 @@
"@types/react-dom": "^16.9.11",
"@types/react-window": "^1.8.8",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vercel/webpack-asset-relocator-loader": "^1.7.2",
"@vitest/coverage-v8": "4.1.0",
"copy-webpack-plugin": "^14.0.0",
"css-loader": "^6.7.1",
"electron": "^42.3.3",
"electron-devtools-installer": "^4.0.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-tsdoc": "^0.3.0",
"fork-ts-checker-webpack-plugin": "^8.0.0",
"husky": "^9.0.11",
"jsdom": "^26.1.0",
Expand All @@ -124,6 +115,7 @@
"mini-css-extract-plugin": "^2.6.1",
"monaco-editor-webpack-plugin": "^3.0.0",
"npm-run-all2": "^7.0.1",
"oxlint": "^1.81.0",
"postcss": "^8.5.23",
"postcss-less": "^6.0.0",
"resolve-url-loader": "^5.0.0",
Expand All @@ -139,14 +131,10 @@
"webpack": "^5.104.1"
},
"lint-staged": {
"./**/*.js": [
"./**/*.{js,ts,tsx}": [
"npm run lint:js -- --fix",
"prettier --write --experimental-cli"
],
"./**/*.{ts,tsx}": [
"npm run lint:ts -- --fix",
"prettier --write --experimental-cli"
],
"./static/**/*.js": [
"npm run lint:templates -- --fix"
],
Expand Down
28 changes: 10 additions & 18 deletions src/main/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ async function isOkToSaveAt(filePath: string): Promise<boolean> {
* want to overwrite an existing file
*/
async function confirmFileOverwrite(filePath: string): Promise<boolean> {
try {
const result = await dialog.showMessageBox({
type: 'warning',
buttons: ['Cancel', 'Yes'],
message: 'Overwrite files?',
detail: `The file ${filePath} already exists. Do you want to overwrite it?`,
});

return result.response === 1;
} catch (error) {
// Let's not overwrite files. We'd rather crash.
throw error;
}
// If the dialog fails, let it throw. Let's not overwrite files. We'd rather crash.
const result = await dialog.showMessageBox({
type: 'warning',
buttons: ['Cancel', 'Yes'],
message: 'Overwrite files?',
detail: `The file ${filePath} already exists. Do you want to overwrite it?`,
});

return result.response === 1;
}

/**
Expand Down Expand Up @@ -169,11 +165,7 @@ export async function saveFilesToTemp(files: Files): Promise<string> {
console.warn(`saveFilesToTemp: rejected unsafe filename: ${name}`);
continue;
}
try {
await fs.outputFile(path.join(dir, name), content);
} catch (error) {
throw error;
}
await fs.outputFile(path.join(dir, name), content);
}

return dir;
Expand Down
2 changes: 1 addition & 1 deletion src/main/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class IpcMainManager extends EventEmitter {
this.messageQueue.set(target, [...existing, [channel, args]]);
return;
}
target.isDestroyed() || target.send(channel, ..._args);
if (!target.isDestroyed()) target.send(channel, ..._args);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function getMainWindowOptions(): Electron.BrowserWindowConstructorOptions
backgroundColor: '#1d2427',
show: false,
webPreferences: {
preload: !!process.env.VITEST
preload: process.env.VITEST
? path.join(process.cwd(), './.webpack/renderer/main_window/preload.js')
: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
nodeIntegration: false,
Expand Down
1 change: 1 addition & 0 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export class App {
}

const [
// oxlint-disable-next-line no-unused-vars -- React is used by the JSX below
{ default: React },
{ render },
{ Dialogs },
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/commands-bisect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const BisectHandler = observer(

public render() {
const { appState } = this.props;
if (!!appState.Bisector) {
if (appState.Bisector) {
const isDownloading =
appState.currentElectronVersion.state === InstallState.downloading;
return (
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class Editor extends React.Component<EditorProps> {
* Initialize Monaco.
*/
public async initMonaco() {
const { monaco, monacoOptions: monacoOptions, appState } = this.props;
const { monaco, monacoOptions, appState } = this.props;
const ref = this.containerRef.current;

const { fontFamily, fontSize } = appState;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const Output = observer(
* Initialize Monaco.
*/
public async initMonaco() {
const { monaco, monacoOptions: monacoOptions } = this.props;
const { monaco, monacoOptions } = this.props;
const ref = this.outputRef.current;
if (ref) {
this.setupCustomOutputEditorLanguage(monaco);
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/components/settings-electron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ const ElectronVersionRow = observer(({ index, style, data }: RowProps) => {
buttonProps.icon = isLocal ? 'trash' : 'cloud-download';
buttonProps.text = isLocal ? 'Remove' : 'Download';
buttonProps.onClick = () => {
isLocal ? appState.removeVersion(ver) : appState.downloadVersion(ver);
if (isLocal) {
appState.removeVersion(ver);
} else {
appState.downloadVersion(ver);
}
};
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/settings-general-github.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const GitHubSettings = observer(
const { gitHubLogin } = this.props.appState;
const { isPublishingGistAsRevision } = this.props.appState;

const maybeSignedIn = !!gitHubLogin
const maybeSignedIn = gitHubLogin
? this.renderSignedIn()
: this.renderNotSignedIn();

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/utils/highlight-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function highlightText(
const words = query
.split(/\s+/)
.filter((word) => word.length > 0)
.map((s) => s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1'));
.map((s) => s.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1'));

if (words.length === 0) return [text];

Expand Down
4 changes: 2 additions & 2 deletions src/renderer/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ export function makeRunnable(ver: Version): RunnableVersion {
const ret: RunnableVersion = {
...ver,
version: normalizeVersion(ver.version),
source: Boolean(ver.localPath) ? VersionSource.local : VersionSource.remote,
state: Boolean(ver.localPath)
source: ver.localPath ? VersionSource.local : VersionSource.remote,
state: ver.localPath
? window.ElectronFiddle.getLocalVersionState({ ...ver })
: InstallState.missing,
};
Expand Down
2 changes: 1 addition & 1 deletion tests/renderer/app.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ describe('App component', () => {
() => vi.mocked(window.ElectronFiddle.showWindow).mock.calls.length > 0,
);
expect(window.close).not.toHaveBeenCalled();
expect(!app.state.isQuitting);
expect(app.state.isQuitting).toBe(false);
});
});
});
4 changes: 2 additions & 2 deletions tests/renderer/file-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('FileManager', () => {

it('opens a fiddle with supported files', async () => {
const file = 'file.js';
expect(isSupportedFile(file));
expect(isSupportedFile(file)).toBe(true);
const content = '// content';
const values = { ...editorValues, [file]: content };
app.remoteLoader.confirmAddFile.mockResolvedValue(true);
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('FileManager', () => {
it('includes supported files', async () => {
const file = 'file.js';
const content = '// file.js';
expect(isSupportedFile(file));
expect(isSupportedFile(file)).toBe(true);
const values = { ...editorValues, [file]: content };

app.getEditorValues.mockReturnValue(values);
Expand Down
8 changes: 4 additions & 4 deletions tests/renderer/utils/editor-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ describe('editor-utils', () => {
it('recognizes known files', () => {
// setup: id is a known file
for (const id of [MAIN_CJS, MAIN_JS, MAIN_MJS] as const) {
expect(isKnownFile(id));
expect(isSupportedFile(id));
expect(isKnownFile(id)).toBe(true);
expect(isSupportedFile(id)).toBe(true);

expect(getEditorTitle(id)).toBe(`Main Process (${id})`);
}
});
it('recognizes supported files', () => {
// set up: id is supported but not known
for (const id of ['foo.cjs', 'foo.js', 'foo.mjs'] as const) {
expect(!isKnownFile(id));
expect(isSupportedFile(id));
expect(isKnownFile(id)).toBe(false);
expect(isSupportedFile(id)).toBe(true);

expect(getEditorTitle(id)).toBe(id);
}
Expand Down
1 change: 0 additions & 1 deletion tools/webpack/common/webpack.plugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import { ProvidePlugin } from 'webpack';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

export const plugins = [
Expand Down
Loading