Skip to content

Commit 5a231d3

Browse files
authored
test: extend cypress examples linting to javascript styles (#1385)
1 parent bd0ff77 commit 5a231d3

File tree

22 files changed

+395
-33
lines changed

22 files changed

+395
-33
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
/LICENSE.md
2+
3+
examples/**/*.js
4+
examples/**/*.?js

eslint.config.mjs

Lines changed: 12 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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
})
Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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
},

0 commit comments

Comments
 (0)