Skip to content

Commit 4cb47a0

Browse files
eslint: use standard (#1022)
1 parent 81d4f3d commit 4cb47a0

File tree

68 files changed

+676
-651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+676
-651
lines changed

.eslintrc.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ env:
33
es6: true
44
node: true
55
extends:
6-
- 'eslint:recommended'
6+
- standard
77
- prettier
88
globals:
99
afterEach: false
@@ -20,17 +20,6 @@ plugins:
2020
- babel
2121
- prettier
2222
rules:
23-
babel/new-cap: error
24-
complexity: error
25-
eqeqeq: [error, always]
26-
no-await-in-loop: error
27-
no-negated-condition: error
28-
no-nested-ternary: error
29-
no-plusplus: error
30-
no-shadow: error
31-
no-unneeded-ternary: [error, {defaultAssignment: false}]
32-
no-var: error
33-
object-shorthand: [error, always]
3423
prettier/prettier:
3524
- error
3625
- trailingComma: none

dependency-lint.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ ignoreErrors:
3636
- coffee-script # features/compiler.feature
3737
- coveralls # .travis.yml
3838
- eslint-config-prettier # .eslintrc.yml - extends
39+
- eslint-config-standard # .eslintrc.yml - extends
3940
- eslint-plugin-babel # .eslintrc.yml - parser
41+
- eslint-plugin-import # peer dependency of eslint-config-standard
42+
- eslint-plugin-node # peer dependency of eslint-config-standard
4043
- eslint-plugin-prettier # .eslintrc.yml - plugins
44+
- eslint-plugin-promise # peer dependency of eslint-config-standard
45+
- eslint-plugin-standard # peer dependency of eslint-config-standard
4146
- prettier # peer dependency of eslint-plugin-prettier
4247

4348
requiredModules:

example/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function runFeature() {
1313
eventBroadcaster
1414
)
1515

16-
let featureSource = featureEditor.getValue()
16+
const featureSource = featureEditor.getValue()
1717
const testCases = Cucumber.getTestCases({
1818
eventBroadcaster,
1919
pickleFilter: new Cucumber.PickleFilter({}),
@@ -22,10 +22,10 @@ function runFeature() {
2222
})
2323

2424
Cucumber.supportCodeLibraryBuilder.reset('')
25-
new Function(stepDefinitionsEditor.getValue())()
26-
let supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize()
25+
new Function(stepDefinitionsEditor.getValue())() // eslint-disable-line no-new-func
26+
const supportCodeLibrary = Cucumber.supportCodeLibraryBuilder.finalize()
2727

28-
let formatterOptions = {
28+
const formatterOptions = {
2929
colorsEnabled: true,
3030
cwd: '/',
3131
eventBroadcaster,
@@ -37,7 +37,7 @@ function runFeature() {
3737
}
3838
Cucumber.FormatterBuilder.build('progress', formatterOptions)
3939

40-
let runtime = new Cucumber.Runtime({
40+
const runtime = new Cucumber.Runtime({
4141
eventBroadcaster,
4242
options: {},
4343
testCases,
@@ -52,12 +52,12 @@ function appendToOutput(data) {
5252
}
5353

5454
function displayError(error) {
55-
let errorContainer = $('<div>')
55+
const errorContainer = $('<div>')
5656
errorContainer.addClass('error').text(error.stack || error)
5757
appendToOutput(errorContainer)
5858
}
5959

60-
$(function() {
60+
$(() => {
6161
featureEditor = ace.edit('feature')
6262
featureEditor.getSession().setMode('ace/mode/gherkin')
6363

@@ -68,14 +68,14 @@ $(function() {
6868

6969
window.onerror = displayError
7070

71-
$('#run-feature').click(function() {
71+
$('#run-feature').click(() => {
7272
runFeature()
73-
.then(function(success) {
74-
let exitStatus = success ? '0' : '1'
75-
let exitStatusContainer = $('<div>')
73+
.then(success => {
74+
const exitStatus = success ? '0' : '1'
75+
const exitStatusContainer = $('<div>')
7676
exitStatusContainer
7777
.addClass('exit-status')
78-
.text('Exit Status: ' + exitStatus)
78+
.text(`Exit Status: ${exitStatus}`)
7979
appendToOutput(exitStatusContainer)
8080
})
8181
.catch(displayError)

features/step_definitions/cli_steps.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ When(
2020
function(location) {
2121
if (location === 'locally') {
2222
return this.run(this.localExecutablePath, [])
23-
} else {
24-
return this.run(this.globalExecutablePath, [])
2523
}
24+
return this.run(this.globalExecutablePath, [])
2625
}
2726
)
2827

29-
Then(/^it passes$/, function() {})
28+
Then(/^it passes$/, () => {})
3029

3130
Then(/^it fails$/, function() {
3231
const actualCode = this.lastRun.error ? this.lastRun.error.code : 0
@@ -69,7 +68,7 @@ Then(/^the error output contains the text:$/, function(text) {
6968
Then(/^I see the version of Cucumber$/, function() {
7069
const version = require('../../package.json').version
7170
const actualOutput = this.lastRun.output
72-
const expectedOutput = version + '\n'
71+
const expectedOutput = `${version}\n`
7372
expect(actualOutput).to.eql(expectedOutput)
7473
})
7574

features/step_definitions/file_steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Given(/^a directory named "(.*)"$/, function(filePath) {
2929

3030
Given(/^"([^"]*)" is an absolute path$/, function(filePath) {
3131
filePath = Mustache.render(filePath, this)
32-
expect(path.isAbsolute(filePath)).to.be.true
32+
expect(path.isAbsolute(filePath)).to.eql(true)
3333
})
3434

3535
Then(/^the file "([^"]*)" has the text:$/, async function(filePath, text) {

features/step_definitions/json_output_steps.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ Then(/^the scenario "([^"]*)" has the steps$/, function(name, table) {
3636
scenarioPredicate: ['name', name]
3737
})
3838
const expectedNames = table.rows().map(row => row[0])
39-
const actualNames = scenario.steps.map(function(step) {
40-
return _.compact([step.keyword, step.name]).join('')
41-
})
39+
const actualNames = scenario.steps.map(step =>
40+
_.compact([step.keyword, step.name]).join('')
41+
)
4242
expect(actualNames).to.eql(expectedNames)
4343
})
4444

@@ -109,9 +109,7 @@ Then(/^the (first|second) scenario has the steps$/, function(cardinal, table) {
109109
features: this.lastRun.jsonOutput,
110110
scenarioPredicate: (element, index) => index === scenarioIndex
111111
})
112-
const stepNames = scenario.steps.map(function(step) {
113-
return [step.name]
114-
})
112+
const stepNames = scenario.steps.map(step => [step.name])
115113
expect(stepNames).to.eql(table.rows())
116114
})
117115

@@ -141,9 +139,7 @@ Then(
141139
},
142140
stepPredicate: ['name', name]
143141
})
144-
const expected = table.raw().map(function(row) {
145-
return { cells: row }
146-
})
142+
const expected = table.raw().map(row => ({ cells: row }))
147143
expect(step.arguments[0].rows).to.eql(expected)
148144
}
149145
)

features/step_definitions/usage_json_steps.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import path from 'path'
88
Then('it outputs the usage data:', function(table) {
99
const usageData = JSON.parse(this.lastRun.output)
1010
table.hashes().forEach(row => {
11-
const rowUsage = _.find(usageData, datum => {
12-
return datum.pattern === row['PATTERN']
13-
})
14-
expect(rowUsage).to.exist
15-
expect(rowUsage.line).to.eql(parseInt(row['LINE']))
11+
const rowUsage = _.find(usageData, datum => datum.pattern === row.PATTERN)
12+
expect(rowUsage).to.be.an('object')
13+
expect(rowUsage.line).to.eql(parseInt(row.LINE))
1614
expect(rowUsage.matches).to.have.lengthOf(row['NUMBER OF MATCHES'])
17-
expect(rowUsage.uri).to.eql(path.normalize(row['URI']))
15+
expect(rowUsage.uri).to.eql(path.normalize(row.URI))
1816
})
1917
})

features/support/event_protocol_output_helpers.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import path from 'path'
33
export function normalizeEventProtocolOutput(str) {
44
return str
55
.replace(/"duration":\d*/g, '"duration":0')
6-
.replace(/"uri":"([^"]*)"/g, (match, uri) => {
7-
return `"uri":"${path.normalize(uri)}"`
8-
})
6+
.replace(
7+
/"uri":"([^"]*)"/g,
8+
(match, uri) => `"uri":"${path.normalize(uri)}"`
9+
)
910
}

features/support/hooks.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,8 @@ Before('@global-install', function() {
8989
After(function() {
9090
if (this.lastRun.error && !this.verifiedLastRunError) {
9191
throw new Error(
92-
'Last run errored unexpectedly. Output:\n\n' +
93-
this.lastRun.output +
94-
'\n\n' +
95-
'Error Output:\n\n' +
96-
this.lastRun.errorOutput
92+
`Last run errored unexpectedly. Output:\n\n${this.lastRun.output}\n\n` +
93+
`Error Output:\n\n${this.lastRun.errorOutput}`
9794
)
9895
}
9996
})

features/support/json_output_helpers.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ export function findScenario({ features, scenarioPredicate }) {
2626
.value()
2727
if (scenario) {
2828
return scenario
29-
} else {
30-
throw new Error('Could not find scenario matching predicate')
3129
}
30+
throw new Error('Could not find scenario matching predicate')
3231
}
3332

3433
export function findStep({ features, stepPredicate, scenarioPredicate }) {
@@ -46,17 +45,16 @@ export function findStep({ features, stepPredicate, scenarioPredicate }) {
4645
const step = _.find(steps, stepPredicate)
4746
if (step) {
4847
return step
49-
} else {
50-
throw new Error(
51-
`Could not find step matching predicate: ${util.inspect(features, {
52-
depth: null
53-
})}`
54-
)
5548
}
49+
throw new Error(
50+
`Could not find step matching predicate: ${util.inspect(features, {
51+
depth: null
52+
})}`
53+
)
5654
}
5755

5856
export function neutraliseVariableValues(report) {
59-
report.forEach(function(item) {
57+
report.forEach(item => {
6058
;(item.elements || []).forEach(element => {
6159
;(element.steps || []).forEach(step => {
6260
if ('result' in step) {

0 commit comments

Comments
 (0)