Added style checks

This commit is contained in:
Izuco 2021-07-06 16:31:57 +02:00
parent bfec2f4b89
commit e20edcc4da
6 changed files with 60 additions and 60 deletions

34
.eslintrc.js Normal file
View file

@ -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'
]
}
};

View file

@ -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

24
.github/workflows/eslint.yml vendored Normal file
View file

@ -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 .

33
funi.js
View file

@ -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

View file

@ -1,5 +1,4 @@
const iso639 = require('iso-639');
const argv = require('../funi').argv;
/**
* @param {Array<object>} videoAndAudio

View file

@ -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"