Skip to content

Commit

Permalink
fix typescript-eslint issues (via #1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
delatrie authored Jun 17, 2024
1 parent 402a782 commit dc06dbc
Show file tree
Hide file tree
Showing 37 changed files with 153 additions and 66 deletions.
15 changes: 11 additions & 4 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable id-blacklist */
module.exports = {
root: true,
globals: {
Expand All @@ -23,6 +24,12 @@ module.exports = {
},
plugins: ["n", "no-null", "prefer-arrow", "import", "jsdoc", "@typescript-eslint"],
ignorePatterns: ["**/dist/**/*"],
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/adjacent-overload-signatures": "error",
Expand Down Expand Up @@ -158,11 +165,11 @@ module.exports = {
"arrow-body-style": "off",
"arrow-parens": ["off", "always"],
"brace-style": ["error", "1tbs"],
complexity: "off",
"complexity": "off",
"constructor-super": "error",
curly: "error",
"curly": "error",
"eol-last": "error",
eqeqeq: ["error", "smart"],
"eqeqeq": ["error", "smart"],
"guard-for-in": "error",
"id-blacklist": [
"error",
Expand Down Expand Up @@ -220,7 +227,7 @@ module.exports = {
"prefer-const": "error",
"prefer-template": "error",
"quote-props": ["error", "consistent-as-needed"],
radix: "error",
"radix": "error",
"space-before-function-paren": [
"error",
{
Expand Down
10 changes: 8 additions & 2 deletions .pnp.loader.mjs

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

7 changes: 7 additions & 0 deletions packages/allure-codeceptjs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module.exports = {
extends: ["../../.eslintrc.cjs"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
};
10 changes: 5 additions & 5 deletions packages/allure-codeceptjs/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AllureCodeceptJsReporter {
}

// @ts-ignore
result.parameters!.push({ name: "Repetition", value: `${test.retryNum + 1}` });
result.parameters.push({ name: "Repetition", value: `${test.retryNum + 1}` });
}, this.currentAllureResultUuid);

this.allureRuntime!.stopTest({ uuid: this.currentAllureResultUuid });
Expand Down Expand Up @@ -198,28 +198,28 @@ export class AllureCodeceptJsReporter {
{
name: `${step.actor} ${step.name}`,
},
this.currentAllureResultUuid!,
this.currentAllureResultUuid,
);
}

stepFailed() {
this.allureRuntime!.updateStep((result) => {
result.status = Status.FAILED;
}, this.currentAllureResultUuid!);
}, this.currentAllureResultUuid);
this.closeCurrentAllureStep();
}

stepComment() {
this.allureRuntime!.updateStep((result) => {
result.status = Status.PASSED;
}, this.currentAllureResultUuid!);
}, this.currentAllureResultUuid);
this.closeCurrentAllureStep();
}

stepPassed() {
this.allureRuntime!.updateStep((result) => {
result.status = Status.PASSED;
}, this.currentAllureResultUuid!);
}, this.currentAllureResultUuid);
this.closeCurrentAllureStep();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it("handles attachments in tests", async () => {
type: "text/plain",
source: expect.any(String),
});
expect(attachments).toHaveProperty(attachment.source as string);
expect(attachments).toHaveProperty(attachment.source);
expect(Buffer.from(attachments[attachment.source] as string, "base64").toString("utf8")).toEqual("some data");
});

Expand Down Expand Up @@ -56,6 +56,6 @@ it("handles attachments in runtime steps", async () => {
type: "text/plain",
source: expect.any(String),
});
expect(attachments).toHaveProperty(attachment.source as string);
expect(attachments).toHaveProperty(attachment.source);
expect(Buffer.from(attachments[attachment.source] as string, "base64").toString("utf8")).toEqual("some data");
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ it("handles attachments in tests", async () => {
type: "text/plain",
source: expect.any(String),
});
expect(attachments).toHaveProperty(attachment.source as string);
expect(attachments).toHaveProperty(attachment.source);
expect(Buffer.from(attachments[attachment.source] as string, "base64").toString("utf8")).toEqual("some data");
});

