Skip to content

Commit

Permalink
Reconfigure linting on the entire project (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianruesch authored Jan 27, 2024
1 parent bf37ec6 commit 2998b3f
Show file tree
Hide file tree
Showing 206 changed files with 5,713 additions and 5,424 deletions.
21 changes: 18 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ module.exports = {
overrides: [
{
extends: [
"eslint:recommended",
"airbnb",
"airbnb-typescript",
"plugin:react/jsx-runtime",
"prettier",
],
files: ["*.ts", "*.tsx"],
rules: {
Expand All @@ -36,9 +36,24 @@ module.exports = {
"off",
{ packageDir: ["project-canvas/electron/main"] },
],
"@typescript-eslint/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "comma",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
},
}],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/quotes": "off",
"object-curly-newline": ["error", { multiline: true, consistent: true }],
'import-newlines/enforce': ['error', { items: 40, 'max-len': 120 }],
quotes: ["error", "double"],
"max-len": "off",
},
},
],
plugins: ["react", "testing-library"],
}
plugins: ["react", "@typescript-eslint", "testing-library", "import-newlines"],
};
19 changes: 0 additions & 19 deletions .github/workflows/static_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,6 @@ jobs:
- name: Run lint check
run: yarn lint

formatting:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: "yarn"

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run formatting check
run: yarn format

typecheck:
name: Type Check
runs-on: ubuntu-latest
Expand Down
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
9 changes: 0 additions & 9 deletions .lintstagedrc

This file was deleted.

3 changes: 3 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"*.{js,jsx,ts,tsx}": ["eslint --fix --max-warnings=3", "git add ."]
}
7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

31 changes: 13 additions & 18 deletions e2e/example.spec.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import {
ElectronApplication,
_electron as electron,
expect,
test,
} from "@playwright/test"
import { ElectronApplication, _electron as electron, expect, test } from "@playwright/test";

import { findLatestBuild, parseElectronApp } from "electron-playwright-helpers"
import { findLatestBuild, parseElectronApp } from "electron-playwright-helpers";

let electronApp: ElectronApplication
let electronApp: ElectronApplication;

test.beforeAll(async () => {
const latestBuild = findLatestBuild()
const appInfo = parseElectronApp(latestBuild)
const latestBuild = findLatestBuild();
const appInfo = parseElectronApp(latestBuild);
electronApp = await electron.launch({
args: [appInfo.main],
executablePath: appInfo.executable,
})
})
});
});

test.afterAll(async () => {
await electronApp.close()
})
await electronApp.close();
});

test("homepage has title and links to intro page", async () => {
const page = await electronApp.firstWindow()
await page.screenshot({ path: "e2e/screenshots/example.png" })
expect(await page.title()).toBe("Project Canvas")
})
const page = await electronApp.firstWindow();
await page.screenshot({ path: "e2e/screenshots/example.png" });
expect(await page.title()).toBe("Project Canvas");
});
42 changes: 21 additions & 21 deletions electron/OAuthHelper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { BrowserWindow } from "electron"
import { BrowserWindow } from "electron";

export function handleOAuth2(win: BrowserWindow) {
const authWindow = new BrowserWindow({
width: 800,
height: 600,
show: false,
})
const CLIENT_ID = import.meta.env.VITE_CLIENT_ID
});
const CLIENT_ID = import.meta.env.VITE_CLIENT_ID;
// join scopes with space (in url encoding)
const SCOPE = [
"read:me",
Expand All @@ -33,46 +33,46 @@ export function handleOAuth2(win: BrowserWindow) {
"read:jql:jira",
"offline_access",
"offline_access",
].join("%20")
const REDIRECT_URI = import.meta.env.VITE_REDIRECT_URI
const AUDIENCE = "api.atlassian.com"
].join("%20");
const REDIRECT_URI = import.meta.env.VITE_REDIRECT_URI;
const AUDIENCE = "api.atlassian.com";

