Skip to content

Commit

Permalink
style: format with prettier v3
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 3, 2023
1 parent 09c1e7d commit fe61c6e
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export default function transform(opts: TransformOptions): TRANSFORM_RESULT {
// `unshift` because these plugin must come before `@babel/plugin-syntax-class-properties`
_opts.plugins.unshift(
[require("babel-plugin-transform-typescript-metadata")],
[require("@babel/plugin-proposal-decorators"), { legacy: true }]
[require("@babel/plugin-proposal-decorators"), { legacy: true }],
);
_opts.plugins.push(require("babel-plugin-parameter-decorator"));
_opts.plugins.push(require("@babel/plugin-syntax-import-assertions"));
}

if (opts.legacy) {
_opts.plugins.push(
require("@babel/plugin-proposal-nullish-coalescing-operator")
require("@babel/plugin-proposal-nullish-coalescing-operator"),
);
_opts.plugins.push(require("@babel/plugin-proposal-optional-chaining"));
}
Expand Down
20 changes: 10 additions & 10 deletions src/jiti.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function createJITI(
_filename: string,
opts: JITIOptions = {},
parentModule?: Module,
parentCache?: ModuleCache
parentCache?: ModuleCache,
): JITI {
opts = { ...defaults, ...opts };

Expand All @@ -100,12 +100,12 @@ export default function createJITI(
const isNativeRe = new RegExp(
`node_modules/(${nativeModules
.map((m) => escapeStringRegexp(m))
.join("|")})/`
.join("|")})/`,
);
const isTransformRe = new RegExp(
`node_modules/(${transformModules
.map((m) => escapeStringRegexp(m))
.join("|")})/`
.join("|")})/`,
);

function debug(...args: string[]) {
Expand Down Expand Up @@ -141,7 +141,7 @@ export default function createJITI(
const nativeRequire = createRequire(
isWindows
? _filename.replace(/\//g, "\\") // Import maps does not work with normalized paths!
: _filename
: _filename,
);

const tryResolve = (id: string, options?: { paths?: string[] }) => {
Expand All @@ -152,7 +152,7 @@ export default function createJITI(

const _url = pathToFileURL(_filename);
const _additionalExts = [...(opts.extensions as string[])].filter(
(ext) => ext !== ".js"
(ext) => ext !== ".js",
);
const _resolve = (id: string, options?: { paths?: string[] }) => {
let resolved, err;
Expand Down Expand Up @@ -211,7 +211,7 @@ export default function createJITI(
function getCache(
filename: string | undefined,
source: string,
get: () => string
get: () => string,
): string {
if (!opts.cache || !filename) {
return get();
Expand All @@ -224,7 +224,7 @@ export default function createJITI(
const filebase = basename(dirname(filename)) + "-" + basename(filename);
const cacheFile = join(
opts.cache as string,
filebase + "." + md5(filename) + ".js"
filebase + "." + md5(filename) + ".js",
);

if (existsSync(cacheFile)) {
Expand Down Expand Up @@ -362,7 +362,7 @@ export default function createJITI(
debug(
`[transpile]${isNativeModule ? " [esm]" : ""}`,
filename,
`(${time}ms)`
`(${time}ms)`,
);
} else {
try {
Expand Down Expand Up @@ -426,7 +426,7 @@ export default function createJITI(
mod.require,
mod,
mod.filename,
dirname(mod.filename)
dirname(mod.filename),
);
} catch (error: any) {
if (opts.requireCache) {
Expand Down Expand Up @@ -459,7 +459,7 @@ export default function createJITI(
return addHook(
(source: string, filename: string) =>
jiti.transform({ source, filename, ts: !!/\.[cm]?ts$/.test(filename) }),
{ exts: opts.extensions }
{ exts: opts.extensions },
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/babel-plugin-transform-import-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Statement, MemberExpression } from "@babel/types";
// Modification: Inlines resolved filename into the code when possible instead of injecting a require
export function TransformImportMetaPlugin(
_ctx: any,
opts: { filename?: string }
opts: { filename?: string },
) {
return <PluginObj>{
name: "transform-import-meta",
Expand Down Expand Up @@ -41,7 +41,7 @@ export function TransformImportMetaPlugin(
opts.filename
? JSON.stringify(pathToFileURL(opts.filename))
: "require('url').pathToFileURL(__filename).toString()"
}` as Statement
}` as Statement,
);
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/import-meta-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const accessor = `process.env`;

const replaceEnvForRuntime = (
template: typeof BabelCore.template,
property: string
property: string,
) => template.expression.ast(`${accessor}.${property}`);

export function importMetaEnvPlugin({ template, types }: any) {
Expand Down Expand Up @@ -97,7 +97,7 @@ export function importMetaEnvPlugin({ template, types }: any) {

path.parentPath.replaceWith(
// @ts-ignore
replaceEnvForRuntime(template, path.parentPath.node.property.name)
replaceEnvForRuntime(template, path.parentPath.node.property.name),
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/typescript/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function anotherDecorator() {
return function (object: any, propertyName: any) {
console.log(
"Decorator metadata keys: " +
Reflect.getMetadataKeys(object, propertyName)
Reflect.getMetadataKeys(object, propertyName),
);
};
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/typescript/satisfies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const normalizeUserEntity = (({ name, avatar }: User) =>
width: 100,
height: 100,
},
} satisfies NormalizedUser)) satisfies UserNormalizer;
}) satisfies NormalizedUser) satisfies UserNormalizer;

export const test = () => {
return {
Expand Down

0 comments on commit fe61c6e

Please sign in to comment.