diff --git a/src/CleanPlugin.ts b/src/CleanPlugin.ts index a0c222b..6f18d8d 100644 --- a/src/CleanPlugin.ts +++ b/src/CleanPlugin.ts @@ -1,5 +1,5 @@ import { deleteSync } from 'del'; -import type { BuildOptions, BuildResult } from 'esbuild'; +import { BuildOptions, BuildResult } from 'esbuild'; import path from 'node:path'; export type PluginOptions = { @@ -11,10 +11,7 @@ export type PluginOptions = { export class CleanPlugin { private previousAssets: string[] = []; - public constructor( - private pluginOptions: PluginOptions, - private buildOptions: BuildOptions, - ) { + public constructor(private pluginOptions: PluginOptions, private buildOptions: BuildOptions) { this.pluginOptions = { dry: false, initialCleanPatterns: ['**/*'], @@ -104,9 +101,7 @@ export class CleanPlugin { } if (!outdir) { - console.warn( - 'esbuild-clean-plugin: The esbuild "outdir" option was not set, please supply it. Stopping.', - ); + console.warn('esbuild-clean-plugin: The esbuild "outdir" option was not set, please supply it. Stopping.'); return false; } diff --git a/src/index.ts b/src/index.ts index f70ffc7..e0f81c6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import type { Plugin } from 'esbuild'; -import { CleanPlugin, type PluginOptions } from './CleanPlugin.js'; +import { Plugin } from 'esbuild'; +import { CleanPlugin, PluginOptions } from './CleanPlugin.js'; export { type PluginOptions } from './CleanPlugin.js'; diff --git a/test/index.ts b/test/index.ts index 45ced99..d9c46c2 100644 --- a/test/index.ts +++ b/test/index.ts @@ -1,9 +1,9 @@ import { jest } from '@jest/globals'; -import { build, type BuildOptions, type BuildResult } from 'esbuild'; +import { build, BuildOptions, BuildResult } from 'esbuild'; import fs from 'fs'; import path from 'path'; import { temporaryDirectory } from 'tempy'; -import { cleanPlugin, type PluginOptions } from '../src'; +import { cleanPlugin, PluginOptions } from '../src'; const filesExists = (filePath: string, fileNames: string[]): boolean => { return fileNames.every((fileName) => { @@ -19,10 +19,7 @@ const writeFile = (filePath: string, fileName: string, data = ''): void => { fs.writeFileSync(fileName, data); }; -const runBuild = ( - buildOptions: BuildOptions = {}, - pluginOptions?: PluginOptions, -): Promise => { +const runBuild = (buildOptions: BuildOptions = {}, pluginOptions?: PluginOptions): Promise => { return build({ metafile: true, plugins: [cleanPlugin(pluginOptions)], @@ -62,9 +59,7 @@ describe('esbuild-clean-plugin', () => { result.stop(); } - const fileName = path.basename( - Object.keys(result?.metafile?.outputs ?? [])[0] ?? '', - ); + const fileName = path.basename(Object.keys(result?.metafile?.outputs ?? [])[0] ?? ''); expect(filesExists(outDir, [fileName])).toBe(true); expect(filesExists(outDir, [initialFileName])).toBe(false); @@ -74,9 +69,7 @@ describe('esbuild-clean-plugin', () => { }, }) .then((buildResult) => { - initialFileName = path.basename( - Object.keys(buildResult.metafile?.outputs ?? [])[0] ?? '', - ); + initialFileName = path.basename(Object.keys(buildResult.metafile?.outputs ?? [])[0] ?? ''); writeFile(entryDir, 'a.js', 'const foo = true;'); }) @@ -123,9 +116,7 @@ describe('esbuild-clean-plugin', () => { }); test('Print stats in verbose mode', async () => { - const consoleSpy = jest - .spyOn(global.console, 'log') - .mockImplementation(jest.fn()); + const consoleSpy = jest.spyOn(global.console, 'log').mockImplementation(jest.fn()); await runBuild( { @@ -137,15 +128,11 @@ describe('esbuild-clean-plugin', () => { }, ); - expect(consoleSpy).toHaveBeenCalledWith( - expect.stringMatching('esbuild-clean-plugin: removed'), - ); + expect(consoleSpy).toHaveBeenCalledWith(expect.stringMatching('esbuild-clean-plugin: removed')); }); test("Stops if 'metafile' option isn't supplied", async () => { - const consoleSpy = jest - .spyOn(global.console, 'warn') - .mockImplementation(jest.fn()); + const consoleSpy = jest.spyOn(global.console, 'warn').mockImplementation(jest.fn()); await runBuild({ entryPoints: [path.resolve(entryDir, 'a.js')], @@ -162,9 +149,7 @@ describe('esbuild-clean-plugin', () => { }); test("Stops if 'outdir' option isn't supplied", async () => { - const consoleSpy = jest - .spyOn(global.console, 'warn') - .mockImplementation(jest.fn()); + const consoleSpy = jest.spyOn(global.console, 'warn').mockImplementation(jest.fn()); await runBuild({ entryPoints: [path.resolve(entryDir, 'a.js')],