Skip to content

Commit c0a7c37

Browse files
committed
update eslint
1 parent ac051f7 commit c0a7c37

23 files changed

+381
-440
lines changed

.eslintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 17 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { FlatCompat } from '@eslint/eslintrc'
2+
import js from '@eslint/js'
3+
import eslintPluginReact from 'eslint-plugin-react'
4+
5+
const compat = new FlatCompat()
6+
7+
export default [
8+
{
9+
ignores: ['**/{node_modules,dist,out,.gitignore}/**']
10+
},
11+
js.configs.recommended,
12+
...compat.extends(
13+
'@electron-toolkit/eslint-config-ts/recommended',
14+
'@electron-toolkit/eslint-config-prettier'
15+
),
16+
{
17+
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
18+
plugins: {
19+
...eslintPluginReact.configs.flat.recommended,
20+
...eslintPluginReact.configs.flat['jsx-runtime']
21+
},
22+
rules: {
23+
'@typescript-eslint/no-unused-vars': [
24+
'error',
25+
{
26+
args: 'all',
27+
argsIgnorePattern: '^_',
28+
caughtErrors: 'all',
29+
caughtErrorsIgnorePattern: '^_',
30+
destructuredArrayIgnorePattern: '^_',
31+
varsIgnorePattern: '^_',
32+
ignoreRestSiblings: true
33+
}
34+
]
35+
}
36+
},
37+
{
38+
files: ['src/renderer/src/**/*.{ts,tsx}'],
39+
rules: {
40+
'@typescript-eslint/explicit-function-return-type': 'off',
41+
'react/prop-types': 'off'
42+
}
43+
}
44+
// extends: [
45+
// 'eslint:recommended',
46+
// 'plugin:react/recommended',
47+
// 'plugin:react/jsx-runtime',
48+
// '@electron-toolkit/eslint-config-ts/recommended',
49+
// '@electron-toolkit/eslint-config-prettier'
50+
// ],
51+
// overrides: [
52+
// {
53+
// files: ['src/renderer/src/components/**/*.ts'],
54+
// rules: {
55+
// 'react/prop-types': 'off'
56+
// }
57+
// }
58+
// ]
59+
]

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"homepage": "https://github.com/kaishuu0123/leavepad",
1010
"scripts": {
1111
"format": "prettier --write .",
12-
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
12+
"lint": "eslint . --fix",
1313
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
1414
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
1515
"typecheck": "npm run typecheck:node && npm run typecheck:web",
@@ -70,7 +70,7 @@
7070
"electron": "^31.0.2",
7171
"electron-builder": "^24.13.3",
7272
"electron-vite": "^2.3.0",
73-
"eslint": "^8.57.0",
73+
"eslint": "^9.14.0",
7474
"eslint-plugin-react": "^7.34.3",
7575
"lucide-react": "^0.452.0",
7676
"postcss": "^8.4.47",

src/main/db_singleton.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ class DbSingleton {
4040
}
4141
}
4242

