From 44ebe0bbac1a6050927f08cfd33993adf9e1fa73 Mon Sep 17 00:00:00 2001 From: Stas Seliverstov Date: Thu, 5 Mar 2020 16:07:12 +0300 Subject: [PATCH] fix errors and warnings --- .eslintrc.yml | 3 ++- packages/allure-cucumberjs/features/.eslintrc.yml | 3 +++ .../features/step_definitions/report.steps.ts | 2 +- packages/allure-cucumberjs/features/support/report.ts | 7 ++----- packages/allure-cucumberjs/features/support/world.ts | 11 ++--------- .../allure-cucumberjs/src/CucumberJSAllureReporter.ts | 4 ++-- packages/allure-cucumberjs/src/utilities.ts | 2 +- packages/allure-jasmine/test/matchers.ts | 4 +++- packages/allure-jasmine/test/status.test.ts | 2 +- 9 files changed, 17 insertions(+), 21 deletions(-) create mode 100644 packages/allure-cucumberjs/features/.eslintrc.yml diff --git a/.eslintrc.yml b/.eslintrc.yml index 4a4a57a88..f3d76ab0a 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -27,6 +27,7 @@ rules: valid-jsdoc: off no-multi-spaces: error no-return-await: error + no-redeclare: [error, { "builtinGlobals": true }] require-await: warn no-self-compare: error no-useless-concat: error @@ -35,7 +36,7 @@ rules: arrow-spacing: error no-confusing-arrow: error no-var: error - object-shorthand: [warn, consistent-as-needed] + object-shorthand: [off, consistent-as-needed] prefer-const: error prefer-destructuring: warn prefer-rest-params: warn diff --git a/packages/allure-cucumberjs/features/.eslintrc.yml b/packages/allure-cucumberjs/features/.eslintrc.yml new file mode 100644 index 000000000..98a49f1ae --- /dev/null +++ b/packages/allure-cucumberjs/features/.eslintrc.yml @@ -0,0 +1,3 @@ +rules: + new-cap: off + diff --git a/packages/allure-cucumberjs/features/step_definitions/report.steps.ts b/packages/allure-cucumberjs/features/step_definitions/report.steps.ts index 9d8655725..ac1e1b04a 100644 --- a/packages/allure-cucumberjs/features/step_definitions/report.steps.ts +++ b/packages/allure-cucumberjs/features/step_definitions/report.steps.ts @@ -8,7 +8,7 @@ import { StepResult } from "allure-js-commons"; chai.use(ChaiPartial); Then(/^it has result for "(.*)"$/, function(name: string) { - expect(this.allureReport.testResults).to.partial([{name}]); + expect(this.allureReport.testResults).to.partial([{ name }]); }); When(/^I choose result for "(.*)"$/, function(name: string) { diff --git a/packages/allure-cucumberjs/features/support/report.ts b/packages/allure-cucumberjs/features/support/report.ts index 1c185b7d7..b4e53afa2 100644 --- a/packages/allure-cucumberjs/features/support/report.ts +++ b/packages/allure-cucumberjs/features/support/report.ts @@ -1,11 +1,8 @@ import { CucumberJSAllureFormatter } from "../../src/CucumberJSAllureReporter"; -import {AllureRuntime} from "allure-js-commons"; +import { AllureRuntime } from "allure-js-commons"; export default class Reporter extends CucumberJSAllureFormatter { constructor(options: any) { - super( - options, - new AllureRuntime({ resultsDir: "./out/allure-results" }), {} - ); + super(options, new AllureRuntime({ resultsDir: "./out/allure-results" }), {}); } } diff --git a/packages/allure-cucumberjs/features/support/world.ts b/packages/allure-cucumberjs/features/support/world.ts index 1dfdb576c..3281b5359 100644 --- a/packages/allure-cucumberjs/features/support/world.ts +++ b/packages/allure-cucumberjs/features/support/world.ts @@ -20,24 +20,17 @@ const getAllureReport: (reportPath: string) => AllureReport = reportPath => { return allureReport; }; - class AllureWorld implements World, AllureWorld { tmpDir: string = ""; formatterPath = "support/allure-formatter.ts"; formatterOutPath = "../out/allure-results"; allureReport: AllureReport = { testResults: [] }; - result: {stdout: string, stderr: string, error: string} = {stdout: "", stderr: "", error: ""} + result: { stdout: string; stderr: string; error: string } = { stdout: "", stderr: "", error: "" }; async run() { const formatterPath = path.join(this.tmpDir, this.formatterPath); const formatterOutPath = path.join(this.tmpDir, this.formatterOutPath); - const argv = [ - "", - "", - "--backtrace", - "--require-module=ts-node/register", - `--format=${formatterPath}:.dummy.txt` - ]; + const argv = ["", "", "--backtrace", "--require-module=ts-node/register", `--format=${formatterPath}:.dummy.txt`]; const cwd = this.tmpDir; diff --git a/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts b/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts index 3b6f24eba..a1d18828f 100644 --- a/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts +++ b/packages/allure-cucumberjs/src/CucumberJSAllureReporter.ts @@ -154,7 +154,7 @@ export class CucumberJSAllureFormatter extends Formatter { if (test.example !== undefined) { info.a = test.example.arguments; for (const prop in test.example.arguments) { - if (!test.example.arguments.hasOwnProperty(prop)) continue; + if (!test.example.arguments[prop]) continue; this.currentTest.addParameter(prop, test.example.arguments[prop]); } } @@ -169,7 +169,7 @@ export class CucumberJSAllureFormatter extends Formatter { this.currentTest.addLabel(LabelName.TAG, tag.name); for (const label in this.labels) { - if (!this.labels.hasOwnProperty(label)) continue; + if (!this.labels[label]) continue; for (const reg of this.labels[label]) { const match = tag.name.match(reg); if (match != null && match.length > 1) { diff --git a/packages/allure-cucumberjs/src/utilities.ts b/packages/allure-cucumberjs/src/utilities.ts index d8cfcabd6..91e124162 100644 --- a/packages/allure-cucumberjs/src/utilities.ts +++ b/packages/allure-cucumberjs/src/utilities.ts @@ -23,7 +23,7 @@ export function hash(data: string): string { export function applyExample(text: string, example: Example | undefined): string { if (example === undefined) return text; for (const argName in example.arguments) { - if (!example.arguments.hasOwnProperty(argName)) continue; + if (!example.arguments[argName]) continue; text = text.replace(new RegExp(`<${argName}>`, "g"), `<${example.arguments[argName]}>`); } return text; diff --git a/packages/allure-jasmine/test/matchers.ts b/packages/allure-jasmine/test/matchers.ts index 459060e0e..dce2ac3f7 100644 --- a/packages/allure-jasmine/test/matchers.ts +++ b/packages/allure-jasmine/test/matchers.ts @@ -1,7 +1,9 @@ import MatchersUtil = jasmine.MatchersUtil; import CustomEqualityTester = jasmine.CustomEqualityTester; +import CustomMatcher = jasmine.CustomMatcher; declare global { + // eslint-disable-next-line no-redeclare namespace jasmine { interface Matchers { toHaveTestLike(expected: any, expectationFailOutput?: any): boolean; @@ -37,7 +39,7 @@ const compare: (actual: any, expected: any) => boolean = (actual, expected) => { }; export const matchers = { - toHaveTestLike: (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => ({ + toHaveTestLike: (util: MatchersUtil, customEqualityTesters: Readonly) => ({ compare: (actual: any, expected: any) => ({ pass: compare(actual, { tests: [expected] }), message: diff --git a/packages/allure-jasmine/test/status.test.ts b/packages/allure-jasmine/test/status.test.ts index 41cdc1ce2..e4cbbf297 100644 --- a/packages/allure-jasmine/test/status.test.ts +++ b/packages/allure-jasmine/test/status.test.ts @@ -1,6 +1,6 @@ import { Status } from "allure-js-commons"; import { matchers } from "./matchers"; -import {runTest} from "./helpers"; +import { runTest } from "./helpers"; describe("Allure Result", () => { beforeAll(() => jasmine.addMatchers(matchers));