Skip to content

Commit

Permalink
Regenerate lockfile (#129)
Browse files Browse the repository at this point in the history
Lockfiles are great for keeping unexpected changes in dependencies from
breaking your app all of a sudden, but they also tend to cause
stagnation and duplicated packages (because packages that are added over
time use different versions of sub-dependencies). For that reason, it's
good to periodically trash the lockfile and re-generate it fresh, which
is what this PR does.

I had to tweak some code to make types happy, but our tests are still
passing so I think we're still all good.
  • Loading branch information
IanVS authored Oct 12, 2023
1 parent ac9af46 commit e09afef
Show file tree
Hide file tree
Showing 5 changed files with 314 additions and 357 deletions.
2 changes: 1 addition & 1 deletion src/preprocessors/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function preprocessor(code: string, options: PrettierOptions): string {
traverse(ast, {
ImportDeclaration(path: NodePath<ImportDeclaration>) {
const tsModuleParent = path.findParent((p) =>
isTSModuleDeclaration(p),
isTSModuleDeclaration(p.node),
);
if (!tsModuleParent) {
allOriginalImportNodes.push(path.node);
Expand Down
6 changes: 4 additions & 2 deletions src/utils/get-code-from-ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ export const getCodeFromAst = ({
start: 0,
end: 0,
loc: {
start: { line: 0, column: 0 },
end: { line: 0, column: 0 },
start: { line: 0, column: 0, index: 0 },
end: { line: 0, column: 0, index: 0 },
filename: '',
identifierName: '',
},
});

Expand Down
8 changes: 6 additions & 2 deletions src/utils/get-comment-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ export function attachCommentsToOutputNodes(
...firstImport.loc?.end,
line: firstImport.loc?.end.line + commentHeight,
},
filename: '',
identifierName: '',
};

const moveDist =
Expand Down Expand Up @@ -536,8 +538,10 @@ function ensureEmptyStatementAtFront(outputNodes: ImportOrLine[]) {
}
const dummy = emptyStatement();
dummy.loc = {
start: { line: 0, column: 0 },
end: { line: 0, column: 0 },
start: { line: 0, column: 0, index: 0 },
end: { line: 0, column: 0, index: 0 },
filename: '',
identifierName: '',
};
outputNodes.unshift(dummy);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/get-import-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const getImportNodes = (
traverse(ast, {
ImportDeclaration(path: NodePath<ImportDeclaration>) {
const tsModuleParent = path.findParent((p) =>
isTSModuleDeclaration(p),
isTSModuleDeclaration(p.node),
);
if (!tsModuleParent) {
importNodes.push(path.node);
Expand Down
Loading

0 comments on commit e09afef

Please sign in to comment.