Skip to content

Commit 0601faa

Browse files
committed
add eslint conf + apply formatting
1 parent 14cd19a commit 0601faa

8 files changed

+2258
-30
lines changed

.eslintrc

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"es6": true,
6+
"node": true
7+
},
8+
"parserOptions": {
9+
"sourceType": "module",
10+
"ecmaVersion": 2021,
11+
"ecmaFeatures": {
12+
"modules": true
13+
}
14+
},
15+
"extends": [
16+
"eslint:recommended"
17+
],
18+
"plugins": [
19+
"prettier"
20+
],
21+
"rules": {
22+
"no-empty": 0,
23+
"no-sparse-arrays": 0,
24+
"prettier/prettier": [
25+
1,
26+
{
27+
"trailingComma": "all",
28+
"printWidth": 130,
29+
"bracketSpacing": false,
30+
"arrowParens": "avoid",
31+
"singleQuote": true
32+
}
33+
],
34+
"no-unused-vars": [
35+
1,
36+
{
37+
"argsIgnorePattern": "^_"
38+
}
39+
]
40+
}
41+
}

cli.js

+26-21
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ function getRetryMessage({meta, ref, retryCount, maxRetries, bytesRead, totalByt
8989
Number.isFinite(maxRetries) ? `/:{color(yellow)}${maxRetries}:{color:close(yellow)}` : ''
9090
}}: `,
9191
lastErr
92-
? `${lastErr.code ? `[:{color(yellow)}${lastErr.code}:{color:close(yellow)}] ` : ''}(:{color(yellow)}${lastErr.message ||
93-
lastErr}:{color:close(yellow)}) `
92+
? `${lastErr.code ? `[:{color(yellow)}${lastErr.code}:{color:close(yellow)}] ` : ''}(:{color(yellow)}${
93+
lastErr.message || lastErr
94+
}:{color:close(yellow)}) `
9495
: '',
9596
totalBytes
9697
? `(:{color(cyan)}${
@@ -618,20 +619,27 @@ async function init(queries, options) {
618619
}
619620
let {namespace} = Config.playlist;
620621
namespace = namespace ? xurl.format(xurl.parse(namespace)).concat('/') : '';
621-
validStats.forEach(({meta: {track: {uri, name, artists, duration}, service, outFilePath}}) =>
622-
plStream.write(
623-
[
624-
'',
625-
`#${service[symbols.meta].DESC} URI: ${uri}`,
626-
`#EXTINF:${Math.round(duration / 1e3)},${artists[0]} - ${name}`,
627-
`${namespace.concat(
628-
(entry => (!Config.playlist.escape ? entry : encodeURI(entry).replace(/#/g, '%23')))(
629-
xpath.relative(BASE_DIRECTORY, outFilePath),
630-
),
631-
)}`,
632-
'',
633-
].join('\n'),
634-
),
622+
validStats.forEach(
623+
({
624+
meta: {
625+
track: {uri, name, artists, duration},
626+
service,
627+
outFilePath,
628+
},
629+
}) =>
630+
plStream.write(
631+
[
632+
'',
633+
`#${service[symbols.meta].DESC} URI: ${uri}`,
634+
`#EXTINF:${Math.round(duration / 1e3)},${artists[0]} - ${name}`,
635+
`${namespace.concat(
636+
(entry => (!Config.playlist.escape ? entry : encodeURI(entry).replace(/#/g, '%23')))(
637+
xpath.relative(BASE_DIRECTORY, outFilePath),
638+
),
639+
)}`,
640+
'',
641+
].join('\n'),
642+
),
635643
);
636644
plStream.close();
637645
logger.write('[done]\n');
@@ -990,10 +998,7 @@ async function init(queries, options) {
990998
if (!audioFeeds || audioFeeds.err) return {meta, err: (audioFeeds || {}).err, code: 2};
991999

9921000
const feedMeta = audioFeeds.formats.sort((meta1, meta2) => (meta1.abr > meta2.abr ? -1 : meta1.abr < meta2.abr ? 1 : 0))[0];
993-
meta.fingerprint = crypto
994-
.createHash('md5')
995-
.update(`${audioSource.source.videoId} ${feedMeta.format_id}`)
996-
.digest('hex');
1001+
meta.fingerprint = crypto.createHash('md5').update(`${audioSource.source.videoId} ${feedMeta.format_id}`).digest('hex');
9971002
const files = await downloadQueue
9981003
.push({track, meta, feedMeta, trackLogger})
9991004
.catch(errObject => Promise.reject({meta, code: 5, ...(errObject.code ? errObject : {err: errObject})}));
@@ -1520,7 +1525,7 @@ program
15201525
)
15211526
.option('-L, --filter-case', 'enable case sensitivity for glob matches on the filters (unimplemented)')
15221527
.option('--profile <PROFILE>', 'configuration context with which to process the search and download')
1523-
.action((args, cmd) => {
1528+
.action((_args, _cmd) => {
15241529
throw Error('Unimplemented: [CLI:search]');
15251530
})
15261531
.on('--help', () => {

0 commit comments

Comments
 (0)