Skip to content

Commit

Permalink
chore: eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Jan 15, 2024
1 parent 35f317c commit 27a888b
Show file tree
Hide file tree
Showing 29 changed files with 285 additions and 280 deletions.
180 changes: 91 additions & 89 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@
"devDependencies": {
"@schoero/configs": "^0.0.0-beta.26",
"@types/minimatch": "^5.1.2",
"@types/node": "^20.11.0",
"@types/node": "^20.11.2",
"changelogen": "^0.5.5",
"cspell": "^8.3.2",
"eslint-plugin-jsonc": "^2.11.2",
"eslint-plugin-jsonc": "^2.12.0",
"eslint-plugin-sort-exports": "^0.8.0",
"rollup-plugin-preserve-shebang": "^1.0.1",
"tinyhighlight": "^0.3.2",
"ts-json-schema-generator": "^1.5.0",
"vite": "^5.0.11",
"vite-plugin-dts": "^3.7.0",
"vite-plugin-dts": "^3.7.1",
"vite-plugin-no-bundle": "^3.0.0",
"vitest": "^1.2.0"
},
Expand Down
10 changes: 5 additions & 5 deletions src/interpreter/ast/entities/circular.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ scope("Interpreter", EntityKind.Circular, () => {
const exportedInterfaceA = createInterfaceEntity(ctx, exportedInterfaceASymbol);

it("should not create a circular entity if the target symbol is not circular", () => {
expect(exportedInterfaceA.properties[0]!.type.kind).toBe(TypeKind.TypeReference);
expect(exportedInterfaceA.properties[0].type.kind).toBe(TypeKind.TypeReference);
});

}
Expand All @@ -49,10 +49,10 @@ scope("Interpreter", EntityKind.Circular, () => {
const exportedInterfaceA = createInterfaceEntity(ctx, exportedInterfaceASymbol);

it("should create a circular entity if the target symbol is circular", () => {
assert(exportedInterfaceA.properties[0]!.type.kind === TypeKind.TypeReference);
assert(exportedInterfaceA.properties[0]!.type.type!.kind === TypeKind.Interface);
assert(exportedInterfaceA.properties[0]!.type.type.properties[0].type.kind === TypeKind.TypeReference);
expect(exportedInterfaceA.properties[0]!.type.type.properties[0]!.type.type!.kind).toBe(TypeKind.Circular);
assert(exportedInterfaceA.properties[0].type.kind === TypeKind.TypeReference);
assert(exportedInterfaceA.properties[0].type.type!.kind === TypeKind.Interface);
assert(exportedInterfaceA.properties[0].type.type.properties[0].type.kind === TypeKind.TypeReference);
expect(exportedInterfaceA.properties[0].type.type.properties[0].type.type!.kind).toBe(TypeKind.Circular);
});

}
Expand Down
2 changes: 1 addition & 1 deletion src/interpreter/ast/entities/class.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ scope("Interpreter", EntityKind.Class, () => {
});

it("should have a matching id", () => {
expect(exportedClass.symbolId).toBe(getSymbolId(ctx, exportedSymbols[0]!));
expect(exportedClass.symbolId).toBe(getSymbolId(ctx, exportedSymbols[0]));
});

it("should have a matching description", () => {
Expand Down
16 changes: 8 additions & 8 deletions src/interpreter/ast/entities/constructor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ scope("Interpreter", EntityKind.Getter, () => {


it("should have a matching description", () => {
expect(exportedClass.ctor!.signatures[0]!.description).toHaveLength(1);
assert(isJSDocText(exportedClass.ctor!.signatures[0]!.description![0]));
expect(exportedClass.ctor!.signatures[0]!.description![0].text).toBe("Constructor description");
expect(exportedClass.ctor!.signatures[0].description).toHaveLength(1);
assert(isJSDocText(exportedClass.ctor!.signatures[0].description![0]));
expect(exportedClass.ctor!.signatures[0].description![0].text).toBe("Constructor description");
});

it("should have a matching example", () => {
expect(exportedClass.ctor!.signatures[0]!.example).toHaveLength(1);
assert(isJSDocText(exportedClass.ctor!.signatures[0]!.example![0].content[0]));
expect(exportedClass.ctor!.signatures[0]!.example![0].content[0].text).toBe("Constructor example");
expect(exportedClass.ctor!.signatures[0].example).toHaveLength(1);
assert(isJSDocText(exportedClass.ctor!.signatures[0].example![0].content[0]));
expect(exportedClass.ctor!.signatures[0].example![0].content[0].text).toBe("Constructor example");
});

it("should return the instance type of the class", () => {
assert(isCircularType(exportedClass.ctor!.signatures[0]!.returnType));
expect(exportedClass.ctor!.signatures[0]!.returnType.typeId).toBe(exportedClass.typeId);
assert(isCircularType(exportedClass.ctor!.signatures[0].returnType));
expect(exportedClass.ctor!.signatures[0].returnType.typeId).toBe(exportedClass.typeId);
});

}
Expand Down
24 changes: 12 additions & 12 deletions src/interpreter/ast/entities/enum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ scope("Interpreter", EntityKind.Enum, () => {
});

it("should have a matching member types with values", () => {
expect(exportedEnum.members[0]!.name).toBe("A");
assert(exportedEnum.members[0]!.type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[0]!.type.value).toBe(0);
expect(exportedEnum.members[1]!.name).toBe("B");
assert(exportedEnum.members[1]!.type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[1]!.type.value).toBe(1);
expect(exportedEnum.members[0].name).toBe("A");
assert(exportedEnum.members[0].type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[0].type.value).toBe(0);
expect(exportedEnum.members[1].name).toBe("B");
assert(exportedEnum.members[1].type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[1].type.value).toBe(1);
});

}
Expand All @@ -133,12 +133,12 @@ scope("Interpreter", EntityKind.Enum, () => {

it("should be able to merge multiple enums with the same name", () => {
expect(exportedEnum.members).toHaveLength(2);
expect(exportedEnum.members[0]!.name).toBe("A");
assert(exportedEnum.members[0]!.type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[0]!.type.value).toBe(0);
expect(exportedEnum.members[1]!.name).toBe("B");
assert(exportedEnum.members[1]!.type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[1]!.type.value).toBe(1);
expect(exportedEnum.members[0].name).toBe("A");
assert(exportedEnum.members[0].type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[0].type.value).toBe(0);
expect(exportedEnum.members[1].name).toBe("B");
assert(exportedEnum.members[1].type.kind === TypeKind.NumberLiteral);
expect(exportedEnum.members[1].type.value).toBe(1);
});

}
Expand Down
18 changes: 9 additions & 9 deletions src/interpreter/ast/entities/getter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,27 @@ scope("Interpreter", EntityKind.Getter, () => {
});

it("should have a matching kind", () => {
expect(exportedClass.getters[0]!.kind).toBe(EntityKind.Getter);
expect(exportedClass.getters[0].kind).toBe(EntityKind.Getter);
});

it("should have a matching name", () => {
expect(exportedClass.getters[0]!.name).toBe("getter");
expect(exportedClass.getters[0].name).toBe("getter");
});

it("should have one signature", () => {
expect(exportedClass.getters[0]!.signatures).toHaveLength(1);
expect(exportedClass.getters[0].signatures).toHaveLength(1);
});

it("should have a matching description", () => {
expect(exportedClass.getters[0]!.signatures[0].description).toHaveLength(1);
assert(isJSDocText(exportedClass.getters[0]!.signatures[0].description![0]));
expect(exportedClass.getters[0]!.signatures[0].description![0].text).toBe("Getter description");
expect(exportedClass.getters[0].signatures[0].description).toHaveLength(1);
assert(isJSDocText(exportedClass.getters[0].signatures[0].description![0]));
expect(exportedClass.getters[0].signatures[0].description![0].text).toBe("Getter description");
});

it("should have a matching example", () => {
expect(exportedClass.getters[0]!.signatures[0].example).toHaveLength(1);
assert(isJSDocText(exportedClass.getters[0]!.signatures[0].example![0].content[0]));
expect(exportedClass.getters[0]!.signatures[0].example![0].content[0].text).toBe("Getter example");
expect(exportedClass.getters[0].signatures[0].example).toHaveLength(1);
assert(isJSDocText(exportedClass.getters[0].signatures[0].example![0].content[0]));
expect(exportedClass.getters[0].signatures[0].example![0].content[0].text).toBe("Getter example");
});

}
Expand Down
34 changes: 17 additions & 17 deletions src/interpreter/ast/entities/interface.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,23 @@ scope("Interpreter", EntityKind.Interface, () => {
it("should be able to parse inheritance", () => {

expect(exportedInterfaceB.properties).toHaveLength(1);
expect(exportedInterfaceB.properties[0]!.name).toBe("b");
expect(exportedInterfaceB.properties[0].name).toBe("b");
expect(exportedInterfaceB.heritage).toBeDefined();
expect(exportedInterfaceB.heritage).toHaveLength(1);

assert(exportedInterfaceB.heritage![0]!.instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceB.heritage![0]!.instanceType.properties).toHaveLength(1);
expect(exportedInterfaceB.heritage![0]!.instanceType.properties[0]!.name).toBe("a");
assert(exportedInterfaceB.heritage![0].instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceB.heritage![0].instanceType.properties).toHaveLength(1);
expect(exportedInterfaceB.heritage![0].instanceType.properties[0].name).toBe("a");

expect(exportedInterfaceC.properties).toHaveLength(1);
expect(exportedInterfaceC.properties[0]!.name).toBe("c");
expect(exportedInterfaceC.properties[0].name).toBe("c");
expect(exportedInterfaceC.heritage).toBeDefined();
expect(exportedInterfaceC.heritage).toHaveLength(1);

assert(exportedInterfaceC.heritage![0]!.instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceC.heritage![0]!.instanceType.properties).toHaveLength(2);
expect(exportedInterfaceC.heritage![0]!.instanceType.properties[1]!.name).toBe("a");
expect(exportedInterfaceC.heritage![0]!.instanceType.properties[0]!.name).toBe("b");
assert(exportedInterfaceC.heritage![0].instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceC.heritage![0].instanceType.properties).toHaveLength(2);
expect(exportedInterfaceC.heritage![0].instanceType.properties[1].name).toBe("a");
expect(exportedInterfaceC.heritage![0].instanceType.properties[0].name).toBe("b");

});

Expand Down Expand Up @@ -224,13 +224,13 @@ scope("Interpreter", EntityKind.Interface, () => {
expect(exportedInterfaceC.heritage).toBeDefined();
expect(exportedInterfaceC.heritage).toHaveLength(2);

assert(exportedInterfaceC.heritage![0]!.instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceC.heritage![0]!.instanceType.properties).toHaveLength(1);
expect(exportedInterfaceC.heritage![0]!.instanceType.properties[0]!.name).toBe("a");
assert(exportedInterfaceC.heritage![0].instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceC.heritage![0].instanceType.properties).toHaveLength(1);
expect(exportedInterfaceC.heritage![0].instanceType.properties[0].name).toBe("a");

assert(exportedInterfaceC.heritage![1]!.instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceC.heritage![1]!.instanceType.properties).toHaveLength(1);
expect(exportedInterfaceC.heritage![1]!.instanceType.properties[0]!.name).toBe("b");
assert(exportedInterfaceC.heritage![1].instanceType.kind === TypeKind.Interface);
expect(exportedInterfaceC.heritage![1].instanceType.properties).toHaveLength(1);
expect(exportedInterfaceC.heritage![1].instanceType.properties[0].name).toBe("b");

});

Expand All @@ -253,8 +253,8 @@ scope("Interpreter", EntityKind.Interface, () => {
expect(exportedInterface.typeParameters).toBeDefined();
expect(exportedInterface.typeParameters).toHaveLength(1);
expect(exportedInterface.properties).toHaveLength(1);
assert(exportedInterface.properties[0]!.type.kind === TypeKind.TypeReference);
expect(exportedInterface.properties[0]!.type.type!.kind).toBe(TypeKind.TypeParameter);
assert(exportedInterface.properties[0].type.kind === TypeKind.TypeReference);
expect(exportedInterface.properties[0].type.type!.kind).toBe(TypeKind.TypeParameter);
});

}
Expand Down
6 changes: 3 additions & 3 deletions src/interpreter/ast/entities/method.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ scope("Interpreter", EntityKind.Method, () => {
});

it("should have a matching kind", () => {
expect(exportedClass.methods[0]!.kind).toBe(EntityKind.Method);
expect(exportedClass.methods[0].kind).toBe(EntityKind.Method);
});

it("should have a matching name", () => {
expect(exportedClass.methods[0]!.name).toBe("method");
expect(exportedClass.methods[0].name).toBe("method");
});

it("should have one signature", () => {
expect(exportedClass.methods[0]!.signatures).toHaveLength(1);
expect(exportedClass.methods[0].signatures).toHaveLength(1);
});


Expand Down
10 changes: 5 additions & 5 deletions src/interpreter/ast/entities/parameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ scope("Interpreter", EntityKind.Parameter, () => {
it("should be able to parse a parameter", () => {
expect(exportedFunction.kind).toBe(EntityKind.Function);
expect(exportedFunction.signatures).toHaveLength(1);
expect(exportedFunction.signatures[0]!.parameters).toHaveLength(1);
expect(exportedFunction.signatures[0].parameters).toHaveLength(1);
});

}
Expand All @@ -44,7 +44,7 @@ scope("Interpreter", EntityKind.Parameter, () => {

const symbol = exportedSymbols.find(s => s.name === "functionSymbol")!;
const exportedFunction = createFunctionEntity(ctx, symbol);
const parameter = exportedFunction.signatures[0]!.parameters![0]!;
const parameter = exportedFunction.signatures[0].parameters![0];

it("should have a matching kind", () => {
expect(parameter.kind).toBe(EntityKind.Parameter);
Expand Down Expand Up @@ -84,7 +84,7 @@ scope("Interpreter", EntityKind.Parameter, () => {

const symbol = exportedSymbols.find(s => s.name === "functionSymbol")!;
const exportedFunction = createFunctionEntity(ctx, symbol);
const parameter = exportedFunction.signatures[0]!.parameters![0]!;
const parameter = exportedFunction.signatures[0].parameters![0];

it("should be able to handle optional types", () => {
expect(parameter.type.kind).toBe(TypeKind.String);
Expand All @@ -103,7 +103,7 @@ scope("Interpreter", EntityKind.Parameter, () => {

const symbol = exportedSymbols.find(s => s.name === "functionSymbol")!;
const exportedFunction = createFunctionEntity(ctx, symbol);
const parameter = exportedFunction.signatures[0]!.parameters![0]!;
const parameter = exportedFunction.signatures[0].parameters![0];

it("should be able to handle initialized types", () => {
expect(parameter.type.kind).toBe(TypeKind.String);
Expand All @@ -123,7 +123,7 @@ scope("Interpreter", EntityKind.Parameter, () => {

const symbol = exportedSymbols.find(s => s.name === "functionSymbol")!;
const exportedFunction = createFunctionEntity(ctx, symbol);
const parameter = exportedFunction.signatures[0]!.parameters![0]!;
const parameter = exportedFunction.signatures[0].parameters![0];

it("should be able to handle rest types", () => {
expect(parameter.rest).toBe(true);
Expand Down
34 changes: 17 additions & 17 deletions src/interpreter/ast/entities/property.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,24 @@ scope("Interpreter", EntityKind.Property, () => {

it("should have a matching name", () => {
assert(exportedTypeAlias.type.kind === TypeKind.TypeLiteral);
expect(exportedTypeAlias.type.properties[0]!.name).toBe("property");
expect(exportedTypeAlias.type.properties[0].name).toBe("property");

assert(exportedObjectLiteral.type.kind === TypeKind.ObjectLiteral);
expect(exportedObjectLiteral.type.properties[0]!.name).toBe("property");
expect(exportedObjectLiteral.type.properties[0].name).toBe("property");

expect(exportedClass.properties[0].name).toBe("property");
});

it("should have a matching description", () => {
assert(exportedTypeAlias.type.kind === TypeKind.TypeLiteral);
expect(exportedTypeAlias.type.properties[0]!.description).toHaveLength(1);
assert(isJSDocText(exportedTypeAlias.type.properties[0]!.description![0]));
expect(exportedTypeAlias.type.properties[0]!.description![0].text).toBe("Property description");
expect(exportedTypeAlias.type.properties[0].description).toHaveLength(1);
assert(isJSDocText(exportedTypeAlias.type.properties[0].description![0]));
expect(exportedTypeAlias.type.properties[0].description![0].text).toBe("Property description");

assert(exportedObjectLiteral.type.kind === TypeKind.ObjectLiteral);
expect(exportedObjectLiteral.type.properties[0]!.description).toHaveLength(1);
assert(isJSDocText(exportedObjectLiteral.type.properties[0]!.description![0]));
expect(exportedObjectLiteral.type.properties[0]!.description![0].text).toBe("Property description");
expect(exportedObjectLiteral.type.properties[0].description).toHaveLength(1);
assert(isJSDocText(exportedObjectLiteral.type.properties[0].description![0]));
expect(exportedObjectLiteral.type.properties[0].description![0].text).toBe("Property description");

expect(exportedClass.properties[0].description).toHaveLength(1);
assert(isJSDocText(exportedClass.properties[0].description![0]));
Expand All @@ -121,14 +121,14 @@ scope("Interpreter", EntityKind.Property, () => {

it("should have a matching example", () => {
assert(exportedTypeAlias.type.kind === TypeKind.TypeLiteral);
expect(exportedTypeAlias.type.properties[0]!.example).toHaveLength(1);
assert(isJSDocText(exportedTypeAlias.type.properties[0]!.example![0].content[0]));
expect(exportedTypeAlias.type.properties[0]!.example![0].content[0].text).toBe("Property example");
expect(exportedTypeAlias.type.properties[0].example).toHaveLength(1);
assert(isJSDocText(exportedTypeAlias.type.properties[0].example![0].content[0]));
expect(exportedTypeAlias.type.properties[0].example![0].content[0].text).toBe("Property example");

assert(exportedObjectLiteral.type.kind === TypeKind.ObjectLiteral);
expect(exportedObjectLiteral.type.properties[0]!.example).toHaveLength(1);
assert(isJSDocText(exportedObjectLiteral.type.properties[0]!.example![0].content[0]));
expect(exportedObjectLiteral.type.properties[0]!.example![0].content[0].text).toBe("Property example");
expect(exportedObjectLiteral.type.properties[0].example).toHaveLength(1);
assert(isJSDocText(exportedObjectLiteral.type.properties[0].example![0].content[0]));
expect(exportedObjectLiteral.type.properties[0].example![0].content[0].text).toBe("Property example");

expect(exportedClass.properties[0].example).toHaveLength(1);
assert(isJSDocText(exportedClass.properties[0].example![0].content[0]));
Expand All @@ -137,10 +137,10 @@ scope("Interpreter", EntityKind.Property, () => {

it("should have a matching type", () => {
assert(exportedTypeAlias.type.kind === TypeKind.TypeLiteral);
expect(exportedTypeAlias.type.properties[0]!.type.kind).toBe(TypeKind.String);
expect(exportedTypeAlias.type.properties[0].type.kind).toBe(TypeKind.String);

assert(exportedObjectLiteral.type.kind === TypeKind.ObjectLiteral);
expect(exportedObjectLiteral.type.properties[0]!.type.kind).toBe(TypeKind.String);
expect(exportedObjectLiteral.type.properties[0].type.kind).toBe(TypeKind.String);

expect(exportedClass.properties[0].type.kind).toBe(TypeKind.String);
});
Expand Down Expand Up @@ -219,7 +219,7 @@ scope("Interpreter", EntityKind.Property, () => {

assert(exportedTypeAlias.type.kind === TypeKind.TypeLiteral);

expect(exportedTypeAlias.type.properties[0]!.modifiers).toContain("readonly");
expect(exportedTypeAlias.type.properties[0].modifiers).toContain("readonly");

expect(exportedClass.properties.find(property => property.name === "publicProperty")!.modifiers).toContain("public");
expect(exportedClass.properties.find(property => property.name === "privateProperty")!.modifiers).toContain("private");
Expand Down

0 comments on commit 27a888b

Please sign in to comment.