From dd1ac81dde24e1b3983802f9805e36eb985560fb Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Thu, 6 Oct 2022 19:56:48 +0200 Subject: [PATCH] Refactor code-style --- packages/loader/lib/index.js | 10 +++++----- packages/loader/test/index.test.js | 8 ++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/loader/lib/index.js b/packages/loader/lib/index.js index 86bbb7a43..db1e3f1c2 100644 --- a/packages/loader/lib/index.js +++ b/packages/loader/lib/index.js @@ -11,7 +11,7 @@ */ import {createHash} from 'node:crypto' -import path from 'node:path'; +import path from 'node:path' import {SourceMapGenerator} from 'source-map' import {createFormatAwareProcessors} from '@mdx-js/mdx/lib/util/create-format-aware-processors.js' @@ -68,10 +68,10 @@ export function loader(value, callback) { (file) => { callback(null, file.value, file.map) }, - (/** @type VFileMessage */ e) => { - const fpath = path.relative(this.context, this.resourcePath); - e.message = `${fpath}:${e.name}: ${e.message}`; - callback(e); + (/** @type VFileMessage */ error) => { + const fpath = path.relative(this.context, this.resourcePath) + error.message = `${fpath}:${error.name}: ${error.message}` + callback(error) } ) } diff --git a/packages/loader/test/index.test.js b/packages/loader/test/index.test.js index a44b77b78..176201207 100644 --- a/packages/loader/test/index.test.js +++ b/packages/loader/test/index.test.js @@ -22,10 +22,7 @@ test('@mdx-js/loader', async () => { // Setup. const base = new URL('.', import.meta.url) - await fs.writeFile( - new URL('webpack.mdx', base), - '# Hello, {' - ) + await fs.writeFile(new URL('webpack.mdx', base), '# Hello, {') // Errors. const failedResult = await promisify(webpack)({ @@ -50,7 +47,7 @@ test('@mdx-js/loader', async () => { const error = failedResult?.toJson()?.errors?.[0] - assert.ok(error); + assert.ok(error) assert.equal( error.message, `Module build failed (from ../index.cjs): @@ -129,7 +126,6 @@ webpack.mdx:1:22: Unexpected end of file in expression, expected a corresponding assert.not.ok(preactBuild?.hasErrors()) - // One for ESM loading CJS, one for webpack. const modPreact = /** @type {{default: {default: PreactComponent}}} */ ( // @ts-expect-error file is dynamically generated.