Skip to content

Commit 5af312b

Browse files
committed
chore: increase prettier print width to 100
1 parent 5f1df79 commit 5af312b

File tree

94 files changed

+159
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+159
-630
lines changed

Diff for: .prettierrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"useTabs": true
2+
"useTabs": true,
3+
"printWidth": 100
34
}

Diff for: src/ambient-modules-declarations.test.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import dedent from "ts-dedent";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83
import { expect, test } from "vitest";
94
import { ambientModulesDeclarations } from "./ambient-modules-declarations";
105

@@ -63,9 +58,7 @@ test("ambient module from another package", () => {
6358
declare module "foo";
6459
`,
6560
);
66-
expect(ambientModulesDeclarations("", project, "my-package")).toStrictEqual(
67-
[],
68-
);
61+
expect(ambientModulesDeclarations("", project, "my-package")).toStrictEqual([]);
6962
});
7063

7164
test("shorthand ambient module", () => {

Diff for: src/apparent-type.test.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import dedent from "ts-dedent";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83
import { expect, test } from "vitest";
94
import { apparentType } from "./apparent-type";
105

@@ -24,7 +19,5 @@ test("apparent type", () => {
2419
const foo = 42;
2520
`,
2621
);
27-
expect(apparentType(indexFile.getVariableDeclarationOrThrow("foo"))).toBe(
28-
"number",
29-
);
22+
expect(apparentType(indexFile.getVariableDeclarationOrThrow("foo"))).toBe("number");
3023
});

Diff for: src/apparent-type.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ export const apparentType = (node: Node): string =>
99
.getApparentType()
1010
.getText(
1111
node,
12-
ts.TypeFormatFlags.NoTruncation |
13-
TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,
12+
ts.TypeFormatFlags.NoTruncation | TypeFormatFlags.UseAliasDefinedOutsideCurrentScope,
1413
)
1514
.replace(/^Number$/, "number")
1615
.replace(/^Boolean$/, "boolean")

Diff for: src/create-project.test.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { temporaryDirectoryTask } from "tempy";
55
import { expect, test } from "vitest";
66
import { createProject, type CreateProjectOptions } from "./create-project";
77

8-
const _createProject = (options: CreateProjectOptions) =>
9-
Effect.runPromise(createProject(options));
8+
const _createProject = (options: CreateProjectOptions) => Effect.runPromise(createProject(options));
109

1110
test("no cwd", async () => {
1211
await temporaryDirectoryTask(async (dir) => {
@@ -35,9 +34,7 @@ test("with index file", async () => {
3534
const indexFilePath = join(dir, "./index.ts");
3635
await fs.writeFile(indexFilePath, "export {};");
3736
const { project } = await _createProject({ indexFilePath, cwd: dir });
38-
expect(
39-
project.getSourceFiles().map((sf) => sf.getBaseName()),
40-
).toStrictEqual(["index.ts"]);
37+
expect(project.getSourceFiles().map((sf) => sf.getBaseName())).toStrictEqual(["index.ts"]);
4138
});
4239
});
4340

@@ -48,8 +45,9 @@ test("with index file and other file", async () => {
4845
await fs.writeFile(indexFilePath, "export * from './other';");
4946
await fs.writeFile(otherFilePath, "export const a = 1;");
5047
const { project } = await _createProject({ indexFilePath, cwd: dir });
51-
expect(
52-
project.getSourceFiles().map((sf) => sf.getBaseName()),
53-
).toStrictEqual(["index.ts", "other.ts"]);
48+
expect(project.getSourceFiles().map((sf) => sf.getBaseName())).toStrictEqual([
49+
"index.ts",
50+
"other.ts",
51+
]);
5452
});
5553
});

Diff for: src/create-project.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { Data, Effect } from "effect";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83

