Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Oct 6, 2022
1 parent 80068ef commit dd1ac81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/loader/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)
}
)
}
Expand Down
8 changes: 2 additions & 6 deletions packages/loader/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {<Message />'
)
await fs.writeFile(new URL('webpack.mdx', base), '# Hello, {<Message />')

// Errors.
const failedResult = await promisify(webpack)({
Expand All @@ -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):
Expand Down Expand Up @@ -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.
Expand Down

1 comment on commit dd1ac81

@vercel
Copy link

@vercel vercel bot commented on dd1ac81 Oct 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mdx – ./

mdx-git-main-mdx.vercel.app
mdxjs.com
mdx-mdx.vercel.app
v2.mdxjs.com

Please sign in to comment.