Skip to content

Commit 13ddd4a

Browse files
committed
细化 eslint 规则
1 parent dfc2a76 commit 13ddd4a

File tree

8 files changed

+24
-18
lines changed

8 files changed

+24
-18
lines changed

eslint.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ export default defineConfigWithVueTs(
2323

2424
{
2525
rules: {
26-
'vue/multi-word-component-names': 'off',
2726
'@typescript-eslint/no-unused-vars': [
2827
'warn',
2928
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
3029
],
31-
'@typescript-eslint/no-namespace': 'off',
3230
'@typescript-eslint/no-explicit-any': 'off',
31+
'vue/multi-word-component-names': 'off',
3332
'vue/no-mutating-props': 'off',
3433
'vue/require-v-for-key': 'off',
34+
eqeqeq: ['error', 'always'],
35+
},
36+
},
37+
{
38+
files: ['**/types.ts'],
39+
rules: {
40+
'@typescript-eslint/no-namespace': 'off',
3541
},
3642
},
3743
)

pipelines/prosoticDictGen/scripts/csv2dictJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// from SUBTLEXus_syllables-corrected.csv to SUBTLEXus_prosotic.dict.json
2-
import nlp from 'compromise/tokenize'
32
import nlpSpeech from 'compromise-speech'
3+
import nlp from 'compromise/tokenize'
44
import fs from 'fs'
55

66
const SRC = './pipelines/prosoticDictGen/SUBTLEXus_syllables-corrected.csv'

src/ui/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ watch(
7575
{ immediate: true },
7676
)
7777
78-
const modalDialogActivated = () => !!document.querySelector('.p-dialog-mask.p-overlay-mask')
78+
const modalDialogActivated = () => document.querySelector('.p-dialog-mask.p-overlay-mask') !== null
7979
const handleRootKeydown = (e: KeyboardEvent) => {
8080
const hotkey = parseKeyEvent(e)
8181
if (!hotkey) return

src/ui/components/CodeMirror.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function highlightCurrentLine() {
5555
}
5656
getDeco(view: EditorView) {
5757
const dropPos = view.state.field(dropCursorPos, false)
58-
const pos = dropPos != null ? dropPos : view.state.selection.main.head
58+
const pos = typeof dropPos === 'number' ? dropPos : view.state.selection.main.head
5959
const line = view.state.doc.lineAt(pos)
6060
currentLine.value = line.number
6161
return Decoration.set([
@@ -72,15 +72,15 @@ function highlightCurrentLine() {
7272
// so that fields can be tracked here
7373
const setDropCursorPos = StateEffect.define<number | null>({
7474
map(pos, mapping) {
75-
return pos == null ? null : mapping.mapPos(pos)
75+
return pos === null ? null : mapping.mapPos(pos)
7676
},
7777
})
7878
const dropCursorPos = StateField.define<number | null>({
7979
create() {
8080
return null
8181
},
8282
update(pos, tr) {
83-
if (pos != null) pos = tr.changes.mapPos(pos)
83+
if (pos !== null) pos = tr.changes.mapPos(pos)
8484
return tr.effects.reduce((pos, e) => (e.is(setDropCursorPos) ? e.value : pos), pos)
8585
},
8686
})
@@ -104,8 +104,8 @@ const drawDropCursor = ViewPlugin.fromClass(
104104
}
105105
update(update: ViewUpdate) {
106106
const cursorPos = update.state.field(dropCursorPos)
107-
if (cursorPos == null) {
108-
if (this.cursor != null) {
107+
if (cursorPos === null) {
108+
if (this.cursor !== null) {
109109
this.cursor?.remove()
110110
this.cursor = null
111111
}
@@ -115,7 +115,7 @@ const drawDropCursor = ViewPlugin.fromClass(
115115
this.cursor!.className = 'cm-dropCursor'
116116
}
117117
if (
118-
update.startState.field(dropCursorPos) != cursorPos ||
118+
update.startState.field(dropCursorPos) !== cursorPos ||
119119
update.docChanged ||
120120
update.geometryChanged
121121
)
@@ -125,7 +125,7 @@ const drawDropCursor = ViewPlugin.fromClass(
125125
readPos(): { left: number; top: number; height: number } | null {
126126
const { view } = this
127127
const pos = view.state.field(dropCursorPos)
128-
const rect = pos != null && view.coordsAtPos(pos)
128+
const rect = pos !== null && view.coordsAtPos(pos)
129129
if (!rect) return null
130130
const outer = view.scrollDOM.getBoundingClientRect()
131131
return {
@@ -150,7 +150,7 @@ const drawDropCursor = ViewPlugin.fromClass(
150150
if (this.cursor) this.cursor.remove()
151151
}
152152
setDropPos(pos: number | null) {
153-
if (this.view.state.field(dropCursorPos) != pos)
153+
if (this.view.state.field(dropCursorPos) !== pos)
154154
this.view.dispatch({ effects: setDropCursorPos.of(pos) })
155155
}
156156
},
@@ -161,7 +161,7 @@ const drawDropCursor = ViewPlugin.fromClass(
161161
},
162162
dragleave(event) {
163163
if (
164-
event.target == this.view.contentDOM ||
164+
event.target === this.view.contentDOM ||
165165
!this.view.contentDOM.contains(event.relatedTarget as HTMLElement)
166166
)
167167
this.setDropPos(null)
@@ -212,7 +212,7 @@ onMounted(() => {
212212
highlightCompartment.of([]),
213213
editableCompartment.of(EditorView.editable.of(!props.readonly)),
214214
...(props.extensions || []),
215-
].filter((e) => !!e),
215+
].filter((e) => e !== null),
216216
})
217217
})
218218
onUnmounted(() => {

src/ui/components/HotKeyPopup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="hotkey-popup">
3-
<div class="hotkey-popup-item" v-for="(item, index) in innerList">
3+
<div class="hotkey-popup-item" v-for="(_item, index) in innerList">
44
<HotKeyInput v-model="innerList[index]!" fluid />
55
<Button
66
icon="pi pi-times"

src/ui/components/LineOrderInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const listItems = ref<ListItem[]>(
6666
original,
6767
props.transEnabled ? translation : null,
6868
props.romanEnabled ? romanization : null,
69-
].filter((i) => !!i),
69+
].filter((i) => i !== null),
7070
)
7171
const originalOrder = computed<number | undefined>(() => {
7272
const index = listItems.value.findIndex((item) => item.key === original.key)

src/utils/alignLineSylTime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { LyricLine, LyricSyllable } from '@core/types'
22

33
const isSyllableTimed = (syl: LyricSyllable) =>
4-
!!((syl.startTime || syl.endTime) && syl.text.trim())
4+
Boolean((syl.startTime || syl.endTime) && syl.text.trim())
55

66
/** Set line's startTime as the startTime of its first syllable */
77
export function alignLineStartTime(line: LyricLine) {

src/utils/tryRaf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @param maxAttempts - The maximum number of attempts to execute the callback.
77
* @param enableLog - If true, logs each attempt to the console.
88
*/
9-
export function tryRaf(callback: () => any, maxAttempts: number = 20, enableLog = false): void {
9+
export function tryRaf(callback: () => unknown, maxAttempts: number = 20, enableLog = false): void {
1010
let attempts = 0
1111
function attempt() {
1212
if (attempts >= maxAttempts) {

0 commit comments

Comments
 (0)