94
export type CreateProjectOptions = {
105
indexFilePath: string;

Diff for: src/docs.test.ts

+8-23
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import dedent from "ts-dedent";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83
import { expect, test } from "vitest";
94
import { docs } from "./docs";
105

@@ -56,36 +51,26 @@ test("docs", () => {
5651
export type Qux = {};
5752
`,
5853
);
59-
expect(docs(indexFile.getVariableDeclarationOrThrow("foo"))).toStrictEqual(
60-
[],
61-
);
54+
expect(docs(indexFile.getVariableDeclarationOrThrow("foo"))).toStrictEqual([]);
6255
expect(docs(indexFile.getVariableDeclarationOrThrow("bar"))).toStrictEqual([
6356
"/** Docs for bar */",
6457
]);
65-
expect(
66-
docs(indexFile.getExportedDeclarations().get("default")?.at(0)!),
67-
).toStrictEqual(["/** Docs for expression */"]);
58+
expect(docs(indexFile.getExportedDeclarations().get("default")?.at(0)!)).toStrictEqual([
59+
"/** Docs for expression */",
60+
]);
6861
expect(docs(indexFile.getFunctionOrThrow("fooFunc"))).toStrictEqual([
6962
"/** Docs for function overloads 1 */",
7063
"/** Docs for function overloads 2 */",
7164
]);
72-
expect(
73-
docs(indexFile.getClassOrThrow("FooClass").getMethodOrThrow("fooMethod")),
74-
).toStrictEqual([
65+
expect(docs(indexFile.getClassOrThrow("FooClass").getMethodOrThrow("fooMethod"))).toStrictEqual([
7566
"/** Docs for class method overloads 1 */",
7667
"/** Docs for class method overloads 2 */",
7768
]);
7869
expect(
79-
docs(
80-
indexFile
81-
.getInterfaceOrThrow("FooInterface")
82-
.getMethodOrThrow("fooMethod"),
83-
),
70+
docs(indexFile.getInterfaceOrThrow("FooInterface").getMethodOrThrow("fooMethod")),
8471
).toStrictEqual([
8572
"/** Docs for interface method overloads 1 */",
8673
"/** Docs for interface method overloads 2 */",
8774
]);
88-
expect(docs(indexFile.getTypeAliasOrThrow("Qux"))).toStrictEqual([
89-
"/** Docs for Qux */",
90-
]);
75+
expect(docs(indexFile.getTypeAliasOrThrow("Qux"))).toStrictEqual(["/** Docs for Qux */"]);
9176
});

Diff for: src/docs.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ const nodesWithDocs = (node: Node): Node[] => {
2222
// Constructors can also be overloaded but they are excluded because
2323
// one item is returned per constructor each with its own docs.
2424
const implementation = node.getImplementation();
25-
return [
26-
...node.getOverloads(),
27-
...(implementation ? [implementation] : []),
28-
];
25+
return [...node.getOverloads(), ...(implementation ? [implementation] : [])];
2926
}
3027
if (
3128
Node.isMethodSignature(node) &&

Diff for: src/export-equals-declarations.test.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import dedent from "ts-dedent";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83
import { expect, test } from "vitest";
94
import { exportEqualsDeclarations } from "./export-equals-declarations";
105

@@ -24,9 +19,7 @@ test("shorthand ambient module", () => {
2419
declare module 'foo';
2520
`,
2621
);
27-
expect(
28-
exportEqualsDeclarations("", indexFile.getModuleOrThrow("'foo'")),
29-
).toStrictEqual([]);
22+
expect(exportEqualsDeclarations("", indexFile.getModuleOrThrow("'foo'"))).toStrictEqual([]);
3023
});
3124

