Skip to content

Commit

Permalink
Fix ESLint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Sep 22, 2024
1 parent 415cee6 commit 61d68cf
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-namespace */
import crypto from 'node:crypto'
import path from 'node:path'
import chokidar, { type FSWatcher } from 'chokidar'
import { watch as chokidarWatch, type FSWatcher } from 'chokidar'
import { getPortPromise } from 'portfinder'
import WS, { type ServerOptions } from 'ws'
import { Converter, ConvertedCallback } from './converter'
Expand All @@ -22,8 +22,7 @@ export class Watcher {
this.finder = opts.finder
this.mode = opts.mode

this.chokidar = chokidar
.watch(watchPath, { ignoreInitial: true })
this.chokidar = chokidarWatch(watchPath, { ignoreInitial: true })
.on('change', (f) => this.convert(f))
.on('add', (f) => this.convert(f))
.on('unlink', (f) => this.delete(f))
Expand Down
4 changes: 2 additions & 2 deletions test/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { load } from 'cheerio'
import { imageSize } from 'image-size'
import { PDFDocument, PDFDict, PDFName, PDFHexString, PDFNumber } from 'pdf-lib'
import { TimeoutError } from 'puppeteer-core'
import yauzl from 'yauzl'
import { fromBuffer as yauzlFromBuffer } from 'yauzl'
import { Converter, ConvertType, ConverterOption } from '../src/converter'
import { CLIError } from '../src/error'
import { File, FileType } from '../src/file'
Expand Down Expand Up @@ -930,7 +930,7 @@ describe('Converter', () => {
const getPptxDocProps = async (buffer: Buffer) => {
// Require to ignore type definition by casting into any :(
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20497
const zip = await (promisify(yauzl.fromBuffer) as any)(buffer, {
const zip = await (promisify(yauzlFromBuffer) as any)(buffer, {
lazyEntries: true,
})

Expand Down
2 changes: 1 addition & 1 deletion test/engine.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Marp from '@marp-team/marp-core'
import { Marp } from '@marp-team/marp-core'
import { ResolvedEngine } from '../src/engine'

afterEach(() => jest.restoreAllMocks())
Expand Down
2 changes: 1 addition & 1 deletion test/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ClientRequest } from 'node:http'
import path from 'node:path'
import Marp from '@marp-team/marp-core'
import { Marp } from '@marp-team/marp-core'
import { load } from 'cheerio'
import express, { type Express } from 'express'
import request from 'supertest'
Expand Down
2 changes: 1 addition & 1 deletion test/templates/bespoke.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @jest-environment jsdom */
import '../_browser/matchMedia'
import Marp from '@marp-team/marp-core'
import { Marp } from '@marp-team/marp-core'
import { Element as MarpitElement } from '@marp-team/marpit'
import { Key } from 'ts-key-enum'
import bespoke from '../../src/templates/bespoke/bespoke'
Expand Down
10 changes: 4 additions & 6 deletions test/watcher.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import http from 'node:http'
import chokidar from 'chokidar'
// import * as portfinder from 'portfinder'
import { watch as chokidarWatch } from 'chokidar'
import { File, FileType } from '../src/file'
import { ThemeSet } from '../src/theme'
import { Watcher, WatchNotifier, notifier } from '../src/watcher'
Expand All @@ -15,13 +14,15 @@ jest.mock('chokidar', () => ({
}),
})),
}))

jest.mock('ws', () => ({
Server: jest.fn(() => ({
clients: [],
close: jest.fn((callback) => callback()),
on: mockWsOn,
})),
}))

jest.mock('../src/watcher')
jest.mock('../src/theme')

Expand Down Expand Up @@ -61,10 +62,7 @@ describe('Watcher', () => {
const watcher = createWatcher()

expect(watcher).toBeInstanceOf(Watcher)
expect(chokidar.watch).toHaveBeenCalledWith(
['test.md'],
expect.anything()
)
expect(chokidarWatch).toHaveBeenCalledWith(['test.md'], expect.anything())
expect(notifier.start).toHaveBeenCalled()

// Chokidar events
Expand Down

0 comments on commit 61d68cf

Please sign in to comment.