Skip to content

Commit

Permalink
chore: improve interop between prettier and eslint (via #29)
Browse files Browse the repository at this point in the history
  • Loading branch information
delatrie authored Dec 19, 2024
1 parent f750fe3 commit 8b41665
Show file tree
Hide file tree
Showing 34 changed files with 89 additions and 110 deletions.
12 changes: 6 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ module.exports = {
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "none" }],
"@typescript-eslint/no-unused-vars": ["error", { caughtErrors: "none", ignoreRestSiblings: true }],
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/prefer-promise-reject-errors": "off",
"@stylistic/quotes": ["error", "double"],
"@stylistic/quotes": ["error", "double", { avoidEscape: true }],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/restrict-template-expressions": [
"error",
Expand Down Expand Up @@ -168,11 +168,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": "off",
"id-blacklist": [
"error",
Expand Down Expand Up @@ -230,7 +230,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
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ module.exports = {
importOrderSeparation: false,
importOrderSortSpecifiers: true,
importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"],
quoteProps: "consistent",
};
2 changes: 1 addition & 1 deletion packages/cli/src/commands/log.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AllureReport, resolveConfig } from "@allurereport/core";
import { createCommand } from "../utils/commands.js";
import * as console from "node:console";
import { createCommand } from "../utils/commands.js";

