Skip to content

Commit 5542518

Browse files
authored
ref(dev): Run linter on scripts (#4834)
Because SDK developers running Windows [can't run our bash scripts[1], we recently decided to move to using TypeScript instead. To make this easier, this extends the domain of our `eslint` and `prettier` checks to include all `scripts` folders. It also fixes a few linting errors which doing so brought to light. [1] #4720
1 parent e134014 commit 5542518

File tree

20 files changed

+41
-47
lines changed

20 files changed

+41
-47
lines changed

.eslintrc.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,7 @@ module.exports = {
1010
ecmaVersion: 2018,
1111
},
1212
extends: ['@sentry-internal/sdk'],
13-
ignorePatterns: [
14-
'coverage/**',
15-
'build/**',
16-
'dist/**',
17-
'esm/**',
18-
'examples/**',
19-
'scripts/**',
20-
'test/manual/**',
21-
'types/**',
22-
],
13+
ignorePatterns: ['coverage/**', 'build/**', 'dist/**', 'esm/**', 'examples/**', 'test/manual/**', 'types/**'],
2314
overrides: [
2415
{
2516
files: ['*.ts', '*.tsx', '*.d.ts'],

packages/angular/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
"clean": "rimraf dist esm build coverage",
5151
"fix": "run-s fix:eslint fix:prettier",
5252
"fix:eslint": "eslint . --format stylish --fix",
53-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
53+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5454
"link:yarn": "yarn link",
5555
"lint": "run-s lint:prettier lint:eslint",
5656
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
57-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\""
57+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\""
5858
},
5959
"volta": {
6060
"extends": "../../package.json"

packages/browser/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@
6363
"clean": "rimraf build coverage .rpt2_cache",
6464
"fix": "run-s fix:eslint fix:prettier",
6565
"fix:eslint": "eslint . --format stylish --fix",
66-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
66+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
6767
"link:yarn": "yarn link",
6868
"lint": "run-s lint:prettier lint:eslint",
6969
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
70-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
70+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
7171
"size:check": "run-p size:check:es5 size:check:es6",
7272
"size:check:es5": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'",
7373
"size:check:es6": "cat build/bundles/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'",

packages/browser/scripts/checkbrowsers.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
/* eslint-disable no-console */
12
// Script which checks all browsers in test/integration/browser.js against supported BrowserStack browsers
23
// Meant to be run manually, by running `yarn test:integration:checkbrowsers` from the command line
34

45
const btoa = require('btoa');
56
const fetch = require('node-fetch');
7+
68
const localConfigs = require('../test/integration/browsers.js');
79

810
const browserstackUsername = process.env.BROWSERSTACK_USERNAME;
@@ -78,6 +80,7 @@ const checkLocalConfigsVsBrowserStack = (localConfigs, bsConfigs) => {
7880
const realMobileUpdates = [];
7981

8082
// check each local config against the entire collection of BS configs
83+
// eslint-disable-next-line guard-for-in
8184
for (const configName in localConfigs) {
8285
const localConfig = localConfigs[configName];
8386

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
"clean": "rimraf dist esm coverage",
4141
"fix": "run-s fix:eslint fix:prettier",
4242
"fix:eslint": "eslint . --format stylish --fix",
43-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
43+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
4444
"link:yarn": "yarn link",
4545
"lint": "run-s lint:prettier lint:eslint",
4646
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
47-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
47+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
4848
"test": "jest",
4949
"test:watch": "jest --watch",
5050
"version": "node ../../scripts/versionbump.js src/version.ts"

packages/gatsby/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
"clean": "rimraf dist esm build coverage",
5252
"fix": "run-s fix:eslint fix:prettier",
5353
"fix:eslint": "eslint . --format stylish --fix",
54-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
54+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5555
"link:yarn": "yarn link",
5656
"lint": "run-s lint:prettier lint:eslint",
5757
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
58-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
58+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
5959
"test": "jest",
6060
"test:watch": "jest --watch"
6161
},

packages/hub/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"clean": "rimraf dist esm coverage",
3838
"fix": "run-s fix:eslint fix:prettier",
3939
"fix:eslint": "eslint . --format stylish --fix",
40-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
40+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
4141
"link:yarn": "yarn link",
4242
"lint": "run-s lint:prettier lint:eslint",
4343
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
44-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
44+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
4545
"build:npm": "npm pack",
4646
"test": "jest",
4747
"test:watch": "jest --watch"

packages/integrations/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@
4343
"clean": "rimraf dist esm build coverage .rpt2_cache",
4444
"fix": "run-s fix:eslint fix:prettier",
4545
"fix:eslint": "eslint . --format stylish --fix",
46-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
46+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
4747
"link:yarn": "yarn link",
4848
"lint": "run-s lint:prettier lint:eslint",
4949
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
50-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
50+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
5151
"test": "jest",
5252
"test:watch": "jest --watch"
5353
},

packages/minimal/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
"clean": "rimraf dist esm coverage",
3838
"fix": "run-s fix:eslint fix:prettier",
3939
"fix:eslint": "eslint . --format stylish --fix",
40-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
40+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
4141
"link:yarn": "yarn link",
4242
"lint": "run-s lint:prettier lint:eslint",
4343
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
44-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
44+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
4545
"build:npm": "npm pack",
4646
"test": "jest",
4747
"test:watch": "jest --watch"

packages/nextjs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
"clean": "rimraf dist esm coverage *.js *.js.map *.d.ts",
6161
"fix": "run-s fix:eslint fix:prettier",
6262
"fix:eslint": "eslint . --format stylish --fix",
63-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
63+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
6464
"link:yarn": "yarn link",
6565
"lint": "run-s lint:prettier lint:eslint",
6666
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
67-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
67+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
6868
"test": "run-s test:unit",
6969
"test:all": "run-s test:unit test:integration",
7070
"test:unit": "jest",

packages/node/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
"clean": "rimraf dist esm coverage",
5252
"fix": "run-s fix:eslint fix:prettier",
5353
"fix:eslint": "eslint . --format stylish --fix",
54-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
54+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5555
"link:yarn": "yarn link",
5656
"lint": "run-s lint:prettier lint:eslint",
5757
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
58-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
58+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
5959
"test": "run-s test:jest test:express test:webpack test:release-health",
6060
"test:express": "node test/manual/express-scope-separation/start.js",
6161
"test:jest": "jest",

packages/react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
"clean": "rimraf dist esm build coverage",
6767
"fix": "run-s fix:eslint fix:prettier",
6868
"fix:eslint": "eslint . --format stylish --fix",
69-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
69+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
7070
"link:yarn": "yarn link",
7171
"lint": "run-s lint:prettier lint:eslint",
7272
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
73-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
73+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
7474
"test": "jest",
7575
"test:watch": "jest --watch"
7676
},

packages/serverless/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
"clean": "rimraf dist esm build dist-awslambda-layer coverage",
5858
"fix": "run-s fix:eslint fix:prettier",
5959
"fix:eslint": "eslint . --format stylish --fix",
60-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
60+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
6161
"link:yarn": "yarn link",
6262
"lint": "run-s lint:prettier lint:eslint",
6363
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
64-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
64+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
6565
"test": "jest",
6666
"test:watch": "jest --watch"
6767
},

packages/serverless/scripts/build-awslambda-layer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const readPkg = require('read-pkg');
1111
const serverlessPackage = require('../package.json');
1212

1313
if (!process.env.GITHUB_ACTIONS) {
14-
console.log(`Skipping build-awslambda-layer script in local environment.`);
14+
console.log('Skipping build-awslambda-layer script in local environment.');
1515
process.exit(0);
1616
}
1717

packages/tracing/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
"circularDepCheck": "madge --circular src/index.ts",
4949
"fix": "run-s fix:eslint fix:prettier",
5050
"fix:eslint": "eslint . --format stylish --fix",
51-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
51+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5252
"link:yarn": "yarn link",
5353
"lint": "run-s lint:prettier lint:eslint",
5454
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
55-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
55+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
5656
"test": "jest",
5757
"test:watch": "jest --watch"
5858
},

packages/types/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"link:yarn": "yarn link",
3333
"lint": "run-s lint:prettier lint:eslint",
3434
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
35-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
35+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
3636
"fix": "run-s fix:eslint fix:prettier",
3737
"fix:eslint": "eslint . --format stylish --fix",
38-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\""
38+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\""
3939
},
4040
"volta": {
4141
"extends": "../../package.json"

packages/utils/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
"clean": "rimraf dist esm coverage *.js *.js.map *.d.ts",
4242
"fix": "run-s fix:eslint fix:prettier",
4343
"fix:eslint": "eslint . --format stylish --fix",
44-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
44+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
4545
"link:yarn": "yarn link",
4646
"lint": "run-s lint:prettier lint:eslint",
4747
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
48-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
48+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
4949
"test": "jest",
5050
"test:watch": "jest --watch",
5151
"test:package": "node test/types/index.js"

packages/vue/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
"clean": "rimraf dist esm build coverage",
5050
"fix": "run-s fix:eslint fix:prettier",
5151
"fix:eslint": "eslint . --format stylish --fix",
52-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
52+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5353
"link:yarn": "yarn link",
5454
"lint": "run-s lint:prettier lint:eslint",
5555
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
56-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
56+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
5757
"test": "jest",
5858
"test:watch": "jest --watch"
5959
},