43-
static getInstance() {
43+
static getInstance(): DbSingleton {
4444
if (!DbSingleton.instance) {
4545
DbSingleton.instance = new DbSingleton()
4646
// ... any one time initialization goes here ...
4747
}
4848
return DbSingleton.instance
4949
}
5050

51-
public async initDbs() {
51+
public async initDbs(): Promise<void> {
5252
await this.dbs.notesDb.read()
5353
await this.dbs.settingsDb.read()
5454
await this.dbs.appStateDb.read()

src/main/ipcHandles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { uuidv7 } from 'uuidv7'
44
import { AppState, Note, NoteEditorSettings } from '../types'
55
import { dbInstance } from './db_singleton'
66

7-
export const registerIpcHandles = (ipcMain) => {
7+
export const registerIpcHandles = (ipcMain): void => {
88
const { notesDb, settingsDb, appStateDb } = dbInstance.dbs
99

1010
ipcMain.handle('get-notes', (): Note[] => {

src/preload/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ import { AppState, Note, NoteEditorSettings } from '../types'
44

55
// Custom APIs for renderer
66
const api = {
7-
getNotes: () => {
7+
getNotes: (): Promise<Note[]> => {
88
return ipcRenderer.invoke('get-notes')
99
},
10-
getNote: (noteId: string) => {
10+
getNote: (noteId: string): Promise<Note> => {
1111
return ipcRenderer.invoke('get-note', noteId)
1212
},
13-
createNote: async () => {
13+
createNote: async (): Promise<Note> => {
1414
const note = await ipcRenderer.invoke('create-note')
1515
return note
1616
},
17-
updateNote: (willUpdateNote: Note) => {
17+
updateNote: (willUpdateNote: Note): Promise<Note> => {
1818
return ipcRenderer.invoke('update-note', willUpdateNote)
1919
},
20-
deleteNote: (noteId: string) => {
20+
deleteNote: (noteId: string): Promise<void> => {
2121
return ipcRenderer.invoke('delete-note', noteId)
2222
},
23-
updateSettings: (settings: NoteEditorSettings) => {
24-
ipcRenderer.invoke('update-settings', settings)
23+
updateSettings: (settings: NoteEditorSettings): Promise<void> => {
24+
return ipcRenderer.invoke('update-settings', settings)
2525
},
26-
getSettings: () => {
26+
getSettings: (): Promise<NoteEditorSettings> => {
2727
return ipcRenderer.invoke('get-settings')
2828
},
29-
getAppState: () => {
29+
getAppState: (): Promise<AppState> => {
3030
return ipcRenderer.invoke('get-app-state')
3131
},
32-
updateAppState: (appState: AppState) => {
32+
updateAppState: (appState: AppState): Promise<void> => {
3333
return ipcRenderer.invoke('update-app-state', appState)
3434
}
3535
}

src/renderer/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ initializeNoteEditor()
5353

5454
function App(): JSX.Element {
5555
const { t } = useTranslation()
56-
// @ts-ignore
5756
const _ipcHandle = (): void => window.electron.ipcRenderer.send('ping')
5857
const editorRef = useRef<editor.IStandaloneCodeEditor | undefined>(undefined)
5958
const [notes, setNotes] = useAtom(notesAtom)

src/renderer/src/components/note-editor.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import jsonWorker from 'monaco-editor/esm/vs/language/json/json.worker?worker'
99
import cssWorker from 'monaco-editor/esm/vs/language/css/css.worker?worker'
1010
import htmlWorker from 'monaco-editor/esm/vs/language/html/html.worker?worker'
1111
import tsWorker from 'monaco-editor/esm/vs/language/typescript/ts.worker?worker'
12-
import { ForwardedRef, forwardRef, useEffect } from 'react'
12+
import { ForwardedRef, forwardRef } from 'react'
1313

1414
export function initializeNoteEditor() {
1515
self.MonacoEnvironment = {
@@ -74,10 +74,9 @@ function NoteEditor(
7474
monaco.editor.remeasureFonts()
7575
})
7676

77-
// for DEBUG
78-
// @ts-ignore
77+
// @ts-ignore for DEBUG
7978
window.editor = monacoEditor
80-
// @ts-ignore
79+
// @ts-ignore for DEBUG
8180
window.monaco = monaco
8281
}
8382
}
Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as React from "react"
2-
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
1+
import * as React from 'react'
2+
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
33

4-
import { cn } from "@renderer/lib/utils"
5-
import { buttonVariants } from "@renderer/components/ui/button"
4+
import { cn } from '@renderer/lib/utils'
5+
import { buttonVariants } from '@renderer/components/ui/button'
66

77
const AlertDialog = AlertDialogPrimitive.Root
88

@@ -16,7 +16,7 @@ const AlertDialogOverlay = React.forwardRef<
1616
>(({ className, ...props }, ref) => (
1717
<AlertDialogPrimitive.Overlay
1818
className={cn(
19-
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
19+
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
2020
className
2121
)}
2222
{...props}
@@ -34,7 +34,7 @@ const AlertDialogContent = React.forwardRef<
3434
<AlertDialogPrimitive.Content
3535
ref={ref}
3636
className={cn(
37-
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
37+
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
3838
className
3939
)}
4040
{...props}
@@ -43,41 +43,26 @@ const AlertDialogContent = React.forwardRef<
4343
))
4444
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
4545

46-
const AlertDialogHeader = ({
47-
className,
48-
...props
49-
}: React.HTMLAttributes<HTMLDivElement>) => (
50-
<div
51-
className={cn(
52-
"flex flex-col space-y-2 text-center sm:text-left",
53-
className
54-
)}
55-
{...props}
56-
/>
46+
const AlertDialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
47+
<div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
5748
)
58-
AlertDialogHeader.displayName = "AlertDialogHeader"
49+
AlertDialogHeader.displayName = 'AlertDialogHeader'
5950

60-
const AlertDialogFooter = ({
61-
className,
62-
...props
63-
}: React.HTMLAttributes<HTMLDivElement>) => (
51+
const AlertDialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
6452
<div
65-
className={cn(
66-
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
67-
className
68-
)}
53+
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)}
6954
{...props}
7055
/>
7156
)
72-
AlertDialogFooter.displayName = "AlertDialogFooter"
57+
AlertDialogFooter.displayName = 'AlertDialogFooter'
7358

7459
const AlertDialogTitle = React.forwardRef<
7560
React.ElementRef<typeof AlertDialogPrimitive.Title>,
7661
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
7762
>(({ className, ...props }, ref) => (
7863
<AlertDialogPrimitive.Title
7964
ref={ref}
80-
className={cn("text-lg font-semibold", className)}
65+
className={cn('text-lg font-semibold', className)}
8166
{...props}
8267
/>
8368
))
@@ -89,22 +74,17 @@ const AlertDialogDescription = React.forwardRef<
8974
>(({ className, ...props }, ref) => (
9075
<AlertDialogPrimitive.Description
9176
ref={ref}
92-
className={cn("text-sm text-muted-foreground", className)}
77+
className={cn('text-sm text-muted-foreground', className)}
9378
{...props}
9479
/>
9580
))
96-
AlertDialogDescription.displayName =
97-
AlertDialogPrimitive.Description.displayName
81+
AlertDialogDescription.displayName = AlertDialogPrimitive.Description.displayName
9882

9983
const AlertDialogAction = React.forwardRef<
10084
React.ElementRef<typeof AlertDialogPrimitive.Action>,
10185
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
10286
>(({ className, ...props }, ref) => (
103-
<AlertDialogPrimitive.Action
104-
ref={ref}
105-
className={cn(buttonVariants(), className)}
106-
{...props}
107-
/>
87+
<AlertDialogPrimitive.Action ref={ref} className={cn(buttonVariants(), className)} {...props} />
10888
))
10989
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
11090

@@ -114,11 +94,7 @@ const AlertDialogCancel = React.forwardRef<
11494
>(({ className, ...props }, ref) => (
11595
<AlertDialogPrimitive.Cancel
11696
ref={ref}
117-
className={cn(
118-
buttonVariants({ variant: "outline" }),
119-
"mt-2 sm:mt-0",
120-
className
121-
)}
97+
className={cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className)}
12298
{...props}
12399
/>
124100
))
@@ -135,5 +111,5 @@ export {
135111
AlertDialogTitle,
136112
AlertDialogDescription,
137113
AlertDialogAction,
138-
AlertDialogCancel,
114+
AlertDialogCancel
139115
}

0 commit comments

Comments
 (0)