chore: upgrade eslint and prettier (#2376)

* chore: upgrade eslint and prettier

* chore: add restrict-template-expressions
This commit is contained in:
Mo
2023-07-27 14:36:05 -05:00
committed by GitHub
parent acc41edb02
commit 4a29e2a24c
1283 changed files with 4416 additions and 5131 deletions

View File

@@ -1,4 +1,5 @@
dist/
app/dist/
test/data/tmp/
CHANGELOG.md
CHANGELOG.md
app/grantLinuxPasswordsAccess.html

View File

@@ -1,95 +1,97 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Standard Notes</title>
<link rel="stylesheet" media="all" href="web/app.css" />
<link rel="stylesheet" media="all" href="stylesheets/renderer.css" />
</head>
<body class="main-ui">
<div class="sk-modal">
<div class="challenge-modal sk-modal-content" style="margin: 2rem">
<div class="sn-component">
<div class="sk-panel">
<div class="sk-panel-header">
<div class="sk-panel-header-title capitalize">Password service access</div>
</div>
<div class="sk-panel-content" style="padding-bottom: 2rem">
<h1 class="sk-h1">Choose how you want Standard Notes to store your account keys</h1>
<p class="sk-p">
Standard Notes can either use your operating system's password manager or its own local storage
facility.
</p>
<p class="sk-p">
<strong>Standard Notes currently does not have access to your system password service.</strong>
If you grant it access, you must quit the app for the change to come into effect.
</p>
<div class="sk-panel-row">
<div class="sk-button-group">
<button class="sk-button info" id="quit-button">
<div class="sk-label capitalize">Use password service (quit)</div>
</button>
<button class="sk-button neutral capitalize" id="use-storage-button">
<div class="sk-label">Use local storage (continue)</div>
</button>
</div>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Standard Notes</title>
<link rel="stylesheet" media="all" href="web/app.css" />
<link rel="stylesheet" media="all" href="stylesheets/renderer.css" />
</head>
<body class="main-ui">
<div class="sk-modal">
<div class="challenge-modal sk-modal-content" style="margin: 2rem">
<div class="sn-component">
<div class="sk-panel">
<div class="sk-panel-header">
<div class="sk-panel-header-title capitalize">Password service access</div>
</div>
<div class="sk-panel-content" style="padding-bottom: 2rem">
<h1 class="sk-h1">Choose how you want Standard Notes to store your account keys</h1>
<p class="sk-p">
Standard Notes can either use your operating system's password manager or its own local storage
facility.
</p>
<p class="sk-p">
<strong>Standard Notes currently does not have access to your system password service.</strong>
If you grant it access, you must quit the app for the change to come into effect.
</p>
<div class="sk-panel-row">
<div class="sk-button-group">
<button class="sk-button info" id="quit-button">
<div class="sk-label capitalize">Use password service (quit)</div>
</button>
<button class="sk-button neutral capitalize" id="use-storage-button">
<div class="sk-label">Use local storage (continue)</div>
</button>
</div>
<div class="sk-panel-row"></div>
<a class="sk-a capitalize" id="learn-more">Learn more</a>
<div style="display: none" id="more-info">
<div class="sk-panel-section">
<h1 class="sk-h1">What's the difference?</h1>
<p class="sk-p">
Using local storage, your account keys may be more easily accessible by third-party programs, unlike
in your password manager which has additional protections built-in.
</p>
<p class="sk-p">
In either cases, the strongest way to protect your account keys is to use a strong passcode, which
will be used to encrypt your keys and prevent any software or operating system from reading them.
<strong> If you plan on setting a passcode, you can safely use local storage. </strong>
</p>
<div class="sk-panel-row"></div>
<h2 class="sk-h2">Granting Standard Notes access to your system password service</h2>
<p class="sk-p">
Note that
<strong>
granting access to your system password service will allow Standard Notes to read, write, and
delete <em>any</em> of your saved passwords.
</strong>
Standard Notes will never use this privilege to do anything more than reading and writing to its own
entry.
</p>
<ol>
<li class="sk-li">Quit Standard Notes</li>
<li class="sk-li">Open your software store (Ubuntu Software Center/Snap Store)</li>
<li class="sk-li">In your installed apps list, click on Standard Notes</li>
<li class="sk-li">Look for a <em>Permissions</em> button</li>
<li class="sk-li">
Make sure the permission associated with reading and writing passwords is checked
</li>
<li class="sk-li">Open Standard Notes again</li>
</ol>
<h2 class="sk-h2">
Granting Standard Notes access to your system password service from the command line
</h2>
<p class="sk-p">
Run the following command:<br />
<code>snap connect standard-notes:password-manager-service</code>
</p>
</div>
<p>
<em>
Note: Password Service may also be referred to as keyring, saved passwords, stored passwords,
password manager, passwords, or secrets, depending on your Linux configuration.
</em>
</div>
<div class="sk-panel-row"></div>
<a class="sk-a capitalize" id="learn-more">Learn more</a>
<div style="display: none" id="more-info">
<div class="sk-panel-section">
<h1 class="sk-h1">What's the difference?</h1>
<p class="sk-p">
Using local storage, your account keys may be more easily accessible by third-party programs, unlike
in your password manager which has additional protections built-in.
</p>
<p class="sk-p">
In either cases, the strongest way to protect your account keys is to use a strong passcode, which
will be used to encrypt your keys and prevent any software or operating system from reading them.
<strong> If you plan on setting a passcode, you can safely use local storage. </strong>
</p>
<div class="sk-panel-row"></div>
<h2 class="sk-h2">Granting Standard Notes access to your system password service</h2>
<p class="sk-p">
Note that
<strong>
granting access to your system password service will allow Standard Notes to read, write, and
delete <em>any</em> of your saved passwords.
</strong>
Standard Notes will never use this privilege to do anything more than reading and writing to its own
entry.
</p>
<ol>
<li class="sk-li">Quit Standard Notes</li>
<li class="sk-li">Open your software store (Ubuntu Software Center/Snap Store)</li>
<li class="sk-li">In your installed apps list, click on Standard Notes</li>
<li class="sk-li">Look for a <em>Permissions</em> button</li>
<li class="sk-li">
Make sure the permission associated with reading and writing passwords is checked
</li>
<li class="sk-li">Open Standard Notes again</li>
</ol>
<h2 class="sk-h2">
Granting Standard Notes access to your system password service from the command line
</h2>
<p class="sk-p">
Run the following command:<br />
<code>snap connect standard-notes:password-manager-service</code>
</p>
</div>
<p>
<em>
Note: Password Service may also be referred to as keyring, saved passwords, stored passwords,
password manager, passwords, or secrets, depending on your Linux configuration.
</em>
</p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</div>
</body>
</html>

View File

@@ -72,6 +72,7 @@ export class FilesManager implements FilesManagerInterface {
if (!stat.isDirectory()) {
throw new Error('Tried to create a directory where a file of the same ' + `name already exists: ${dirPath}`)
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (error.code === FileErrorCodes.FileDoesNotExist) {
/**
@@ -83,6 +84,7 @@ export class FilesManager implements FilesManagerInterface {
/** Now that its parent(s) exist, create the directory */
try {
await fs.promises.mkdir(dirPath)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (error.code === FileErrorCodes.FileAlreadyExists) {
/**
@@ -257,6 +259,7 @@ export class FilesManager implements FilesManagerInterface {
try {
await this.ensureDirectoryExists(path.dirname(filepath))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
return tryReject(error)
}
@@ -299,6 +302,7 @@ export class FilesManager implements FilesManagerInterface {
try {
await fs.promises.unlink(filePath)
break
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
if (error.code === FileErrorCodes.OperationNotPermitted || error.code === FileErrorCodes.DeviceIsBusy) {
await new Promise((resolve) => setTimeout(resolve, 300))

View File

@@ -4,7 +4,12 @@ import { downloadData } from './FileNetworking'
export class FileDownloader {
writeStream: WriteStream
constructor(private chunkSizes: number[], private valetToken: string, private url: string, filePath: string) {
constructor(
private chunkSizes: number[],
private valetToken: string,
private url: string,
filePath: string,
) {
this.writeStream = createWriteStream(filePath, { flags: 'a' })
}

View File

@@ -33,7 +33,10 @@ export class HomeServerManager implements HomeServerManagerInterface {
private homeServer?: TempHomeServerInterface
constructor(private webContents: WebContents, private filesManager: FilesManagerInterface) {}
constructor(
private webContents: WebContents,
private filesManager: FilesManagerInterface,
) {}
async getHomeServerUrl(): Promise<string | undefined> {
const homeServerConfiguration = await this.getHomeServerConfigurationObject()

View File

@@ -17,9 +17,7 @@ import { TrayManager } from '../TrayManager'
import { autoUpdatingAvailable } from '../Types/Constants'
import { isLinux, isMac } from '../Types/Platforms'
import { checkForUpdate, openChangelog, showUpdateInstallationDialog } from '../UpdateManager'
import { handleTestMessage } from '../Utils/Testing'
import { isDev, isTesting } from '../Utils/Utils'
import { MessageType } from './../../../../test/TestIpcMessage'
import { isDev } from '../Utils/Utils'
import { SpellcheckerManager } from './../SpellcheckerManager'
import { MenuManagerInterface } from './MenuManagerInterface'
@@ -123,42 +121,7 @@ export function createMenuManager({
}): MenuManagerInterface {
let menu: Menu
if (isTesting()) {
// eslint-disable-next-line no-var
var hasReloaded = false
// eslint-disable-next-line no-var
var hasReloadedTimeout: any
handleTestMessage(MessageType.AppMenuItems, () =>
menu.items.map((item) => ({
label: item.label,
role: item.role,
submenu: {
items: item.submenu?.items?.map((subItem) => ({
id: subItem.id,
label: subItem.label,
})),
},
})),
)
handleTestMessage(MessageType.ClickLanguage, (code) => {
menu.getMenuItemById(MessageType.ClickLanguage + code)!.click()
})
handleTestMessage(MessageType.HasReloadedMenu, () => hasReloaded)
}
function reload() {
if (isTesting()) {
// eslint-disable-next-line block-scoped-var
hasReloaded = true
// eslint-disable-next-line block-scoped-var
clearTimeout(hasReloadedTimeout)
// eslint-disable-next-line block-scoped-var
hasReloadedTimeout = setTimeout(() => {
// eslint-disable-next-line block-scoped-var
hasReloaded = false
}, 300)
}
menu = Menu.buildFromTemplate([
...(isMac() ? [macAppMenu(app.name)] : []),
editMenu(spellcheckerManager, reload),
@@ -270,7 +233,10 @@ function macAppMenu(appName: string): MenuItemConstructorOptions {
}
}
function editMenu(spellcheckerManager: SpellcheckerManager | undefined, reload: () => any): MenuItemConstructorOptions {
function editMenu(
spellcheckerManager: SpellcheckerManager | undefined,
reload: () => void,
): MenuItemConstructorOptions {
if (isDev()) {
/** Check for invalid state */
if (!isMac() && spellcheckerManager === undefined) {
@@ -323,13 +289,13 @@ function macSpeechMenu(): MenuItemConstructorOptions {
}
}
function spellcheckerMenu(spellcheckerManager: SpellcheckerManager, reload: () => any): MenuItemConstructorOptions {
function spellcheckerMenu(spellcheckerManager: SpellcheckerManager, reload: () => void): MenuItemConstructorOptions {
return {
id: MenuId.SpellcheckerLanguages,
label: str().spellcheckerLanguages,
submenu: spellcheckerManager.languages().map(
({ name, code, enabled }): MenuItemConstructorOptions => ({
...(isTesting() ? { id: MessageType.ClickLanguage + code } : {}),
...{},
label: name,
type: MenuItemTypes.CheckBox,
checked: enabled,
@@ -346,7 +312,7 @@ function spellcheckerMenu(spellcheckerManager: SpellcheckerManager, reload: () =
}
}
function viewMenu(window: Electron.BrowserWindow, store: Store, reload: () => any): MenuItemConstructorOptions {
function viewMenu(window: Electron.BrowserWindow, store: Store, reload: () => void): MenuItemConstructorOptions {
return {
label: str().view,
submenu: [
@@ -375,7 +341,7 @@ function viewMenu(window: Electron.BrowserWindow, store: Store, reload: () => an
}
}
function menuBarOptions(window: Electron.BrowserWindow, store: Store, reload: () => any) {
function menuBarOptions(window: Electron.BrowserWindow, store: Store, reload: () => void) {
const useSystemMenuBar = store.get(StoreKeys.UseSystemMenuBar)
let isMenuBarVisible = store.get(StoreKeys.MenuBarVisible)
window.setMenuBarVisibility(isMenuBarVisible)
@@ -406,7 +372,7 @@ function menuBarOptions(window: Electron.BrowserWindow, store: Store, reload: ()
]
}
function windowMenu(store: Store, trayManager: TrayManager, reload: () => any): MenuItemConstructorOptions {
function windowMenu(store: Store, trayManager: TrayManager, reload: () => void): MenuItemConstructorOptions {
return {
role: Roles.Window,
submenu: [
@@ -446,7 +412,7 @@ function macWindowItems(): MenuItemConstructorOptions[] {
]
}
function minimizeToTrayItem(store: Store, trayManager: TrayManager, reload: () => any) {
function minimizeToTrayItem(store: Store, trayManager: TrayManager, reload: () => void) {
const minimizeToTray = trayManager.shouldMinimizeToTray()
return {
label: str().minimizeToTrayOnClose,

View File

@@ -48,7 +48,10 @@ class MappingFileHandler {
return new MappingFileHandler(mapping, filesManager)
}
constructor(private mapping: MappingFile, private filesManager: FilesManagerInterface) {}
constructor(
private mapping: MappingFile,
private filesManager: FilesManagerInterface,
) {}
get = (componendId: string) => {
return this.mapping[componendId]

View File

@@ -5,6 +5,7 @@ import { StoreData, StoreKeys } from './StoreKeys'
import { logError } from './Store'
import { FileErrorCodes } from '../File/FileErrorCodes'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function createSanitizedStoreData(data: any = {}): StoreData {
return {
[StoreKeys.MenuBarVisible]: ensureIsBoolean(data[StoreKeys.MenuBarVisible], true),
@@ -27,6 +28,8 @@ export function createSanitizedStoreData(data: any = {}): StoreData {
[StoreKeys.LegacyFileBackupsLocation]: data[StoreKeys.LegacyFileBackupsLocation],
}
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function sanitizeZoomFactor(factor?: any): number {
if (typeof factor === 'number' && factor > 0) {
return factor
@@ -67,7 +70,9 @@ export function parseDataFile(filePath: string) {
const fileData = fs.readFileSync(filePath)
const userData = JSON.parse(fileData.toString())
return createSanitizedStoreData(userData)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
// eslint-disable-next-line no-console
console.log('Error reading store file', error)
if (error.code !== FileErrorCodes.FileDoesNotExist) {
logError(error)

View File

@@ -65,7 +65,7 @@
"electron-builder": "23.6.0",
"electron-notarize": "^1.2.1",
"eslint": "*",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^8.9.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
@@ -79,7 +79,7 @@
"ts-node": "^10.9.1",
"typescript": "*",
"webpack": "*",
"webpack-merge": "^5.8.0"
"webpack-merge": "*"
},
"build": {
"appId": "org.standardnotes.standardnotes",