Skip to content

Commit

Permalink
Run eslint on the scripts directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
peaBerberian committed Sep 4, 2024
1 parent e5894f8 commit 97b1d5f
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
2 changes: 0 additions & 2 deletions demo/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module.exports = {
env: {
es6: true,
browser: true,
commonjs: true,
mocha: true,
},

globals: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"bundle:watch": "./scripts/run_bundler.mjs src/index.ts --production-mode -o dist/rx-player.js --watch",
"certificate": "./scripts/generate_certificate",
"check": "npm run check:types && npm run lint && npm run check:types:unit_tests",
"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",
"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",
"check:demo": "npm run check:demo:types && npm run lint:demo",
"check:demo:types": "tsc --noEmit --project demo/",
"clean:build": "scripts/remove_dir.mjs dist",
Expand All @@ -169,6 +169,7 @@
"fmt:rust:check": "cd ./src/parsers/manifest/dash/wasm-parser && cargo fmt --check",
"lint": "eslint src -c .eslintrc.js",
"lint:demo": "eslint -c demo/.eslintrc.js demo/scripts",
"lint:scripts": "eslint -c scripts/.eslintrc.js --ext .js --ext .mjs --ext .cjs scripts",
"lint:tests": "eslint tests/**/*.js --ignore-pattern '/tests/performance/bundle*'",
"list": "node scripts/list-npm-scripts.mjs",
"prepublishOnly": "npm run build:all",
Expand Down
53 changes: 53 additions & 0 deletions scripts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
},
env: {
es6: true,
node: true,
commonjs: true,
},
extends: ["prettier"],
rules: {
"comma-dangle": [1, "only-multiline"],
"no-cond-assign": 0,
"no-constant-condition": 0,
"no-control-regex": 0,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 1,
"no-empty-character-class": 1,
"no-empty": 0,
"no-ex-assign": 1,
"no-extra-boolean-cast": 1,
"no-extra-parens": [1, "functions"],
"no-extra-semi": 2,
"no-func-assign": 2,
"no-inner-declarations": 0,
"no-invalid-regexp": 1,
"no-irregular-whitespace": 1,
"no-negated-in-lhs": 2,
"no-obj-calls": 2,
"no-regex-spaces": 1,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-jsdoc": 0,
"valid-typeof": 2,
"no-unexpected-multiline": 0,
"no-trailing-spaces": 2,
"no-multiple-empty-lines": 1,
"accessor-pairs": [1, { setWithoutGet: true }],
"block-scoped-var": 1,
complexity: 0,
curly: [1, "all"],
"no-case-declarations": 0,
"no-var": 1,
"prefer-const": 1,
"linebreak-style": [1, "unix"],
semi: [1, "always"],
},
};
6 changes: 4 additions & 2 deletions scripts/run_bundler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
}

try {
await runBundler(normalizedPath, {
runBundler(normalizedPath, {
watch: shouldWatch,
minify: shouldMinify,
production,
silent,
outfile,
}).catch((err) => {
console.error(`ERROR: ${err}\n`);
process.exit(1);
});
} catch (err) {
console.error(`ERROR: ${err}\n`);
displayHelp();
process.exit(1);
}
}
Expand Down

0 comments on commit 97b1d5f

Please sign in to comment.