3225
test("export default", () => {

Diff for: src/export-equals-declarations.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
ModuleDeclaration,
3-
SourceFile,
4-
SyntaxKind,
5-
type ExportedDeclarations,
6-
} from "ts-morph";
1+
import { ModuleDeclaration, SourceFile, SyntaxKind, type ExportedDeclarations } from "ts-morph";
72
import { isExportedDeclarations } from "./is-exported-declarations";
83
import { isHidden } from "./is-hidden";
94
import { isNamespace } from "./is-namespace";

Diff for: src/exported-declarations.test.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import dedent from "ts-dedent";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83
import { expect, test } from "vitest";
94
import { exportedDeclarations } from "./exported-declarations";
105

Diff for: src/exported-declarations.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import type {
2-
ExportedDeclarations,
3-
ModuleDeclaration,
4-
SourceFile,
5-
} from "ts-morph";
1+
import type { ExportedDeclarations, ModuleDeclaration, SourceFile } from "ts-morph";
62
import { isExportedDeclarations } from "./is-exported-declarations";
73
import { isHidden } from "./is-hidden";
84

@@ -17,10 +13,7 @@ export const exportedDeclarations = (
1713
container: SourceFile | ModuleDeclaration,
1814
): ExportedDeclarationsReturn => {
1915
const exportedDeclarations = [];
20-
for (const [
21-
exportName,
22-
declarations,
23-
] of container.getExportedDeclarations()) {
16+
for (const [exportName, declarations] of container.getExportedDeclarations()) {
2417
for (const declaration of declarations) {
2518
if (isHidden(declaration) || !isExportedDeclarations(declaration)) {
2619
continue;

Diff for: src/extract-class.ts

+5-16
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ export const extractClass = async (
8181
};
8282
};
8383

84-
const classSignature = async (
85-
declaration: ClassDeclaration,
86-
): Promise<string> => {
84+
const classSignature = async (declaration: ClassDeclaration): Promise<string> => {
8785
const signature = headText(declaration);
8886
return formatSignature("class", signature);
8987
};
@@ -123,9 +121,7 @@ const extractClassConstructors = async (
123121
return constructors;
124122
};
125123

126-
const classConstructorSignature = async (
127-
declaration: ConstructorDeclaration,
128-
): Promise<string> => {
124+
const classConstructorSignature = async (declaration: ConstructorDeclaration): Promise<string> => {
129125
const modifiers = modifiersText(declaration);
130126
const params = declaration
131127
.getParameters()
@@ -179,25 +175,18 @@ const extractClassProperties = async (
179175

180176
const classPropertySignature = async (
181177
name: string,
182-
declaration:
183-
| ParameterDeclaration
184-
| PropertyDeclaration
185-
| GetAccessorDeclaration,
178+
declaration: ParameterDeclaration | PropertyDeclaration | GetAccessorDeclaration,
186179
): Promise<string> => {
187180
const type = apparentType(declaration);
188-
if (
189-
Node.isParameterDeclaration(declaration) ||
190-
Node.isPropertyDeclaration(declaration)
191-
) {
181+
if (Node.isParameterDeclaration(declaration) || Node.isPropertyDeclaration(declaration)) {
192182
const modifiers = modifiersText(declaration);
193183
const optional = declaration.hasQuestionToken() ? "?" : "";
194184
const signature = `${modifiers} ${name}${optional}: ${type}`;
195185
return formatSignature("class-property", signature);
196186
}
197187
// GetAccessorDeclaration.
198188
const staticKeyword = declaration.isStatic() ? "static" : "";
199-
const readonlyKeyword =
200-
declaration.getSetAccessor() === undefined ? "readonly" : "";
189+
const readonlyKeyword = declaration.getSetAccessor() === undefined ? "readonly" : "";
201190
const signature = `${staticKeyword} ${readonlyKeyword} ${name}: ${type}`;
202191
return formatSignature("class-property", signature);
203192
};

Diff for: src/extract-declarations.test.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import dedent from "ts-dedent";
2-
import {
3-
ModuleKind,
4-
ModuleResolutionKind,
5-
Project,
6-
ScriptTarget,
7-
} from "ts-morph";
2+
import { ModuleKind, ModuleResolutionKind, Project, ScriptTarget } from "ts-morph";
83
import { expect, test } from "vitest";
94
import { extractDeclarations } from "./extract-declarations";
105

Diff for: src/extract-declarations.ts

+6-27
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import { extractFunction, type ExtractedFunction } from "./extract-function";
1717
import { extractFunctionExpression } from "./extract-function-expression";
1818
import { extractInterface, type ExtractedInterface } from "./extract-interface";
1919
import { extractNamespace, type ExtractedNamespace } from "./extract-namespace";
20-
import {
21-
extractTypeAlias,
22-
type ExtractedTypeAlias,
23-
} from "./extract-type-alias";
20+
import { extractTypeAlias, type ExtractedTypeAlias } from "./extract-type-alias";
2421
import { extractVariable, type ExtractedVariable } from "./extract-variable";
2522
import { extractVariableAssignmentExpression } from "./extract-variable-assignment-expression";
2623
import { globalAmbientDeclarations } from "./global-ambient-declarations";
@@ -104,12 +101,8 @@ export const extractDeclarations = async ({
104101
const foundDeclarations = [
105102
...exportedDeclarations(containerName, container),
106103
...exportEqualsDeclarations(containerName, container),
107-
...(project
108-
? ambientModulesDeclarations(containerName, project, pkgName)
109-
: []),
110-
...(Node.isSourceFile(container)
111-
? globalAmbientDeclarations(containerName, container)
112-
: []),
104+
...(project ? ambientModulesDeclarations(containerName, project, pkgName) : []),
105+
...(Node.isSourceFile(container) ? globalAmbientDeclarations(containerName, container) : []),
113106
];
114107
const seenFunctions = new Set<string>();
115108
const seenNamespaces = new Set<string>();
@@ -152,11 +145,7 @@ const extractDeclaration = async ({
152145
return extractVariable(containerName, exportName, declaration);
153146
}
154147
if (isVariableAssignmentExpression(declaration)) {
155-
return extractVariableAssignmentExpression(
156-
containerName,
157-
exportName,
158-
declaration,
159-
);
148+
return extractVariableAssignmentExpression(containerName, exportName, declaration);
160149
}
161150
if (isExpression(declaration)) {
162151
return extractExpression(containerName, exportName, declaration);
@@ -197,12 +186,7 @@ const extractDeclaration = async ({
197186
container: declaration,
198187
maxDepth: maxDepth - 1,
199188
});
200-
return extractNamespace(
201-
containerName,
202-
exportName,
203-
declaration,
204-
innerDeclarations,
205-
);
189+
return extractNamespace(containerName, exportName, declaration, innerDeclarations);
206190
}
207191
if (isFileModule(declaration) && maxDepth > 0) {
208192
// A file module declaration happens with the following export forms:
@@ -213,12 +197,7 @@ const extractDeclaration = async ({
213197
container: declaration,
214198
maxDepth: maxDepth - 1,
215199
});
216-
return extractFileModule(
217-
containerName,
218-
exportName,
219-
declaration,
220-
innerDeclarations,
221-
);
200+
return extractFileModule(containerName, exportName, declaration, innerDeclarations);
222201
}
223202
return undefined;
224203
};

Diff for: src/extract-enum.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ const extractEnumMembers = async (
7373
return members;
7474
};
7575

76-
const enumMemberSignature = async (
77-
declaration: EnumMember,
78-
): Promise<string> => {
76+
const enumMemberSignature = async (declaration: EnumMember): Promise<string> => {
7977
const signature = declaration.getText();
8078
return formatSignature("enum-member", signature);
8179
};

Diff for: src/extract-expression.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ export const extractExpression = async (
2020
signature: await expressionSignature(exportName, declaration),
2121
});
2222

23-
const expressionSignature = async (
24-
name: string,
25-
declaration: Expression,
26-
): Promise<string> => {
23+
const expressionSignature = async (name: string, declaration: Expression): Promise<string> => {
2724
const kind = "const";
2825
const type = apparentType(declaration);
2926
return formatSignature("variable", `${kind} ${name}: ${type}`);

0 commit comments

Comments
 (0)