From e20edcc4da87d5a87bd19116293960287a6f77f1 Mon Sep 17 00:00:00 2001 From: Izuco <57068530+izu-co@users.noreply.github.com> Date: Tue, 6 Jul 2021 16:31:57 +0200 Subject: [PATCH] Added style checks --- .eslintrc.js | 34 ++++++++++++++++++++++++++++++++++ .eslintrc.yml | 27 --------------------------- .github/workflows/eslint.yml | 24 ++++++++++++++++++++++++ funi.js | 33 +-------------------------------- modules/merger.js | 1 - package.json | 1 + 6 files changed, 60 insertions(+), 60 deletions(-) create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.yml create mode 100644 .github/workflows/eslint.yml diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..1d3c968 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,34 @@ +module.exports = { + 'env': { + 'commonjs': true, + 'es2021': true, + 'node': true + }, + 'extends': 'eslint:recommended', + 'parserOptions': { + 'ecmaVersion': 12 + }, + 'rules': { + 'no-empty': [ + 'error', + { allowEmptyCatch: true } + ], + 'indent': [ + 'error', + 4, + { 'SwitchCase': 1 } + ], + 'linebreak-style': [ + 'error', + 'windows' + ], + 'quotes': [ + 'error', + 'single' + ], + 'semi': [ + 'error', + 'always' + ] + } +}; diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index eec2e96..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,27 +0,0 @@ -env: - commonjs: true - es6: true - node: true -extends: 'eslint:recommended' -globals: - Atomics: readonly - SharedArrayBuffer: readonly -parserOptions: - ecmaVersion: 2018 -rules: - no-empty: - - error - - { "allowEmptyCatch": true } - indent: - - error - - 4 - - { "SwitchCase": 1 } - linebreak-style: - - error - - windows - quotes: - - error - - single - semi: - - error - - always diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml new file mode 100644 index 0000000..26d4425 --- /dev/null +++ b/.github/workflows/eslint.yml @@ -0,0 +1,24 @@ +name: eslint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x] + 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 i + - run: npx eslint . diff --git a/funi.js b/funi.js index 7a88626..8363d7a 100644 --- a/funi.js +++ b/funi.js @@ -447,7 +447,7 @@ function getSubsUrl(m){ path: m[i].filePath, ext: `.${lang}`, langName: subType[lang], - language: m[i].languages[0].code ?? lang.slice(0, 2) + language: m[i].languages[0].code || lang.slice(0, 2) }); } } @@ -848,37 +848,6 @@ function logDownloadInfo (dateStart, partsDL, partsTotal, partsDLRes, partsTotal console.log(`[INFO] ${partsDLRes} of ${partsTotalRes} parts downloaded [${percent}%] (${time})`); } -// make proxy URL -function buildProxy(proxyBaseUrl, proxyAuth){ - if(!proxyBaseUrl.match(/^(https?|socks4|socks5):/)){ - proxyBaseUrl = 'http://' + proxyBaseUrl; - } - - let proxyCfg = new URL(proxyBaseUrl); - let proxyStr = `${proxyCfg.protocol}//`; - - if(typeof proxyCfg.hostname != 'string' || proxyCfg.hostname == ''){ - throw new Error('[ERROR] Hostname and port required for proxy!'); - } - - if(proxyAuth && typeof proxyAuth == 'string' && proxyAuth.match(':')){ - proxyCfg.username = proxyAuth.split(':')[0]; - proxyCfg.password = proxyAuth.split(':')[1]; - proxyStr += `${proxyCfg.username}:${proxyCfg.password}@`; - } - - proxyStr += proxyCfg.hostname; - - if(!proxyCfg.port && proxyCfg.protocol == 'http:'){ - proxyStr += ':80'; - } - else if(!proxyCfg.port && proxyCfg.protocol == 'https:'){ - proxyStr += ':443'; - } - - return proxyStr; -} - /** * @param {string} input * @param {string} title diff --git a/modules/merger.js b/modules/merger.js index a111545..fd7050a 100644 --- a/modules/merger.js +++ b/modules/merger.js @@ -1,5 +1,4 @@ const iso639 = require('iso-639'); -const argv = require('../funi').argv; /** * @param {Array} videoAndAudio diff --git a/package.json b/package.json index f2d1d68..ce0e812 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "yargs": "^16.1.0" }, "devDependencies": { + "eslint": "^7.30.0", "fs-extra": "^9.0.1", "pkg": "^4.4.9", "removeNPMAbsolutePaths": "^2.0.0"