Skip to content

Commit 0265cf7

Browse files
committed
Run eslint on the scripts directory
I noticed that the `scripts` directory, which begins to have a lot of files as we automate more tasks (like #1524), wasn't linted. That directory contains code in two languages BASH and JS (Node.js), with a move to prefer JS files (as it's a JS/TS project). So I chose to add an `.eslintrc.js` file (which is a deprecated format but I couldn't make the new one work) and lint script on that directory. I subsequently fixed some linting errors. For now, that script isn't run by our GitHub actions, I will see whether we can do an intelligent kind of runner which detects if scripts have been updated.
1 parent 7277ee9 commit 0265cf7

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
"bundle:watch": "./scripts/run_bundler.mjs src/index.ts --production-mode -o dist/rx-player.js --watch",
152152
"certificate": "./scripts/generate_certificate",
153153
"check": "npm run check:types && npm run lint && npm run check:types:unit_tests",
154-
"check:all": "npm run check:types && npm run lint && npm run lint:demo && npm run lint:tests && npm run test:unit && npm run test:integration && npm run test:memory && node -r esm ./scripts/check_nodejs_import_compatibility.js",
154+
"check:all": "npm run check:types && npm run lint && npm run lint:demo && npm run lint:tests && npm run lint:scripts && npm run test:unit && npm run test:integration && npm run test:memory && node -r esm ./scripts/check_nodejs_import_compatibility.js",
155155
"check:demo": "npm run check:demo:types && npm run lint:demo",
156156
"check:demo:types": "tsc --noEmit --project demo/",
157157
"clean:build": "scripts/remove_dir.mjs dist",
@@ -169,6 +169,7 @@
169169
"fmt:rust:check": "cd ./src/parsers/manifest/dash/wasm-parser && cargo fmt --check",
170170
"lint": "eslint src -c .eslintrc.js",
171171
"lint:demo": "eslint -c demo/.eslintrc.js demo/scripts",
172+
"lint:scripts": "eslint -c scripts/.eslintrc.js --ext .js --ext .mjs --ext .cjs scripts",
172173
"lint:tests": "eslint tests/**/*.js --ignore-pattern '/tests/performance/bundle*'",
173174
"list": "node scripts/list-npm-scripts.mjs",
174175
"prepublishOnly": "npm run build:all",

scripts/.eslintrc.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
ecmaVersion: 2020,
5+
sourceType: "module",
6+
},
7+
env: {
8+
es6: true,
9+
node: true,
10+
commonjs: true,
11+
},
12+
extends: ["prettier"],
13+
rules: {
14+
"comma-dangle": [1, "only-multiline"],
15+
"no-cond-assign": 0,
16+
"no-constant-condition": 0,
17+
"no-control-regex": 0,
18+
"no-debugger": 2,
19+
"no-dupe-args": 2,
20+
"no-dupe-keys": 2,
21+
"no-duplicate-case": 1,
22+
"no-empty-character-class": 1,
23+
"no-empty": 0,
24+
"no-ex-assign": 1,
25+
"no-extra-boolean-cast": 1,
26+
"no-extra-parens": [1, "functions"],
27+
"no-extra-semi": 2,
28+
"no-func-assign": 2,
29+
"no-inner-declarations": 0,
30+
"no-invalid-regexp": 1,
31+
"no-irregular-whitespace": 1,
32+
"no-negated-in-lhs": 2,
33+
"no-obj-calls": 2,
34+
"no-regex-spaces": 1,
35+
"no-sparse-arrays": 2,
36+
"no-unreachable": 2,
37+
"use-isnan": 2,
38+
"valid-jsdoc": 0,
39+
"valid-typeof": 2,
40+
"no-unexpected-multiline": 0,
41+
"no-trailing-spaces": 2,
42+
"no-multiple-empty-lines": 1,
43+
"accessor-pairs": [1, { setWithoutGet: true }],
44+
"block-scoped-var": 1,
45+
complexity: 0,
46+
curly: [1, "all"],
47+
"no-case-declarations": 0,
48+
"no-var": 1,
49+
"prefer-const": 1,
50+
"linebreak-style": [1, "unix"],
51+
semi: [1, "always"],
52+
},
53+
};

scripts/run_bundler.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,18 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
6262
}
6363

6464
try {
65-
await runBundler(normalizedPath, {
65+
runBundler(normalizedPath, {
6666
watch: shouldWatch,
6767
minify: shouldMinify,
6868
production,
6969
silent,
7070
outfile,
71+
}).catch((err) => {
72+
console.error(`ERROR: ${err}\n`);
73+
process.exit(1);
7174
});
7275
} catch (err) {
7376
console.error(`ERROR: ${err}\n`);
74-
displayHelp();
7577
process.exit(1);
7678
}
7779
}

0 commit comments

Comments
 (0)