Skip to content

Commit 63812a5

Browse files
fix: avoid mutating eslint browser environment
2 parents a66873e + 0bd34ab commit 63812a5

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ module.exports = {
1111
},
1212
environments: {
1313
globals: {
14-
globals: Object.assign(globals.browser, globals.mocha, {
14+
globals: Object.assign({
1515
cy: false,
1616
Cypress: false,
1717
expect: false,
1818
assert: false,
1919
chai: false,
20-
}),
20+
}, globals.browser, globals.mocha),
2121
parserOptions: {
2222
ecmaVersion: 2019,
2323
sourceType: 'module',

tests/config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict'
2+
3+
const globals = require('globals')
4+
const config = require('../index.js')
5+
6+
describe('environments globals', () => {
7+
const env = config.environments.globals
8+
9+
it('should not mutate globals', () => {
10+
expect(globals.browser).not.toHaveProperty('cy')
11+
expect(globals.mocha).not.toHaveProperty('cy')
12+
});
13+
14+
it('should include other globals', () => {
15+
expect(env.globals).toEqual(expect.objectContaining(globals.browser))
16+
expect(env.globals).toEqual(expect.objectContaining(globals.mocha))
17+
});
18+
19+
it('should include cypress globals', () => {
20+
expect(env.globals).toEqual(expect.objectContaining({
21+
cy: false,
22+
Cypress: false,
23+
}))
24+
});
25+
})

0 commit comments

Comments
 (0)