Skip to content

Commit

Permalink
chore(deps-dev): prettier@3.0.0
Browse files Browse the repository at this point in the history
- reformat entire codebase using new defaults
- adjust code matcher to be async
- regenerate lock file
  • Loading branch information
AviVahl committed Jul 6, 2023
1 parent 9042c89 commit 8a7efb1
Show file tree
Hide file tree
Showing 18 changed files with 135 additions and 135 deletions.
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"memfs": "^4.2.0",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/esm/src/create-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export type ModuleFormat = 'builtin' | 'commonjs' | 'json' | 'module' | 'wasm';
export type ResolveHook = (
specifier: string,
context: { parentURL?: string; conditions: string[] },
defaultResolve: ResolveHook
defaultResolve: ResolveHook,
) => { url: string; format?: ModuleFormat };

/** @url https://nodejs.org/docs/latest-v16.x/api/esm.html#loadurl-context-defaultload */
export type LoadHook = (
url: string,
context: { format?: ModuleFormat },
defaultTransformSource: LoadHook
defaultTransformSource: LoadHook,
) => { source: string | SharedArrayBuffer | Uint8Array; format: ModuleFormat; shortCircuit?: boolean };

export interface CreateLoaderOptions {
Expand All @@ -37,7 +37,7 @@ export function createLoader({ compilerOptions, cwd }: CreateLoaderOptions) {
const moduleResolutionCache = ts.createModuleResolutionCache(
cwd,
ts.sys.useCaseSensitiveFileNames ? (s) => s : (s) => s.toLowerCase(),
compilerOptions
compilerOptions,
);
const resolve: ResolveHook = (specifier, context, defaultResolve) => {
const { parentURL } = context;
Expand All @@ -47,7 +47,7 @@ export function createLoader({ compilerOptions, cwd }: CreateLoaderOptions) {
fileURLToPath(parentURL),
compilerOptions,
ts.sys,
moduleResolutionCache
moduleResolutionCache,
);

if (resolvedModule && !definitionExtensions.has(resolvedModule.extension)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/esm/src/load-tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function loadTsconfig(tsconfigPath: string): ts.CompilerOptions {
const { options } = ts.parseJsonSourceFileConfigFileContent(
ts.readJsonConfigFile(tsconfigPath, ts.sys.readFile),
ts.sys,
dirname(tsconfigPath)
dirname(tsconfigPath),
);
if (options.module === undefined || options.module < ts.ModuleKind.ES2015) {
options.module = ts.ModuleKind.Node16;
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/node-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export function createNodeExtension({
// couldn't find a cache directory, so fall back to a non-caching implementation
return createTransformerExtension(
(filePath) =>
ts.transpileModule(readFileSync(filePath, 'utf8'), { fileName: filePath, compilerOptions }).outputText
ts.transpileModule(readFileSync(filePath, 'utf8'), { fileName: filePath, compilerOptions }).outputText,
);
}

Expand Down Expand Up @@ -175,7 +175,7 @@ export function createNodeExtension({
cacheDirectoryPath: optionsScopedCachePath,
fileName: filePath,
compilerOptions,
}).outputText
}).outputText,
);
}

Expand Down
18 changes: 9 additions & 9 deletions packages/robotrix/src/cjs-to-esm-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ICjsToEsmTransformerOptions {
* with a unique identifier.
*/
export function createCjsToEsmTransformer(
options: ICjsToEsmTransformerOptions = {}
options: ICjsToEsmTransformerOptions = {},
): ts.TransformerFactory<ts.SourceFile> {
return (context) =>
(sourceFile: ts.SourceFile): ts.SourceFile =>
Expand All @@ -39,7 +39,7 @@ export function createCjsToEsmTransformer(
function transformSourceFile(
sourceFile: ts.SourceFile,
context: ts.TransformationContext,
{ shouldTransform = () => true }: ICjsToEsmTransformerOptions
{ shouldTransform = () => true }: ICjsToEsmTransformerOptions,
): ts.SourceFile {
if (sourceFile.statements.some((node) => ts.isImportDeclaration(node) || ts.isExportDeclaration(node))) {
// file has esm, so avoid cjs conversion.
Expand Down Expand Up @@ -88,8 +88,8 @@ function transformSourceFile(
factory.createImportDeclaration(
undefined /* modifiers */,
factory.createImportClause(false, importIdentifier, undefined /* namedBindings */),
node.arguments[0]!
)
node.arguments[0]!,
),
);

// replace require call with identifier
Expand All @@ -103,7 +103,7 @@ function transformSourceFile(
// export default module.exports
function createCjsExportDefault(factory: ts.NodeFactory) {
return factory.createExportDefault(
factory.createPropertyAccessExpression(factory.createIdentifier('module'), 'exports')
factory.createPropertyAccessExpression(factory.createIdentifier('module'), 'exports'),
);
}

Expand All @@ -130,17 +130,17 @@ function createCjsModuleDefinition(factory: ts.NodeFactory) {
'exports',
undefined /* exclamationToken */,
undefined /* type */,
factory.createObjectLiteralExpression()
factory.createObjectLiteralExpression(),
),
factory.createVariableDeclaration(
'module',
undefined /* exclamationToken */,
undefined /* type */,
factory.createObjectLiteralExpression([factory.createShorthandPropertyAssignment('exports')])
factory.createObjectLiteralExpression([factory.createShorthandPropertyAssignment('exports')]),
),
],
ts.NodeFlags.Let
)
ts.NodeFlags.Let,
),
);
}

Expand Down
18 changes: 9 additions & 9 deletions packages/robotrix/src/react-dev-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function reactDevTransformer(context: ts.TransformationContext): ts.Trans
// file-wide unique identifier that would point to the fileName string literal
const jsxFileNameIdentifier = factory.createUniqueName(
JSX_FILENAME,
ts.GeneratedIdentifierFlags.Optimistic | ts.GeneratedIdentifierFlags.FileLevel
ts.GeneratedIdentifierFlags.Optimistic | ts.GeneratedIdentifierFlags.FileLevel,
);

// fist run the visitor, so it will mark whether we need to add fileName const declaration
Expand Down Expand Up @@ -92,15 +92,15 @@ function findUserDefinedAttributes(node: ts.JsxAttributes) {
function createSelfAttribute(factory: ts.NodeFactory): ts.JsxAttribute {
return factory.createJsxAttribute(
factory.createIdentifier(SELF),
factory.createJsxExpression(undefined, factory.createThis())
factory.createJsxExpression(undefined, factory.createThis()),
);
}

// __source={ [location-object] }
function createSourceAttribute(locationObj: ts.ObjectLiteralExpression, factory: ts.NodeFactory): ts.JsxAttribute {
return factory.createJsxAttribute(
factory.createIdentifier(SOURCE),
factory.createJsxExpression(undefined, locationObj)
factory.createJsxExpression(undefined, locationObj),
);
}

Expand All @@ -109,7 +109,7 @@ function createLocationObject(jsxFileNameIdentifier: ts.Identifier, line: number
return factory.createObjectLiteralExpression([
factory.createPropertyAssignment(
'fileName',
jsxFileNameIdentifier // use the file-wide identifier for fileName value
jsxFileNameIdentifier, // use the file-wide identifier for fileName value
),
factory.createPropertyAssignment('lineNumber', factory.createNumericLiteral(String(line + 1))),
]);
Expand All @@ -120,32 +120,32 @@ function addFileNameConst(
sourceFile: ts.SourceFile,
jsxFileNameIdentifier: ts.Identifier,
fileName: string,
factory: ts.NodeFactory
factory: ts.NodeFactory,
): ts.SourceFile {
const variableDecls = [
factory.createVariableDeclaration(
jsxFileNameIdentifier,
undefined /* exclamationToken */,
undefined /* type */,
factory.createStringLiteral(fileName)
factory.createStringLiteral(fileName),
),
];

return insertStatementAfterImports(
sourceFile,
factory.createVariableStatement(
undefined /* modifiers */,
factory.createVariableDeclarationList(variableDecls, ts.NodeFlags.Const)
factory.createVariableDeclarationList(variableDecls, ts.NodeFlags.Const),
),
factory
factory,
);
}

// insert a new statement above the first non-import statement
function insertStatementAfterImports(
sourceFile: ts.SourceFile,
statement: ts.Statement,
factory: ts.NodeFactory
factory: ts.NodeFactory,
): ts.SourceFile {
const { statements } = sourceFile;

Expand Down
6 changes: 3 additions & 3 deletions packages/robotrix/src/remap-imports-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createRemapImportsTransformer({
export function remapSourceFileImports(
sourceFile: ts.SourceFile,
context: ts.TransformationContext,
remapTarget: IRemapImportsTransformerOptions['remapTarget']
remapTarget: IRemapImportsTransformerOptions['remapTarget'],
): ts.SourceFile {
const { factory } = context;
const { fileName } = sourceFile;
Expand All @@ -43,7 +43,7 @@ export function remapSourceFileImports(
ts.getModifiers(node),
node.importClause,
factory.createStringLiteral(remappedTarget),
node.assertClause
node.assertClause,
);
}
} else if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
Expand All @@ -56,7 +56,7 @@ export function remapSourceFileImports(
node.isTypeOnly,
node.exportClause,
factory.createStringLiteral(remappedTarget),
node.assertClause
node.assertClause,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/robotrix/src/resolved-modules-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function resolvedModulesTransformer(context: ts.TransformationContext): t
function remapImportsToResolvedModules(
request: string,
_containingFile: string,
{ resolvedModules }: ResolvedSourceFile
{ resolvedModules }: ResolvedSourceFile,
) {
if (!resolvedModules || request.startsWith('./') || request.startsWith('../')) {
// relative request or no typescript mapping.
Expand Down
Loading

0 comments on commit 8a7efb1

Please sign in to comment.