export type LogCommandOptions = {
allSteps?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/utils/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export type CreateCommandOptions = {

export const createCommand = (payload: CreateCommandOptions) => {
if (!payload.name) {
throw new Error("Command name is not provided!");
}
throw new Error("Command name is not provided!");
}
if (!payload.action) {
throw new Error("Command action is not provided!");
}
throw new Error("Command action is not provided!");
}

return (cli: CAC) => {
const command = cli.command(payload.name, payload.description);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/process.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ChildProcess} from "node:child_process";
import type { ChildProcess } from "node:child_process";
import { spawn } from "node:child_process";

export const runProcess = (
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/terminal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { TestResult, TestStatus} from "@allurereport/core-api";
import type { TestResult, TestStatus } from "@allurereport/core-api";
import { formatDuration } from "@allurereport/core-api";
import console from "node:console";
import { blue, gray, green, red, yellow } from "yoctocolors";
Expand Down
4 changes: 3 additions & 1 deletion packages/e2e/test/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export const generateTestResults = async (payload: GeneratorParams) => {
await report.done();
};

export const boostrapReport = async (params: Omit<GeneratorParams, "reportDir" | "resultsDir">): Promise<ReportBootstrap> => {
export const boostrapReport = async (
params: Omit<GeneratorParams, "reportDir" | "resultsDir">,
): Promise<ReportBootstrap> => {
const temp = tmpdir();
const allureTestResultsDir = await mkdtemp(resolve(temp, "allure-results-"));
const allureReportDir = await mkdtemp(resolve(temp, "allure-report-"));
Expand Down
1 change: 0 additions & 1 deletion packages/plugin-classic/src/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const sortByTime = (a: { time: Allure2Time }, b: { time: Allure2Time }): number
const convertStatus = (status: TestStatus): Allure2Status => status;

const convertStageResult = (context: ConvertContext, result: TestResult | TestFixtureResult): Allure2StageResult => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { name, ...testStage } = convertStep(context, {
name: "test",
steps: result.steps,
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-csv/src/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ export const generateCsv = async <T>(
};

const forceEscapeCsv = (value: any): string => {
// eslint-disable-next-line @stylistic/quotes,prefer-template
// eslint-disable-next-line prefer-template
return value ? '"' + `${value}`.replaceAll('"', '""') + '"' : "";
};
3 changes: 1 addition & 2 deletions packages/plugin-slack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export class SlackPlugin implements Plugin {
}),
headers: {
"Content-Type": "application/json;charset=utf-8",
// eslint-disable-next-line quote-props
Authorization: `Bearer ${token}`,
"Authorization": `Bearer ${token}`,
},
});

Expand Down
2 changes: 1 addition & 1 deletion packages/reader/src/allure1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const parseRootElement = async (visitor: ResultsVisitor, xml: Record<string, any
};

const parseTestSuite = async (visitor: ResultsVisitor, testSuite: Record<string, any>): Promise<boolean> => {
const { name: testSuiteName, "test-cases": testCases } = testSuite;
const { "name": testSuiteName, "test-cases": testCases } = testSuite;
if (!isStringAnyRecord(testCases)) {
return false;
}
Expand Down
3 changes: 0 additions & 3 deletions packages/reader/src/allure2/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ export interface Attachment {

// TODO we need to ensure case insensitive enums mapping + do not fail in case of invalid values

/* eslint-disable no-shadow */
export enum Status {
FAILED = "failed",
BROKEN = "broken",
PASSED = "passed",
SKIPPED = "skipped",
}

/* eslint-disable no-shadow */
export enum Stage {
SCHEDULED = "scheduled",
RUNNING = "running",
Expand All @@ -23,7 +21,6 @@ export enum Stage {
INTERRUPTED = "interrupted",
}

/* eslint-disable no-shadow */
export enum ParameterMode {
HIDDEN = "hidden",
MASKED = "masked",
Expand Down
2 changes: 1 addition & 1 deletion packages/reader/src/cucumberjson/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ResultsVisitor,
} from "@allurereport/reader-api";
import { BufferResultFile } from "@allurereport/reader-api";
import * as console from "node:console";
import { randomUUID } from "node:crypto";
import { ensureArray, ensureInt, ensureString, isArray, isNonNullObject, isString } from "../utils.js";
import type {
Expand Down Expand Up @@ -92,7 +93,6 @@ export const cucumberjson: ResultsReader = {
return oneOrMoreFeaturesParsed;
}
} catch (e) {
// eslint-disable-next-line no-console
console.error("error parsing", originalFileName, e);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "sandbox",
"type": "module",
"version": "3.0.0-beta.4",
"private": true,
"description": "A package to test another Allure Report packages in action",
"keywords": [],
"license": "Apache-2.0",
"author": "Qameta Software",
"type": "module",
"scripts": {
"pret": "rimraf ./allure-results",
"t": "vitest run"
Expand All @@ -32,6 +33,5 @@
"rimraf": "^6.0.1",
"vitest": "^2.1.8"
},
"packageManager": "[email protected]",
"private": true
"packageManager": "[email protected]"
}
47 changes: 8 additions & 39 deletions packages/sandbox/test/fixtures.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import {
afterAll,
afterEach,
beforeAll,
beforeEach,
describe,
it,
} from "vitest";
import { step, attachment } from "allure-js-commons";
import { attachment, step } from "allure-js-commons";
import { afterAll, afterEach, beforeAll, beforeEach, describe, it } from "vitest";

beforeAll(async () => {
await step("beforeAll 1", () => {});
Expand All @@ -24,63 +17,39 @@ describe("folder 1", () => {
beforeEach(async () => {
await step("beforeEach (folder 1) 1", () => {});
await step("beforeEach (folder 1) 2", () => {});
await attachment(
"beforeEach (folder 1) 3",
"beforeEach (folder 1) attachment",
"text/plain",
);
await attachment("beforeEach (folder 1) 3", "beforeEach (folder 1) attachment", "text/plain");
});

afterEach(async () => {
await step("afterEach (folder 1) 1", () => {});
await step("afterEach (folder 1) 2", () => {});
await attachment(
"afterEach (folder 1) 3",
"afterEach (folder 1) attachment",
"text/plain",
);
await attachment("afterEach (folder 1) 3", "afterEach (folder 1) attachment", "text/plain");
});

describe("folder 2", () => {
beforeEach(async () => {
await step("beforeEach (folder 2) 1", () => {});
await step("beforeEach (folder 2) 2", () => {});
await attachment(
"beforeEach (folder 2) 3",
"beforeEach (folder 2) attachment",
"text/plain",
);
await attachment("beforeEach (folder 2) 3", "beforeEach (folder 2) attachment", "text/plain");
});

afterEach(async () => {
await step("afterEach (folder 2) 1", () => {});
await step("afterEach (folder 2) 2", () => {});
await attachment(
"afterEach (folder 2) 3",
"afterEach (folder 2) attachment",
"text/plain",
);
await attachment("afterEach (folder 2) 3", "afterEach (folder 2) attachment", "text/plain");
});

describe("folder 3", () => {
beforeEach(async () => {
await step("beforeEach (folder 3) 1", () => {});
await step("beforeEach (folder 3) 2", () => {});
await attachment(
"beforeEach (folder 3) 3",
"beforeEach (folder 3) attachment",
"text/plain",
);
await attachment("beforeEach (folder 3) 3", "beforeEach (folder 3) attachment", "text/plain");
});

afterEach(async () => {
await step("afterEach (folder 3) 1", () => {});
await step("afterEach (folder 3) 2", () => {});
await attachment(
"afterEach (folder 3) 3",
"afterEach (folder 3) attachment",
"text/plain",
);
await attachment("afterEach (folder 3) 3", "afterEach (folder 3) attachment", "text/plain");
});

it("test", async () => {
Expand Down
1 change: 0 additions & 1 deletion packages/sandbox/test/legacy.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="allure-vitest" />

import { it } from "vitest";

it("sample test", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/sandbox/test/modern.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { it, expect } from "vitest";
import { expect, it } from "vitest";

it("sample passed test", async () => {
expect(true).toBe(true);
Expand Down
4 changes: 1 addition & 3 deletions packages/static-server/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @stylistic/quotes */
import watchDirectory from "@allurereport/directory-watcher";
import * as console from "node:console";
import { type Stats, createReadStream } from "node:fs";
Expand Down Expand Up @@ -85,8 +84,7 @@ export const serve = async (options?: {
res.writeHead(200, {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache",
// eslint-disable-next-line quote-props
Connection: "keep-alive",
"Connection": "keep-alive",
});

clients.add(res);
Expand Down
2 changes: 1 addition & 1 deletion packages/static-server/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ALLURE_LIVE_RELOAD_HASH_STORAGE_KEY } from "@allurereport/web-commons";

/* eslint-disable */
/* eslint max-lines: 0 */
export const EXTENSIONS_BY_TYPE: Record<string, string> = {
"application/andrew-inset": ".ez",
"application/applixware": ".aw",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-awesome/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
env: { browser: true, es2020: true },
extends: ["../../.eslintrc.cjs", "eslint-config-preact"],
extends: ["eslint-config-preact", "../../.eslintrc.cjs"],
ignorePatterns: ["dist/", ".eslintrc.cjs", "postcss.config.js", "webpack.config.js", "types.d.ts"],
parser: "@typescript-eslint/parser",
overrides: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FunctionalComponent } from "preact";
import { useState } from "preact/hooks";
import { MetadataButton } from "@/components/app/MetadataButton";
import { Text } from "@/components/commons/Typography";
import * as styles from "./styles.scss";
import { FunctionalComponent } from "preact";
import { AllureAwesomeTestResult } from "../../../../../types";
import * as styles from "./styles.scss";

export type TestResultDescriptionProps = {
description: AllureAwesomeTestResult["description"];
}
};

export const TestResultDescription: FunctionalComponent<TestResultDescriptionProps> = ({ description }) => {
const [isOpen, setIsOpen] = useState<boolean>(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import type { AttachmentTestStepResult } from "@allurereport/core-api";
import type { FunctionalComponent } from "preact";
import { useEffect, useState } from "preact/hooks";
import { modalData } from "@/components/app/Modal";
import { HtmlAttachmentPreview } from "@/components/app/TestResult/TestResultSteps/HtmlAttachmentPreview";
import { AttachmentCode } from "@/components/app/TestResult/TestResultSteps/attachmentCode";
import { AttachmentImage } from "@/components/app/TestResult/TestResultSteps/attachmentImage";
import { AttachmentVideo } from "@/components/app/TestResult/TestResultSteps/attachmentVideo";
import { EmptyComponent } from "@/components/app/TestResult/TestResultSteps/wrongAttachment";
import { Spinner } from "@/components/commons/Spinner";
import { type Attachments, attachmentType, fetchAttachment } from "@/utils/attachments";
import {
HtmlAttachmentPreview
} from "@/components/app/TestResult/TestResultSteps/HtmlAttachmentPreview";
import { modalData } from "@/components/app/Modal";
import * as styles from "./styles.scss";

const componentsByAttachmentType = {
Expand Down Expand Up @@ -63,8 +61,8 @@ export const Attachment: FunctionalComponent<AttachmentTestStepResultProps> = ({

// temp solution before modal component refactoring
if (CurrentPreviewComponent && previewable && modalData.value.preview) {
return <CurrentPreviewComponent attachment={attachment} item={item} />
return <CurrentPreviewComponent attachment={attachment} item={item} />;
}

return CurrentComponent ? <CurrentComponent attachment={attachment} item={item} /> : <EmptyComponent />
return CurrentComponent ? <CurrentComponent attachment={attachment} item={item} /> : <EmptyComponent />;
};
6 changes: 3 additions & 3 deletions packages/web-awesome/src/components/commons/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export const Menu = (props: {
}).then(({ x, y }) => {
if (menuRef.current) {
Object.assign(menuRef.current.style, {
left: `${x}px`,
top: `${y}px`,
position: "absolute",
"left": `${x}px`,
"top": `${y}px`,
"position": "absolute",
"z-index": 10,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const SearchBox = (props: Props) => {
value={localValue}
name="search"
autocomplete="off"
data-testid="search-input"
data-testid="search-input"
/>
{showClear && (
<div className={styles.clearButton}>
Expand Down
Loading

0 comments on commit 8b41665

Please sign in to comment.