Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 22, 2024
1 parent 6c16f67 commit 05dc3f2
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions external/builder/babel-plugin-pdfjs-preprocessor.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { types as t, transformSync } from "@babel/core";
import fs from "fs";
import path from "path";
import { join as joinPaths } from "path";
import vm from "vm";

const ROOT_PREFIX = "$ROOT/";
Expand All @@ -17,9 +17,9 @@ function evalWithDefines(code, defines) {
return vm.runInNewContext(code, defines, { displayErrors: false });
}

function handlePreprocessorAction(ctx, actionName, args, nodePath) {
function handlePreprocessorAction(ctx, actionName, args, path) {
try {
let arg = args[0];
const arg = args[0];
switch (actionName) {
case "test":
if (!t.isStringLiteral(arg)) {
Expand All @@ -46,7 +46,7 @@ function handlePreprocessorAction(ctx, actionName, args, nodePath) {
}
let jsonPath = arg.value;
if (jsonPath.indexOf(ROOT_PREFIX) === 0) {
jsonPath = path.join(
jsonPath = joinPaths(
ctx.rootPath,
jsonPath.substring(ROOT_PREFIX.length)
);
Expand All @@ -55,7 +55,7 @@ function handlePreprocessorAction(ctx, actionName, args, nodePath) {
}
throw new Error("Unsupported action");
} catch (e) {
throw nodePath.buildCodeFrameError(
throw path.buildCodeFrameError(
"Could not process " +
PDFJS_PREPROCESSOR_NAME +
"." +
Expand All @@ -74,11 +74,7 @@ function babelPluginPDFJSPreprocessor(babel, ctx) {
},
visitor: {
"ExportNamedDeclaration|ImportDeclaration": ({ node }) => {
if (
node.source &&
ctx.map &&
ctx.map[node.source.value]
) {
if (node.source && ctx.map && ctx.map[node.source.value]) {
const newValue = ctx.map[node.source.value];
node.source.value = newValue;
}
Expand Down

0 comments on commit 05dc3f2

Please sign in to comment.