Fixes linter errors

This commit is contained in:
freearhey 2023-10-15 14:08:23 +03:00
parent 57e508fc3b
commit 63c86a2b30
393 changed files with 28447 additions and 28443 deletions

View file

@ -15,7 +15,7 @@ program
const filepath = program.args[0]
const programOptions = program.opts()
const defaultCountry = programOptions.country.toLowerCase()
const newLabel = ` [new]`
const newLabel = ' [new]'
let options = new Collection()
@ -49,10 +49,10 @@ async function main() {
}
return
}
let choices = getOptions(channels, channel)
const choices = getOptions(channels, channel)
const question: QuestionCollection = {
name: 'option',
message: `Choose an option:`,
message: 'Choose an option:',
type: 'list',
choices,
pageSize: 10
@ -151,13 +151,13 @@ function getOptions(channels: Collection, channel: Channel) {
variants.add(`${channel.name.trim()} | ${channelId}${newLabel}`)
similar.forEach((_channel: ApiChannel) => {
const altNames = _channel.altNames.notEmpty() ? ` (${_channel.altNames.join(',')})` : ''
const closed = _channel.closed ? `[closed:${_channel.closed}]` : ``
const closed = _channel.closed ? `[closed:${_channel.closed}]` : ''
const replacedBy = _channel.replacedBy ? `[replaced_by:${_channel.replacedBy}]` : ''
variants.add(`${_channel.name}${altNames} | ${_channel.id} ${closed}${replacedBy}[api]`)
})
variants.add(`Overwrite`)
variants.add(`Skip`)
variants.add('Overwrite')
variants.add('Skip')
return variants.all()
}
@ -173,7 +173,7 @@ function getSimilar(channels: Collection, channelId: string) {
function generateCode(name: string, country: string) {
const channelId: string = transliterate(name)
.replace(/\+/gi, 'Plus')
.replace(/^\&/gi, 'And')
.replace(/^&/gi, 'And')
.replace(/[^a-z\d]+/gi, '')
return `${channelId}.${country}`

View file

@ -42,7 +42,7 @@ async function main() {
let errors: ValidationError[] = []
let files: string[] = await storage.list(options.channels)
const files: string[] = await storage.list(options.channels)
for (const filepath of files) {
const file = new File(filepath)
if (file.extension() !== 'xml') continue

View file

@ -1,7 +1,7 @@
import { Logger, File, Collection, Storage } from '@freearhey/core'
import { ChannelsParser, XML } from '../../core'
import { Channel } from 'epg-grabber'
import { Command, OptionValues } from 'commander'
import { Command } from 'commander'
import path from 'path'
const program = new Command()
@ -36,7 +36,7 @@ async function main() {
}
const args: {
[key: string]: any
[key: string]: string
} = {}
if (Array.isArray(options.set)) {
@ -76,6 +76,10 @@ async function main() {
main()
function isPromise(promise: any) {
return !!promise && typeof promise.then === 'function'
function isPromise(promise: object[] | Promise<object[]>) {
return (
!!promise &&
typeof promise === 'object' &&
typeof (promise as Promise<object[]>).then === 'function'
)
}

View file

@ -40,7 +40,7 @@ async function main() {
let totalFiles = 0
let totalErrors = 0
const storage = new Storage()
let files: string[] = await storage.list(options.channels)
const files: string[] = await storage.list(options.channels)
for (const filepath of files) {
const file = new File(filepath)
if (file.extension() !== 'xml') continue

View file

@ -55,7 +55,7 @@ async function main() {
logger.info('config:')
logger.tree(options)
logger.info(`loading channels...`)
logger.info('loading channels...')
const storage = new Storage()
const parser = new ChannelsParser({ storage })
@ -69,7 +69,7 @@ async function main() {
}
let parsedChannels = new Collection()
for (let filepath of files) {
for (const filepath of files) {
parsedChannels = parsedChannels.concat(await parser.parse(filepath))
}
if (options.lang) {