const authUrl = `https://auth.atlassian.com/authorize?audience=${AUDIENCE}&client_id=${CLIENT_ID}&scope=${SCOPE}&redirect_uri=${REDIRECT_URI}&response_type=code&prompt=consent`
const authUrl = `https://auth.atlassian.com/authorize?audience=${AUDIENCE}&client_id=${CLIENT_ID}&scope=${SCOPE}&redirect_uri=${REDIRECT_URI}&response_type=code&prompt=consent`;

authWindow.loadURL(authUrl)
authWindow.show()
authWindow.loadURL(authUrl);
authWindow.show();

authWindow.webContents.on("will-redirect", (_, url) => {
if (url.startsWith(REDIRECT_URI)) {
if (
// handle cancel button press event on the authWindow
url.includes(
"error=access_denied&error_description=User%20did%20not%20authorize%20the%20request"
"error=access_denied&error_description=User%20did%20not%20authorize%20the%20request",
)
) {
authWindow.destroy()
win.webContents.send("cancelOAuth")
authWindow.destroy();
win.webContents.send("cancelOAuth");
} else {
const code = handleCallback(url, authWindow)
const code = handleCallback(url, authWindow);
// Send OAuth code back to renderer process
win.webContents.send("code", code)
win.webContents.send("code", code);
}
}
})
});
}

function handleCallback(url: string, authWindow: BrowserWindow) {
const rawCode = /\?code=(.+)/.exec(url) || null
const code = rawCode && rawCode.length > 1 ? rawCode[1] : null
const error = /\?error=(.+)\$/.exec(url)
const rawCode = /\?code=(.+)/.exec(url) || null;
const code = rawCode && rawCode.length > 1 ? rawCode[1] : null;
const error = /\?error=(.+)\$/.exec(url);

if (code || error) {
authWindow.destroy()
authWindow.destroy();
}

if (code) {
return code
return code;
}

return error
return error;
}
58 changes: 31 additions & 27 deletions electron/export-issues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,37 @@ import fs from "fs";
import * as Electron from "electron";

export const enum ExportStatus {
SUCCESS = 'success',
CANCELED = 'canceled',
ERROR = 'error',
SUCCESS = "success",
CANCELED = "canceled",
ERROR = "error",
}

export type ExportReply = { status: ExportStatus, error?: string }
export type ExportReply = { status: ExportStatus, error?: string };

export const getExportIssuesHandler =
(electron: typeof Electron, mainWindow: Electron.BrowserWindow) =>
(event: Electron.IpcMainEvent, data: string) => {
electron.dialog.showSaveDialog(mainWindow!, {
title: "Export issues to CSV",
defaultPath: electron.app.getPath("downloads"),
filters: [{ name: 'CSV file', extensions: ['csv'] }],
properties: []
})
.then(file=> {
if (file.canceled) {
event.reply("exportIssuesReply", { status: ExportStatus.CANCELED });
} else {
fs.writeFile(
file.filePath?.toString() ?? electron.app.getPath('downloads'),
data,
(err) => { if(err) throw err; },
)
event.reply("exportIssuesReply", { status: ExportStatus.SUCCESS });
}
})
.catch((e) => event.reply("exportIssuesReply", { status: ExportStatus.ERROR, error: e.toString }));
}
export const getExportIssuesHandler = (electron: typeof Electron, mainWindow: Electron.BrowserWindow) => (event: Electron.IpcMainEvent, data: string) => {
electron.dialog
.showSaveDialog(mainWindow!, {
title: "Export issues to CSV",
defaultPath: electron.app.getPath("downloads"),
filters: [{ name: "CSV file", extensions: ["csv"] }],
properties: [],
})
.then((file) => {
if (file.canceled) {
event.reply("exportIssuesReply", { status: ExportStatus.CANCELED });
} else {
fs.writeFile(
file.filePath?.toString() ?? electron.app.getPath("downloads"),
data,
(err) => {
if (err) throw err;
},
);
event.reply("exportIssuesReply", { status: ExportStatus.SUCCESS });
}
})
.catch((e) => event.reply("exportIssuesReply", {
status: ExportStatus.ERROR,
error: e.toString,
}));
};
Loading

0 comments on commit 2998b3f

Please sign in to comment.