Expand Down Expand Up @@ -56,6 +56,6 @@ it("handles attachments in runtime steps", async () => {
type: "text/plain",
source: expect.any(String),
});
expect(attachments).toHaveProperty(attachment.source as string);
expect(attachments).toHaveProperty(attachment.source);
expect(Buffer.from(attachments[attachment.source] as string, "base64").toString("utf8")).toEqual("some data");
});
7 changes: 7 additions & 0 deletions packages/allure-cucumberjs/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module.exports = {
extends: ["../../.eslintrc.cjs"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
};
2 changes: 1 addition & 1 deletion packages/allure-cucumberjs/src/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export default class AllureCucumberReporter extends Formatter {

const testUuid = this.allureRuntime.startTest(result);
this.testCaseStartedMap.set(data.id, data);
this.allureResultsUuids.set(data.id, testUuid as string);
this.allureResultsUuids.set(data.id, testUuid);
this.allureRuntime.startScope();

if (!scenario?.examples) {
Expand Down
7 changes: 7 additions & 0 deletions packages/allure-cypress/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ module.exports = {
"cypress/globals": true,
},
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
};
6 changes: 3 additions & 3 deletions packages/allure-cypress/test/spec/screenshots.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, it } from "vitest";
import { type Attachment, ContentType } from "allure-js-commons";
import { ContentType } from "allure-js-commons";
import { runCypressInlineTest } from "../utils.js";

it("attaches screenshots for failed specs", async () => {
Expand All @@ -18,7 +18,7 @@ it("attaches screenshots for failed specs", async () => {

expect(attachment.name).toBe("Screenshot");
expect(attachment.type).toBe(ContentType.PNG);
expect(attachments).toHaveProperty((attachment as Attachment).source);
expect(attachments).toHaveProperty(attachment.source);
});

it("attaches runtime screenshots", async () => {
Expand All @@ -37,5 +37,5 @@ it("attaches runtime screenshots", async () => {

expect(attachment.name).toBe("foo");
expect(attachment.type).toBe(ContentType.PNG);
expect(attachments).toHaveProperty((attachment as Attachment).source);
expect(attachments).toHaveProperty(attachment.source);
});
7 changes: 7 additions & 0 deletions packages/allure-jasmine/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ module.exports = {
jasmine: true,
},
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
};
8 changes: 4 additions & 4 deletions packages/allure-jasmine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter {
const allureRuntime = this.allureRuntime;
const globalJasmine = globalThis.jasmine;
const currentAllureResultUuidGetter = () => this.currentAllureTestUuid;
const currentAllureStepResultGetter = () => this.allureRuntime.getCurrentStep(currentAllureResultUuidGetter()!);
const currentAllureStepResultGetter = () => this.allureRuntime.getCurrentStep(currentAllureResultUuidGetter());
// @ts-ignore
const originalExpectationHandler = globalJasmine.Spec.prototype.addExpectationResult;

Expand All @@ -92,7 +92,7 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter {
allureRuntime.updateStep((result) => {
result.status = Status.FAILED;
result.stage = Stage.FINISHED;
}, currentAllureResultUuidGetter()!);
}, currentAllureResultUuidGetter());
}

originalExpectationHandler.call(this, passed, data, isError);
Expand Down Expand Up @@ -156,9 +156,9 @@ export default class AllureJasmineReporter implements jasmine.CustomReporter {
result.status = Status.BROKEN;
return;
}
}, this.currentAllureTestUuid!);
}, this.currentAllureTestUuid);
this.allureRuntime.stopTest({ uuid: this.currentAllureTestUuid! });
this.allureRuntime.writeTest(this.currentAllureTestUuid!);
this.allureRuntime.writeTest(this.currentAllureTestUuid);
this.currentAllureTestUuid = undefined;
}

Expand Down
9 changes: 8 additions & 1 deletion packages/allure-jest/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ module.exports = {
jest: true,
},
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
}
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
};
2 changes: 1 addition & 1 deletion packages/allure-jest/src/environmentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const createJestEnvironment = <T extends typeof JestEnvironment>(Base: T): T =>
return;
}

this.allureUuidsByTestIds.set(newTestId, testUuid as string);
this.allureUuidsByTestIds.set(newTestId, testUuid);
}

private handleTestStart(test: Circus.TestEntry) {
Expand Down
7 changes: 7 additions & 0 deletions packages/allure-js-commons/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
module.exports = {
extends: ["../../.eslintrc.cjs"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
}
],
};
7 changes: 7 additions & 0 deletions packages/allure-js-commons/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"include": ["./test/**/*"],
"compilerOptions": {
"noEmit": true
}
}
5 changes: 5 additions & 0 deletions packages/allure-mocha/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
module.exports = {
extends: ["../../.eslintrc.cjs"],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json", "./tsconfig.test.json"],
},
overrides: [
{
extends: ["plugin:@typescript-eslint/disable-type-checked"],
files: [".eslintrc.cjs"],
},
{
files: ["**/*.cjs", "**/*.js"],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-mocha/src/AllureMochaReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export class AllureMochaReporter extends Mocha.reporters.Base {
private onHookEnd = (hook: Mocha.Hook) => {
if (this.runtime.hasFixture()) {
this.runtime.updateFixture((r) => {
const error = hook.error();
const error: Error | undefined = hook.error();
if (error) {
r.status = getStatusFromError(error);
r.statusDetails = {
Expand Down
2 changes: 1 addition & 1 deletion packages/allure-mocha/src/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LegacyAllureApi {
* @deprecated please use import { parameter } from "allure-js-commons" instead.
*/
parameter = (name: string, value: any, options?: ParameterOptions) =>
Promise.resolve(commons.parameter(name, serialize(value) as string, options));
Promise.resolve(commons.parameter(name, serialize(value), options));
/**
* @deprecated please use import { link } from "allure-js-commons" instead.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("legacy link API", () => {
["legacy", "links", "tms"],
);
for (const test of tests) {
testMap.set(test.name as string, test as TestResult);
testMap.set(test.name as string, test);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe("legacy runtime parameters API", () => {
);
for (const testResult of results.tests) {
if (testMap.has(testResult.name as string)) {
testMap.get(testResult.name as string)!.push(testResult as TestResult);
testMap.get(testResult.name as string)!.push(testResult);
} else {
testMap.set(testResult.name as string, [testResult as TestResult]);
testMap.set(testResult.name as string, [testResult]);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("step", () => {
["legacy", "steps", "stepReturnsPromise"],
);
for (const testResult of results.tests) {
testMap.set(testResult.name as string, testResult as TestResult);
testMap.set(testResult.name as string, testResult);
}
attachments = results.attachments;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("legacy suites API", () => {
["legacy", "labels", "suites", "subSuite"],
);
for (const testResult of tests) {
testMap.set(testResult.name as string, testResult as TestResult);
testMap.set(testResult.name as string, testResult);
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/allure-mocha/test/spec/api/runtime/links.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("link", () => {
["links", "multipleLinks"],
);
for (const test of tests) {
testMap.set(test.name as string, test as TestResult);
testMap.set(test.name as string, test);
}
});

Expand Down
Loading

0 comments on commit dc06dbc

Please sign in to comment.