Skip to content

Commit

Permalink
enforce import order, autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjgoss committed Oct 8, 2023
1 parent d555c79 commit ef4cf5f
Show file tree
Hide file tree
Showing 124 changed files with 306 additions and 304 deletions.
1 change: 1 addition & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ plugins:
- '@typescript-eslint'
rules:
'no-console': 'error'
'import/order': 'error'
'unicorn/prefer-node-protocol': 'error'
# requires strictNullChecks compiler option, produces many errors with messages objects
'@typescript-eslint/strict-boolean-expressions': off
Expand Down
12 changes: 6 additions & 6 deletions compatibility/cck_spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import fs from 'node:fs'
import path from 'node:path'
import { PassThrough, pipeline, Writable } from 'node:stream'
import util from 'node:util'
import { describe, it } from 'mocha'
import { config, expect, use } from 'chai'
import chaiExclude from 'chai-exclude'
import { glob } from 'glob'
import fs from 'node:fs'
import path from 'node:path'
import { PassThrough, pipeline, Writable } from 'node:stream'
import { ignorableKeys } from '../features/support/formatter_output_helpers'
import * as messages from '@cucumber/messages'
import * as messageStreams from '@cucumber/message-streams'
import util from 'node:util'
import { runCucumber, IRunConfiguration } from '../src/api'
import { Envelope } from '@cucumber/messages'
import { ignorableKeys } from '../features/support/formatter_output_helpers'
import { runCucumber, IRunConfiguration } from '../src/api'

const asyncPipeline = util.promisify(pipeline)
const PROJECT_PATH = path.join(__dirname, '..')
Expand Down
4 changes: 2 additions & 2 deletions compatibility/features/attachments/attachments.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Before, When, World } from '../../../src'
import { ReadableStreamBuffer } from 'stream-buffers'
import fs from 'node:fs'
import path from 'node:path'
import { ReadableStreamBuffer } from 'stream-buffers'
import { Before, When, World } from '../../../src'

Before((): void => undefined)

Expand Down
2 changes: 1 addition & 1 deletion compatibility/features/data-tables/data-tables.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { When, Then, DataTable } from '../../../src'
import { expect } from 'chai'
import { When, Then, DataTable } from '../../../src'

