Skip to content

Commit c358e2d

Browse files
ESLint fixes
1 parent a6fd804 commit c358e2d

File tree

5 files changed

+21
-22
lines changed

5 files changed

+21
-22
lines changed

src/deep-clone.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// tslint:disable-next-line: no-any
21
type ObjectOrArray = Record<string | number, any>;
32

43
/**
54
* Deep-clones a JSON object or array.
65
*/
7-
export function deepClone<T extends ObjectOrArray>(obj: T): T {
6+
export function deepClone<T extends ObjectOrArray>(obj: T): T {
87
let clone: ObjectOrArray = Array.isArray(obj) ? [] : {};
98

109
for (let key of Object.keys(obj)) {

src/employees.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @ts-ignore - Prevent TypeScript from copying the JSON file to the output folder
1+
// @ts-expect-error - Prevent TypeScript from copying the JSON file to the output folder
22
import jsonEmployees from "../employees.json";
33
import { deepClone } from "./deep-clone";
44
import { resolve } from "./isomorphic.node";

src/projects.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @ts-ignore - Prevent TypeScript from copying the JSON file to the output folder
1+
// @ts-expect-error - Prevent TypeScript from copying the JSON file to the output folder
22
import jsonProjects from "../projects.json";
33
import { deepClone } from "./deep-clone";
44

test/specs/employees.spec.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,28 @@ describe("employees", () => {
6767

6868
it("should have valid data types for all fields", () => {
6969
employees.forEach((employee) => {
70-
expect(employee.username).to.be.a("string").and.not.empty;
71-
expect(employee.password).to.be.a("string").and.not.empty;
72-
expect(employee.name.first).to.be.a("string").and.not.empty;
73-
expect(employee.name.last).to.be.a("string").and.not.empty;
70+
expect(employee.username).to.be.a("string").with.length.of.at.least(1);
71+
expect(employee.password).to.be.a("string").with.length.of.at.least(1);
72+
expect(employee.name.first).to.be.a("string").with.length.of.at.least(1);
73+
expect(employee.name.last).to.be.a("string").with.length.of.at.least(1);
7474
expect(employee.gender).to.be.a("string").and.match(/^male|female$/);
75-
expect(employee.portrait).to.be.a("string").and.not.empty;
76-
expect(employee.thumbnail).to.be.a("string").and.not.empty;
77-
expect(employee.email).to.be.a("string").and.not.empty;
78-
expect(employee.address.street).to.be.a("string").and.not.empty;
79-
expect(employee.address.city).to.be.a("string").and.not.empty;
80-
expect(employee.address.state).to.be.a("string").and.not.empty;
75+
expect(employee.portrait).to.be.a("string").with.length.of.at.least(1);
76+
expect(employee.thumbnail).to.be.a("string").with.length.of.at.least(1);
77+
expect(employee.email).to.be.a("string").with.length.of.at.least(1);
78+
expect(employee.address.street).to.be.a("string").with.length.of.at.least(1);
79+
expect(employee.address.city).to.be.a("string").with.length.of.at.least(1);
80+
expect(employee.address.state).to.be.a("string").with.length.of.at.least(1);
8181
expect(employee.address.zip).to.be.a("string").and.match(/^\d{5}$/);
8282
expect(employee.phones).to.be.an("array").and.have.length.above(0);
8383
expect(employee.ssn).to.be.a("string").and.match(/^\d{3}-\d{2}-\d{4}$/);
8484
expect(employee.department).to.be.a("string").and.match(/^Accounting|Sales|Human Resources|Marketing$/);
8585
expect(employee.roles).to.be.an("array").and.have.length.above(0);
8686

8787
if (isJSON) {
88-
expect(employee.dob).to.be.a("string").and.not.empty;
89-
expect(employee.hiredOn).to.be.a("string").and.not.empty;
88+
expect(employee.dob).to.be.a("string").with.length.of.at.least(1);
89+
expect(employee.hiredOn).to.be.a("string").with.length.of.at.least(1);
9090
if (employee.terminatedOn) {
91-
expect(employee.terminatedOn).to.be.a("string").and.not.empty;
91+
expect(employee.terminatedOn).to.be.a("string").with.length.of.at.least(1);
9292
}
9393
}
9494
else {
@@ -125,8 +125,8 @@ describe("employees", () => {
125125
expect(employee.thumbnail).to.satisfy(path.isAbsolute);
126126
}
127127

128-
expect(fs.existsSync(employee.portrait)).to.be.true;
129-
expect(fs.existsSync(employee.thumbnail)).to.be.true;
128+
expect(fs.existsSync(employee.portrait)).to.equal(true);
129+
expect(fs.existsSync(employee.thumbnail)).to.equal(true);
130130
}
131131
else {
132132
expect(employee.portrait).to.equal("portraits/" + employee.username + ".jpg");

test/specs/projects.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ describe("projects", () => {
5353
expect(project.assigned).to.be.an("array").and.have.length.above(0);
5454

5555
if (isJSON) {
56-
expect(project.startedOn).to.be.a("string").and.not.empty;
56+
expect(project.startedOn).to.be.a("string").with.length.of.at.least(1);
5757
if (project.endedOn !== null) {
58-
expect(project.endedOn).to.be.a("string").and.not.empty;
58+
expect(project.endedOn).to.be.a("string").with.length.of.at.least(1);
5959
}
6060
}
6161
else {
@@ -66,7 +66,7 @@ describe("projects", () => {
6666
}
6767

6868
project.assigned.forEach((username) => {
69-
expect(username).to.be.a("string").and.not.empty;
69+
expect(username).to.be.a("string").with.length.of.at.least(1);
7070
});
7171
});
7272
});

0 commit comments

Comments
 (0)