Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run eslint on the scripts directory #1529

Merged
merged 7 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: RxPlayer Tests

on:
Expand Down Expand Up @@ -29,7 +26,7 @@ jobs:
with:
toolchain: stable

- run: npm install
- run: npm ci
- run: rustup target add wasm32-unknown-unknown
- run: npm run fmt:prettier:check
- run: npm run fmt:rust:check
Expand All @@ -49,7 +46,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm install
- run: npm ci
- run: npm run check

unit_tests:
Expand All @@ -67,7 +64,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm install
- run: npm ci
- run: npm run test:unit

integration_linux:
Expand All @@ -89,7 +86,7 @@ jobs:
- run:
sudo add-apt-repository multiverse && sudo apt update && sudo apt install -y
ubuntu-restricted-extras
- run: npm install
- run: npm ci
- run: npm run build
- run: npm run test:integration

Expand All @@ -112,5 +109,5 @@ jobs:
- run:
sudo add-apt-repository multiverse && sudo apt update && sudo apt install -y
ubuntu-restricted-extras
- run: npm install
- run: npm ci
- run: npm run test:memory
26 changes: 26 additions & 0 deletions .github/workflows/demo_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: RxPlayer Demo Checks

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- demo/**

jobs:
scripts_lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run check:demo
2 changes: 1 addition & 1 deletion .github/workflows/perfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- run:
sudo add-apt-repository multiverse && sudo apt update && sudo apt install -y
ubuntu-restricted-extras
- run: npm install
- run: npm ci
- run: export DISPLAY=:99
- run: sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional
- run: node tests/performance/run.mjs
26 changes: 26 additions & 0 deletions .github/workflows/script_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: RxPlayer Script Checks

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- scripts/**

jobs:
scripts_lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run lint:scripts
26 changes: 26 additions & 0 deletions .github/workflows/tests_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: RxPlayer Tests Checks

on:
pull_request:
types: [opened, synchronize, reopened]
paths:
- tests/**

jobs:
tests_lint:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run lint:tests
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
Loading