Skip to content

Commit 4ec5777

Browse files
committed
test: extend cypress examples linting to javascript styles
1 parent bd0ff77 commit 4ec5777

22 files changed

+395
-33
lines changed

.prettierignore

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/LICENSE.md
2+
3+
examples/**/*.js
4+
examples/**/*.?js

eslint.config.mjs

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import globals from 'globals'
22
import pluginJs from '@eslint/js'
33
import pluginCypress from 'eslint-plugin-cypress/flat'
4+
import stylistic from '@stylistic/eslint-plugin'
45

56
export default [
67
pluginJs.configs.recommended,
@@ -17,5 +18,16 @@ export default [
1718
...globals.node
1819
}
1920
}
21+
},
22+
{
23+
name: 'examples-style',
24+
files: ['examples/**/*.js'],
25+
...stylistic.configs.recommended,
26+
rules: {
27+
'@stylistic/indent': ['error', 2],
28+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
29+
'@stylistic/quotes': ['error', 'single'],
30+
'@stylistic/semi': ['error', 'never'],
31+
}
2032
}
2133
]

examples/browser/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = defineConfig({
2323
log(message) {
2424
console.log(message)
2525
return null
26-
}
26+
},
2727
})
2828
},
2929
supportFile: false,

examples/browser/cypress/e2e/spec.cy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ it('works', () => {
1313
// log the top window's dimensions
1414
const resolution = Cypress._.pick(top, [
1515
'innerWidth',
16-
'innerHeight'
16+
'innerHeight',
1717
])
1818
cy.task(
1919
'log',
20-
`top window inner w, h is ${resolution.innerWidth}x${resolution.innerHeight}`
20+
`top window inner w, h is ${resolution.innerWidth}x${resolution.innerHeight}`,
2121
)
2222
})
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { defineConfig } from "cypress";
1+
import { defineConfig } from 'cypress'
22

33
export default defineConfig({
44
component: {
55
devServer: {
6-
framework: "react",
7-
bundler: "vite",
6+
framework: 'react',
7+
bundler: 'vite',
88
},
99
},
10-
});
10+
})

examples/config/cypress.config-alternate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ module.exports = defineConfig({
77
setupNodeEvents() {
88
console.log('\nUsing cypress.config-alternate.js config-file')
99
},
10-
supportFile: false
10+
supportFile: false,
1111
},
1212
})