packages/wasm/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@
4848
"clean": "rimraf dist esm coverage *.js.map *.d.ts",
4949
"fix": "run-s fix:eslint fix:prettier",
5050
"fix:eslint": "eslint . --format stylish --fix",
51-
"fix:prettier": "prettier --write \"{src,test}/**/*.ts\"",
51+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/*.ts\"",
5252
"link:yarn": "yarn link",
5353
"lint": "run-s lint:prettier lint:eslint",
5454
"lint:eslint": "eslint . --cache --cache-location '../../eslintcache/' --format stylish",
55-
"lint:prettier": "prettier --check \"{src,test}/**/*.ts\"",
55+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/*.ts\"",
5656
"test": "node test/scripts/ensure-browser-bundle.js && cross-env PORT=1337 jest",
5757
"test:watch": "jest --watch"
5858
},

scripts/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
const { spawnSync } = require('child_process');
2-
const { join } = require('path');
1+
import { spawnSync } from 'child_process';
2+
import { join } from 'path';
33

4-
function run(cmd: string, cwd = '') {
4+
function run(cmd: string, cwd: string = '') {
55
const result = spawnSync(cmd, { shell: true, stdio: 'inherit', cwd: join(__dirname, '..', cwd || '') });
66

77
if (result.status !== 0) {
8-
process.exit(result.status);
8+
process.exit(result.status || undefined);
99
}
1010
}
1111

0 commit comments

Comments
 (0)