Skip to content

Commit b558680

Browse files
chore: add eslint linting for JavaScript (#1323)
Co-authored-by: Jennifer Shehane <[email protected]>
1 parent 9b8ffb3 commit b558680

File tree

12 files changed

+1552
-39
lines changed

12 files changed

+1552
-39
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
/browsers
55
/included
66
/factory/test-project
7+
8+
**/*.js

circle.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ commands:
5050
fi
5151
5252
jobs:
53+
lint:
54+
machine:
55+
image: ubuntu-2204:2024.11.1
56+
steps:
57+
- checkout
58+
- run: npm ci
59+
- run: npm run lint
5360
check-factory-versions:
5461
machine:
5562
image: ubuntu-2204:2024.11.1
@@ -238,6 +245,7 @@ jobs:
238245
workflows:
239246
test:
240247
jobs:
248+
- lint
241249
- check-factory-versions
242250
- check-node-override-version
243251
- test-image:

eslint.config.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import globals from 'globals'
2+
import pluginJs from '@eslint/js'
3+
import pluginCypress from 'eslint-plugin-cypress/flat'
4+
import stylistic from '@stylistic/eslint-plugin'
5+
6+
export default [
7+
{ languageOptions: { globals: globals.node } },
8+
pluginJs.configs.recommended,
9+
pluginCypress.configs.recommended,
10+
stylistic.configs.recommended,
11+
{ ignores: ['factory/test-project/**/*.js'] },
12+
{
13+
rules: {
14+
'@stylistic/indent': ['error', 2],
15+
'@stylistic/comma-dangle': ['error', 'always-multiline'],
16+
'@stylistic/quotes': ['error', 'single'],
17+
'@stylistic/semi': ['error', 'never'],
18+
},
19+
},
20+
]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { defineConfig } = require('cypress');
1+
const { defineConfig } = require('cypress')
22

33
module.exports = defineConfig({
44
downloadsFolder: '/tmp/cypress/downloads',
@@ -8,4 +8,4 @@ module.exports = defineConfig({
88
e2e: {
99
supportFile: false,
1010
},
11-
});
11+
})
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
#!/usr/bin/node
2-
const { spawn } = require('child_process');
2+
const { spawn } = require('child_process')
33

44
const chromeVersion = process.argv.slice(2)[0]
55

66
if (!chromeVersion) {
77
console.log('No Chrome version provided, skipping Chrome install')
8-
return
8+
process.exit(0)
99
}
1010

1111
if (process.arch !== 'x64') {
1212
console.log('Not downloading Chrome since we are not on x64. For arm64 status see https://crbug.com/677140')
13-
return;
13+
process.exit(0)
1414
}
1515

1616
console.log('Installing Chrome version: ', chromeVersion)
1717

1818
// Insert logic here if needed to run a different install script based on chrome version.
19-
const install = spawn(`${__dirname}/default.sh`, [chromeVersion], {stdio: 'inherit'})
19+
const install = spawn(`${__dirname}/default.sh`, [chromeVersion], { stdio: 'inherit' })
2020

2121
install.on('error', function (error) {
2222
console.log('child process errored with ' + error.toString())
2323
process.exit(1)
24-
});
24+
})
2525

2626
install.on('exit', function (code) {
2727
console.log('child process exited with code ' + code.toString())
2828
process.exit(code)
29-
});
29+
})
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
#!/usr/bin/node
2-
const { spawn } = require('child_process');
2+
const { spawn } = require('child_process')
33

44
const cypressVersion = process.argv.slice(2)[0]
55

66
if (!cypressVersion) {
77
console.log('No Cypress version provided, skipping Cypress install')
8-
return
8+
process.exit(0)
99
}
1010

1111
console.log('Installing Cypress version ', cypressVersion)
1212

1313
// Insert logic here if needed to run a different install script based on cypress version.
14-
const install = spawn(`${__dirname}/default.sh`, [cypressVersion], {stdio: 'inherit'})
14+
const install = spawn(`${__dirname}/default.sh`, [cypressVersion], { stdio: 'inherit' })
1515

1616
install.on('error', function (error) {
1717
console.log('child process errored with ' + error.toString())
1818
process.exit(1)
19-
});
19+
})
2020

2121
install.on('exit', function (code) {
2222
console.log('child process exited with code ' + code.toString())
2323
process.exit(code)
24-
});
24+
})
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
#!/usr/bin/node
2-
const { spawn } = require('child_process');
2+
const { spawn } = require('child_process')
33

44
const edgeVersion = process.argv.slice(2)[0]
55

66
if (!edgeVersion) {
77
console.log('No Edge version provided, skipping Edge install')
8-
return
8+
process.exit(0)
99
}
1010

1111
if (process.arch !== 'x64') {
1212
console.log('Not downloading Edge since we are not on x64. For arm64 status see https://techcommunity.microsoft.com/t5/discussions/edge-for-linux-arm64/m-p/1532272')
13-
return;
13+
process.exit(0)
1414
}
1515