examples/config/cypress/e2e/spec-a.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
describe('Example config A', () => {
33
it('has baseUrl', () => {
44
expect(Cypress.config('baseUrl')).to.equal(
5-
'http://localhost:3333'
5+
'http://localhost:3333',
66
)
77
})
88

examples/config/cypress/e2e/spec-b.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
describe('Example config B', () => {
33
it('has baseUrl', () => {
44
expect(Cypress.config('baseUrl')).to.equal(
5-
'http://localhost:3333'
5+
'http://localhost:3333',
66
)
77
})
88

examples/custom-command/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const fs = require('fs')
66

77
cypress.run().then(results => {
88
const summary = _.pickBy(results, (value, key) =>
9-
key.startsWith('total')
9+
key.startsWith('total'),
1010
)
1111
console.log(summary)
1212
fs.writeFileSync(
1313
'results.json',
1414
JSON.stringify(summary, null, 2) + '\n',
15-
'utf8'
15+
'utf8',
1616
)
1717
console.log('saved file results.json')
1818
})

examples/env/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = defineConfig({
77
console.log('logging from cypress.config.js')
88
console.log(
99
'process.env.CYPRESS_environmentName',
10-
process.env.CYPRESS_environmentName
10+
process.env.CYPRESS_environmentName,
1111
)
1212
console.log('entire config.env', config.env)
1313
},

examples/env/cypress/e2e/spec.cy.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ it('has all expected env variables', () => {
22
// environmentName is set as workflow environment variable
33
// as a precaution we can confirm the variable was set
44
expect(Cypress.env('environmentName'), 'environment').to.be.a(
5-
'string'
5+
'string',
66
)
77
// and we can confirm its value
88
expect(
99
Cypress.env('environmentName'),
10-
'environment name is staging'
10+
'environment name is staging',
1111
).to.equal('staging')
1212

1313
// host and port are set via action's "with: env:" parameter
1414
expect(Cypress.env(), 'full env includes API info').to.deep.include(
1515
{
1616
host: 'http://api.dev.local',
17-
apiPort: 4222
18-
}
17+
apiPort: 4222,
18+
},
1919
)
2020
// we can confirm that host is an url
2121
expect(Cypress.env('host'), 'host is an URL').to.match(
22-
/^https?:\/\//
22+
/^https?:\/\//,
2323
)
2424
})

examples/env/cypress/e2e/without-env.cy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ it('has all expected env variables', () => {
22
// environmentName is set as workflow environment variable
33
expect(
44
Cypress.env('environmentName'),
5-
'has environment name'
5+
'has environment name',
66
).to.equal('staging')
77
})

examples/nextjs/cypress.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
const { defineConfig } = require("cypress");
1+
const { defineConfig } = require('cypress')
22

33
module.exports = defineConfig({
44
fixturesFolder: false,
55
e2e: {
66
supportFile: false,
77
baseUrl: 'http://localhost:3000',
88
},
9-
});
9+
})

examples/quiet/cypress.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = defineConfig({
88
log(message) {
99
console.log(message)
1010
return null
11-
}
11+
},
1212
})
1313
},
1414
supportFile: false,

examples/quiet/cypress/e2e/spec.cy.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ it('works', () => {
1313
// log the top window's dimensions
1414
const resolution = Cypress._.pick(top, [
1515
'innerWidth',
16-
'innerHeight'
16+
'innerHeight',
1717
])
1818
cy.task(
1919
'log',
20-
`top window inner w, h is ${resolution.innerWidth}x${resolution.innerHeight}`
20+
`top window inner w, h is ${resolution.innerWidth}x${resolution.innerHeight}`,
2121
)
2222
})

examples/wait-on/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ const arg = require('arg')
99

1010
const args = arg({
1111
'--port': Number,
12-
'--delay': Number
12+
'--delay': Number,
1313
})
1414
const port = args['--port'] || 3050
1515
const createServerAfterSeconds = args['--delay'] || 7
1616

1717
log(
1818
'starting the server at port %d after %d seconds',
1919
port,
20-
createServerAfterSeconds
20+
createServerAfterSeconds,
2121
)
2222

2323
setTimeout(function () {

examples/wait-on/index2.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const arg = require('arg')
99

1010
const args = arg({
1111
'--port': Number,
12-
'--delay': Number
12+
'--delay': Number,
1313
})
1414
const port = args['--port'] || 3050
1515
const errorPeriodSeconds = args['--delay'] || 10

examples/wait-on/index3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const arg = require('arg')
99

1010
const args = arg({
1111
'--port': Number,
12-
'--delay': Number
12+
'--delay': Number,
1313
})
1414
const port = args['--port'] || 3050
1515
const errorPeriodSeconds = args['--delay'] || 40

examples/wait-on/index4.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const http = require('http')
88
const arg = require('arg')
99

1010
const args = arg({
11-
'--port': Number
11+
'--port': Number,
1212
})
1313
const port = args['--port'] || 3050
1414

examples/webpack/webpack.config.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module.exports = {
33
entry: './src/index.js',
44
output: {
55
filename: 'bundle.js',
6-
path: path.resolve(__dirname, 'dist')
6+
path: path.resolve(__dirname, 'dist'),
77
},
88
devServer: {
99
static: {
10-
directory: __dirname
11-
}
10+
directory: __dirname,
11+
},
1212
},
13-
mode: 'development'
13+
mode: 'development',
1414
}

0 commit comments

Comments
 (0)