Skip to content

Commit b3b2d51

Browse files
eslint: remove globals (#1023)
1 parent 4cb47a0 commit b3b2d51

31 files changed

+73
-24
lines changed

.eslintrc.yml

-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,6 @@ env:
55
extends:
66
- standard
77
- prettier
8-
globals:
9-
afterEach: false
10-
beforeEach: false
11-
createMock: false
12-
describe: false
13-
expect: false
14-
it: false
15-
sinon: false
168
parser: babel-eslint
179
parserOptions:
1810
sourceType: module

dependency-lint.yml

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ requiredModules:
5151
- '{features,scripts,test}/**/*'
5252
- '**/*_spec.js'
5353
- 'example/index.js'
54+
- '**/test_helpers.js'
5455
ignore:
5556
- 'dist/**/*'
5657
- 'node_modules/**/*'

src/cli/configuration_builder_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import { promisify } from 'bluebird'
24
import ConfigurationBuilder from './configuration_builder'
35
import fsExtra from 'fs-extra'

src/cli/helpers_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import sinon from 'sinon'
14
import { getTestCasesFromFilesystem } from './helpers'
25
import { promisify } from 'bluebird'
36
import EventEmitter from 'events'

src/cli/option_splitter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import OptionSplitter from './option_splitter'
24

35
describe('OptionSplitter', () => {

src/cli/profile_loader_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import { promisify } from 'bluebird'
24
import fs from 'mz/fs'
35
import path from 'path'

src/formatter/helpers/issue_helpers_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import { createMock } from '../test_helpers'
14
import getColorFns from '../get_color_fns'
25
import Status from '../../status'
36
import { formatIssue } from './issue_helpers'

src/formatter/helpers/keyword_type_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import KeywordType, { getStepKeywordType } from './keyword_type'
24

35
describe('KeywordType', () => {

src/formatter/helpers/summary_helpers_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import getColorFns from '../get_color_fns'
24
import { formatSummary } from './summary_helpers'
35
import Status from '../../status'

src/formatter/helpers/usage_helpers/index_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import { getUsage } from './'
24
import EventEmitter from 'events'
35
import Gherkin from 'gherkin'

src/formatter/json_formatter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import JsonFormatter from './json_formatter'
24
import Status from '../status'
35
import EventEmitter from 'events'

src/formatter/progress_bar_formatter_spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import { createMock } from './test_helpers'
4+
import sinon from 'sinon'
15
import getColorFns from './get_color_fns'
26
import ProgressBarFormatter from './progress_bar_formatter'
37
import Status from '../status'

src/formatter/progress_formatter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import getColorFns from './get_color_fns'
24
import ProgressFormatter from './progress_formatter'
35
import Status from '../status'

src/formatter/rerun_formatter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import _ from 'lodash'
24
import path from 'path'
35
import RerunFormatter from './rerun_formatter'

src/formatter/step_definition_snippet_builder/index_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import { createMock } from '../test_helpers'
14
import { KeywordType } from '../helpers'
25
import StepDefinitionSnippetBuilder from './'
36
import TransformLookupBuilder from '../../support_code_library_builder/parameter_type_registry_builder'

src/formatter/step_definition_snippet_builder/javascript_snippet_syntax_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import JavascriptSnippetSyntax from './javascript_snippet_syntax'
24

35
describe('JavascriptSnippetSyntax', () => {

src/formatter/summary_formatter_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import { createMock } from './test_helpers'
14
import getColorFns from './get_color_fns'
25
import Status from '../status'
36
import SummaryFormatter from './summary_formatter'

src/formatter/test_helpers.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import _ from 'lodash'
2+
import sinon from 'sinon'
3+
4+
export function createMock(input) {
5+
if (_.isArray(input)) {
6+
input = _.zipObject(input)
7+
}
8+
return _.mapValues(input, value => sinon.stub().returns(value))
9+
}

src/formatter/usage_formatter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import UsageFormatter from './usage_formatter'
24
import EventEmitter from 'events'
35
import Gherkin from 'gherkin'

src/formatter/usage_json_formatter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import UsageJsonFormatter from './usage_json_formatter'
24
import EventEmitter from 'events'
35
import Gherkin from 'gherkin'

src/models/data_table_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import DataTable from './data_table'
24

35
describe('DataTable', () => {

src/models/test_case_hook_definition_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import TestCaseHookDefinition from './test_case_hook_definition'
24

35
describe('TestCaseHookDefinition', () => {

src/pickle_filter_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import PickleFilter from './pickle_filter'
24

35
describe('PickleFilter', () => {

src/runtime/attachment_manager/index_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import sinon from 'sinon'
14
import AttachmentManager from './'
25
import stream from 'stream'
36

src/runtime/helpers_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import { getAmbiguousStepException } from './helpers'
24

35
describe('Helpers', () => {

src/runtime/test_case_runner_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { afterEach, beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import sinon from 'sinon'
14
import TestCaseHookDefinition from '../models/test_case_hook_definition'
25
import TestCaseRunner from './test_case_runner'
36
import Status from '../status'

src/status_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import Status, { getStatusMapping } from './status'
24

35
describe('Status', () => {

src/support_code_library_builder/index_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
3+
import sinon from 'sinon'
14
import { ParameterTypeRegistry } from 'cucumber-expressions'
25
import supportCodeLibraryBuilder from './'
36

src/user_code_runner_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { beforeEach, describe, it } from 'mocha'
2+
import { expect } from 'chai'
13
import UserCodeRunner from './user_code_runner'
24
import Promise from 'bluebird'
35

test/listener_helpers.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { expect } from 'chai'
2+
13
export function expectToHearEvents(listener, expectedEvents) {
24
let previousStub = null
35
const callNumberMapping = {}

test/test_helper.js

-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
import _ from 'lodash'
21
import 'regenerator-runtime/runtime'
32
import chai from 'chai'
4-
import sinon from 'sinon'
53
import sinonChai from 'sinon-chai'
64

75
chai.use(sinonChai)
8-
9-
function createMock(input) {
10-
if (_.isArray(input)) {
11-
input = _.zipObject(input)
12-
}
13-
return _.mapValues(input, value => sinon.stub().returns(value))
14-
}
15-
16-
_.assign(global, {
17-
chai,
18-
createMock,
19-
expect: chai.expect,
20-
sinon
21-
})

0 commit comments

Comments
 (0)