1616
console.log('Installing Edge version: ', edgeVersion)
1717

1818
// Insert logic here if needed to run a different install script based on edge version.
19-
const install = spawn(`${__dirname}/default.sh`, [edgeVersion], {stdio: 'inherit'})
19+
const install = spawn(`${__dirname}/default.sh`, [edgeVersion], { stdio: 'inherit' })
2020

2121
install.on('error', function (error) {
2222
console.log('child process errored with ' + error.toString())
2323
process.exit(1)
24-
});
24+
})
2525

2626
install.on('exit', function (code) {
2727
console.log('child process exited with code ' + code.toString())
2828
process.exit(code)
29-
});
29+
})

factory/installScripts/firefox/install-firefox-version.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/node
2-
const { spawn } = require('child_process');
2+
const { spawn } = require('child_process')
33

44
const firefoxVersion = process.argv.slice(2)[0]
55

66
if (!firefoxVersion) {
77
console.log('No Firefox version provided, skipping Firefox install')
8-
return
8+
process.exit(0)
99
}
1010

1111
const architecture = process.arch
@@ -22,22 +22,23 @@ switch (architecture) {
2222
}
2323
else {
2424
console.log(`Firefox ${firefoxVersion} not available for arm64, minimum 136.0 required, skipping download`)
25-
return
25+
process.exit(0)
2626
}
27+
// eslint-disable-next-line no-fallthrough
2728
default:
2829
console.log(`Unsupported architecture ${architecture} for Firefox, skipping download`)
29-
return
30+
process.exit(0)
3031
}
3132

3233
console.log(`Installing Firefox version ${firefoxVersion} for ${architecture}`)
3334

3435
// Change in compression from bz2 to xz in Firefox 135.0
3536
// See https://www.mozilla.org/en-US/firefox/135.0/releasenotes/
3637

37-
let compression = `bz2`
38+
let compression = 'bz2'
3839

3940
if (firefoxVersion >= '135.0') {
40-
compression = `xz`
41+
compression = 'xz'
4142
}
4243

4344
// Insert logic here if needed to run a different install script based on chrome version.
@@ -46,9 +47,9 @@ const install = spawn(`${__dirname}/default.sh`, [firefoxVersion, compression, p
4647
install.on('error', function (error) {
4748
console.log('child process errored with ' + error.toString())
4849
process.exit(1)
49-
});
50+
})
5051

5152
install.on('exit', function (code) {
5253
console.log('child process exited with code ' + code.toString())
5354
process.exit(code)
54-
});
55+
})
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
#!/usr/bin/node
2-
const { spawn } = require('child_process');
2+
const { spawn } = require('child_process')
33

44
const webkitVersion = process.argv.slice(2)[0]
55

66
if (!webkitVersion) {
77
console.log('No Webkit version provided, skipping Webkit install')
8-
return
8+
process.exit(0)
99
}
1010

1111
if (!['arm64', 'x64'].includes(process.arch)) {
1212
console.log(`Not downloading Webkit since we are on ${process.arch}`)
13-
return;
13+
process.exit(0)
1414
}
1515

1616
console.log('Installing Webkit version: ', webkitVersion)
1717

1818
// Insert logic here if needed to run a different install script based on webkit version.
19-
const install = spawn(`${__dirname}/default.sh`, [webkitVersion], {stdio: 'inherit'})
19+
const install = spawn(`${__dirname}/default.sh`, [webkitVersion], { stdio: 'inherit' })
2020

2121
install.on('error', function (error) {
2222
console.log('child process errored with ' + error.toString())
2323
process.exit(1)
24-
});
24+
})
2525

2626
install.on('exit', function (code) {
2727
console.log('child process exited with code ' + code.toString())
2828
process.exit(code)
29-
});
29+
})
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/usr/bin/node
2-
const { spawn } = require('child_process');
2+
const { spawn } = require('child_process')
33

44
const yarnVersion = process.argv.slice(2)[0]
55

66
if (!yarnVersion) {
77
console.log('No Yarn version provided, skipping Yarn install')
8-
return
8+
process.exit(0)
99
}
1010

1111
if (yarnVersion >= '2') {
@@ -16,14 +16,14 @@ if (yarnVersion >= '2') {
1616
console.log('Installing Yarn version: ', yarnVersion)
1717

1818
// Insert logic here if needed to run a different install script based on version.
19-
const install = spawn(`${__dirname}/default.sh`, [yarnVersion], {stdio: 'inherit'})
19+
const install = spawn(`${__dirname}/default.sh`, [yarnVersion], { stdio: 'inherit' })
2020

2121
install.on('error', function (error) {
2222
console.log('child process errored with ' + error.toString())
2323
process.exit(1)
24-
});
24+
})
2525

2626
install.on('exit', function (code) {
2727
console.log('child process exited with code ' + code.toString())
2828
process.exit(code)
29-
});
29+
})

0 commit comments

Comments
 (0)