type World = {
transposed: DataTable
Expand Down
2 changes: 1 addition & 1 deletion compatibility/features/hooks/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { When, Before, After, World } from '../../../src'
import fs from 'node:fs'
import path from 'node:path'
import { When, Before, After, World } from '../../../src'

Before(function () {
// no-op
Expand Down
2 changes: 1 addition & 1 deletion compatibility/features/parameter-types/parameter-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Given, defineParameterType } from '../../../src'
import { expect } from 'chai'
import { Given, defineParameterType } from '../../../src'

class Flight {
constructor(
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/cli_steps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DataTable, Then, When } from '../../'
import { expect } from 'chai'
import { normalizeText } from '../support/helpers'
import stringArgv from 'string-argv'
import Mustache from 'mustache'
import { normalizeText } from '../support/helpers'
import { DataTable, Then, When } from '../../'
import {
doesHaveValue,
doesNotHaveValue,
Expand Down
6 changes: 3 additions & 3 deletions features/step_definitions/file_steps.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Given, Then } from '../../'
import path from 'node:path'
import { expect } from 'chai'
import hasAnsi from 'has-ansi'
import { normalizeText } from '../support/helpers'
import fs from 'mz/fs'
import fsExtra from 'fs-extra'
import path from 'node:path'
import Mustache from 'mustache'
import { normalizeText } from '../support/helpers'
import { Given, Then } from '../../'
import { World } from '../support/world'

Given(
Expand Down
6 changes: 3 additions & 3 deletions features/step_definitions/formatter_steps.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Then } from '../../'
import path from 'node:path'
import { expect, use } from 'chai'
import chaiExclude from 'chai-exclude'
import fs from 'mz/fs'
import { Then } from '../../'
import {
ignorableKeys,
normalizeJsonOutput,
normalizeMessageOutput,
stripMetaMessages,
} from '../support/formatter_output_helpers'
import fs from 'mz/fs'
import path from 'node:path'
import { World } from '../support/world'

use(chaiExclude)
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/install_steps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Given } from '../../'
import tmp from 'tmp'
import path from 'node:path'
import fs from 'node:fs'
import tmp from 'tmp'
import fsExtra from 'fs-extra'
import { Given } from '../../'
import { World } from '../support/world'

/*
Expand Down
6 changes: 3 additions & 3 deletions features/step_definitions/message_steps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Then } from '../../'
import { expect } from 'chai'
import * as messages from '@cucumber/messages'
import semver from 'semver'
import { Then } from '../../'
import DataTable from '../../src/models/data_table'
import {
getPickleNamesInOrderOfExecution,
Expand All @@ -9,9 +11,7 @@ import {
getTestStepAttachmentsForStep,
getTestStepResults,
} from '../support/message_helpers'
import * as messages from '@cucumber/messages'
import { World } from '../support/world'
import semver from 'semver'

const ENCODING_MAP: { [key: string]: messages.AttachmentContentEncoding } = {
IDENTITY: messages.AttachmentContentEncoding.IDENTITY,
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/parallel_steps.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DataTable, Then } from '../../'
import { World } from '../support/world'
import messages from '@cucumber/messages'
import { expect } from 'chai'
import { DataTable, Then } from '../../'
import { World } from '../support/world'

function getSetsOfPicklesRunningAtTheSameTime(
envelopes: messages.Envelope[]
Expand Down
6 changes: 3 additions & 3 deletions features/step_definitions/report_server_steps.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { URL } from 'node:url'
import assert from 'node:assert'
import { expect } from 'chai'
import { Given, Then, DataTable } from '../..'
import { World } from '../support/world'
import { expect } from 'chai'
import { URL } from 'node:url'
import FakeReportServer from '../../test/fake_report_server'
import assert from 'node:assert'

Given(
'a report server is running on {string}',
Expand Down
4 changes: 2 additions & 2 deletions features/step_definitions/usage_json_steps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataTable, Then } from '../../'
import { expect } from 'chai'
import path from 'node:path'
import { expect } from 'chai'
import { DataTable, Then } from '../../'
import { World } from '../support/world'
import { IUsage } from '../../src/formatter/helpers/usage_helpers'

Expand Down
2 changes: 1 addition & 1 deletion features/support/formatter_output_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as messages from '@cucumber/messages'
import {
doesHaveValue,
doesNotHaveValue,
Expand All @@ -8,7 +9,6 @@ import {
IJsonScenario,
IJsonStep,
} from '../../src/formatter/json_formatter'
import * as messages from '@cucumber/messages'

// Converting windows stack trace to posix and removing cwd
// C:\\project\\path\\features\\support/code.js
Expand Down
4 changes: 2 additions & 2 deletions features/support/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { After, Before, formatterHelpers, ITestCaseHookParameter } from '../../'
import fsExtra from 'fs-extra'
import path from 'node:path'
import fsExtra from 'fs-extra'
import { After, Before, formatterHelpers, ITestCaseHookParameter } from '../../'
import { doesHaveValue } from '../../src/value_checker'
import { World } from './world'
import { warnUserAboutEnablingDeveloperMode } from './warn_user_about_enabling_developer_mode'
Expand Down
12 changes: 6 additions & 6 deletions features/support/message_helpers.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { getGherkinStepMap } from '../../src/formatter/helpers/gherkin_document_parser'
import {
getPickleStepMap,
getStepKeyword,
} from '../../src/formatter/helpers/pickle_parser'
import util from 'node:util'
import * as messages from '@cucumber/messages'
import { Query } from '@cucumber/query'
import { doesHaveValue, doesNotHaveValue } from '../../src/value_checker'
import { getWorstTestStepResult } from '@cucumber/messages'
import { doesHaveValue, doesNotHaveValue } from '../../src/value_checker'
import {
getPickleStepMap,
getStepKeyword,
} from '../../src/formatter/helpers/pickle_parser'
import { getGherkinStepMap } from '../../src/formatter/helpers/gherkin_document_parser'

export interface IStepTextAndResult {
text: string
Expand Down
10 changes: 5 additions & 5 deletions features/support/world.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { setWorldConstructor } from '../../'
import { execFile } from 'node:child_process'
import { expect } from 'chai'
import toString from 'stream-to-string'
import { PassThrough, pipeline, Writable } from 'node:stream'
import stripAnsi from 'strip-ansi'
import fs from 'node:fs'
import path from 'node:path'
import util from 'node:util'
import { expect } from 'chai'
import toString from 'stream-to-string'
import stripAnsi from 'strip-ansi'
import VError from 'verror'
import * as messages from '@cucumber/messages'
import * as messageStreams from '@cucumber/message-streams'
import FakeReportServer from '../../test/fake_report_server'
import { doesHaveValue } from '../../src/value_checker'
import util from 'node:util'
import { setWorldConstructor } from '../../'
import { IRunEnvironment, loadConfiguration, runCucumber } from '../../lib/api'
import { ArgvParser } from '../../lib/configuration'

Expand Down
2 changes: 1 addition & 1 deletion src/api/convert_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
splitFormatDescriptor,
} from '../configuration'
import { IPublishConfig } from '../formatter'
import { IRunConfiguration } from './types'
import { ILogger } from '../logger'
import { IRunConfiguration } from './types'

export async function convertConfiguration(
logger: ILogger,
Expand Down
2 changes: 1 addition & 1 deletion src/api/convert_configuration_spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, it } from 'mocha'
import { expect } from 'chai'
import { convertConfiguration } from './convert_configuration'
import { DEFAULT_CONFIGURATION } from '../configuration'
import { FakeLogger } from '../../test/fake_logger'
import { convertConfiguration } from './convert_configuration'

describe('convertConfiguration', () => {
it('should convert defaults correctly', async () => {
Expand Down
14 changes: 7 additions & 7 deletions src/api/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Formatter, { IFormatterStream } from '../formatter'
import { EventEmitter } from 'node:events'
import { EventDataCollector } from '../formatter/helpers'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import { promisify } from 'node:util'
import { WriteStream as TtyWriteStream } from 'node:tty'
import FormatterBuilder from '../formatter/builder'
import fs from 'mz/fs'
import path from 'node:path'
import { IRunOptionsFormats } from './types'
import { ILogger } from '../logger'
import fs from 'mz/fs'
import { mkdirp } from 'mkdirp'
import Formatter, { IFormatterStream } from '../formatter'
import { EventDataCollector } from '../formatter/helpers'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import FormatterBuilder from '../formatter/builder'
import { ILogger } from '../logger'
import { IRunOptionsFormats } from './types'

export async function initializeFormatters({
env,
Expand Down
2 changes: 1 addition & 1 deletion src/api/gherkin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
import { Query as GherkinQuery } from '@cucumber/gherkin-utils'
import PickleFilter from '../pickle_filter'
import { orderPickles } from '../cli/helpers'
import { ISourcesCoordinates } from './types'
import { ILogger } from '../logger'
import { ISourcesCoordinates } from './types'

interface PickleWithDocument {
gherkinDocument: GherkinDocument
Expand Down
12 changes: 6 additions & 6 deletions src/api/load_configuration.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
IRunEnvironment,
IResolvedConfiguration,
ILoadConfigurationOptions,
} from './types'
import { locateFile } from '../configuration/locate_file'
import {
DEFAULT_CONFIGURATION,
fromFile,
mergeConfigurations,
} from '../configuration'
import { validateConfiguration } from '../configuration/validate_configuration'
import { ILogger } from '../logger'
import { convertConfiguration } from './convert_configuration'
import { mergeEnvironment } from './environment'
import { ILogger } from '../logger'
import {
IRunEnvironment,
IResolvedConfiguration,
ILoadConfigurationOptions,
} from './types'
import { ConsoleLogger } from './console_logger'

/**
Expand Down
4 changes: 2 additions & 2 deletions src/api/load_sources.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IdGenerator } from '@cucumber/messages'
import { ILogger } from '../logger'
import {
ILoadSourcesResult,
IPlannedPickle,
Expand All @@ -6,11 +8,9 @@ import {
ISourcesError,
} from './types'
import { resolvePaths } from './paths'
import { IdGenerator } from '@cucumber/messages'
import { mergeEnvironment } from './environment'
import { getFilteredPicklesAndErrors } from './gherkin'
import { ConsoleLogger } from './console_logger'
import { ILogger } from '../logger'

/**
* Load and parse features, produce a filtered and ordered test plan and/or parse errors.
Expand Down
2 changes: 1 addition & 1 deletion src/api/load_sources_spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai'
import path from 'node:path'
import { PassThrough } from 'node:stream'
import { expect } from 'chai'
import fs from 'mz/fs'
import { IdGenerator } from '@cucumber/messages'
import { IRunEnvironment } from './types'
Expand Down
4 changes: 2 additions & 2 deletions src/api/load_support.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { IdGenerator } from '@cucumber/messages'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import { ILogger } from '../logger'
import { ILoadSupportOptions, IRunEnvironment } from './types'
import { resolvePaths } from './paths'
import { getSupportCodeLibrary } from './support'
import { mergeEnvironment } from './environment'
import { ISupportCodeLibrary } from '../support_code_library_builder/types'
import { ILogger } from '../logger'
import { ConsoleLogger } from './console_logger'

/**
Expand Down
4 changes: 2 additions & 2 deletions src/api/load_support_spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { IRunEnvironment } from './types'
import path from 'node:path'
import { expect } from 'chai'
import { IRunEnvironment } from './types'
import { loadSupport } from './load_support'
import { loadConfiguration } from './load_configuration'
import { expect } from 'chai'
import { setupEnvironment, teardownEnvironment } from './test_helpers'

describe('loadSupport', function () {
Expand Down
4 changes: 2 additions & 2 deletions src/api/paths.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { glob } from 'glob'
import path from 'node:path'
import { glob } from 'glob'
import fs from 'mz/fs'
import { ISourcesCoordinates, ISupportCodeCoordinates } from './types'
import { ILogger } from '../logger'
import { ISourcesCoordinates, ISupportCodeCoordinates } from './types'

export async function resolvePaths(
logger: ILogger,
Expand Down
4 changes: 2 additions & 2 deletions src/api/paths_spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { promisify } from 'node:util'
import path from 'node:path'
import tmp, { DirOptions } from 'tmp'
import fsExtra from 'fs-extra'
import path from 'node:path'
import { describe, it } from 'mocha'
import { expect } from 'chai'
import { resolvePaths } from './paths'
import { FakeLogger } from '../../test/fake_logger'
import { ILogger } from '../logger'
import { resolvePaths } from './paths'

async function buildTestWorkingDirectory(): Promise<string> {
const cwd = await promisify<DirOptions, string>(tmp.dir)({
Expand Down
2 changes: 1 addition & 1 deletion src/api/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Plugin, PluginManager } from '../plugin'
import publishPlugin from '../publish'
import { IRunEnvironment, IRunOptions } from './types'
import { ILogger } from '../logger'
import { IRunEnvironment, IRunOptions } from './types'

const INTERNAL_PLUGINS: Record<string, Plugin> = {
publish: publishPlugin,
Expand Down
Loading

0 comments on commit ef4cf5f

Please sign in to comment.