Skip to content

Commit

Permalink
Fix remaining lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gburgett committed Oct 27, 2022
1 parent 2404dfc commit cf99df8
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 38 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ module.exports = {
}],
'semi': ['error','never'],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off'
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-function': 'off'
}
}
2 changes: 1 addition & 1 deletion src/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function BuildPipeline(
source
.pipe(urlParser)
.pipe(sourceUrlTracker)
// reentry is responsible for ending itself when the EOF handler sends the EOF back
// reentry is responsible for ending itself when the EOF handler sends the EOF back
.pipe(reentry, { end: false })
.pipe(fetcher)
.pipe(eofHandler)
Expand Down
8 changes: 4 additions & 4 deletions src/divergent_stream_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export class DivergentStreamWrapper extends ParallelTransform {
private readonly _streams: Map<string, Duplex>
private readonly _createStreamOptions: CreateStreamOptions
private readonly _forwarder = new EventForwarder({
// Don't forward the normal stream events from inner streams, just the
// special Linkscanner events
ignore: StreamEvents,
}).to(this)
// Don't forward the normal stream events from inner streams, just the
// special Linkscanner events
ignore: StreamEvents,
}).to(this)

constructor(options: DivergentStreamWrapperOptions) {
super({
Expand Down
1 change: 1 addition & 0 deletions src/event_forwarder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class EventForwarder {

addMethods.forEach((methodName) => {
const oldMethod = emitter[methodName]
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this
emitter[methodName] = function(event: string | symbol, listener: (...args: any[]) => void) {
const ignore = self._options.ignore && self._options.ignore.has(event)
Expand Down
2 changes: 1 addition & 1 deletion src/fetch_interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class FetchInterfaceWrapper implements FetchInterface {
interval: maxConcurrency.interval,
})

// tslint:disable-next-line: max-classes-per-file
// tslint:disable-next-line: max-classes-per-file
this.Request = class {
constructor(url: string, requestInit?: RequestInit) {
// add in the headers inside the request constructor call
Expand Down
18 changes: 9 additions & 9 deletions src/fetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ describe('Fetcher', () => {
let options: Partial<FetchOptions>
let fetchMockSandbox: fetchMock.FetchMockSandbox
beforeEach(() => {
fetchMock.reset()
fetchMockSandbox = fetchMock.sandbox()
options = {
fetch: {
fetch: fetchMockSandbox,
Request: fetchMock.config.Request!,
},
}
})
fetchMock.reset()
fetchMockSandbox = fetchMock.sandbox()
options = {
fetch: {
fetch: fetchMockSandbox,
Request: fetchMock.config.Request!,
},
}
})

const instance = (additionalOptions?: Partial<FetchOptions>) =>
new Fetcher({
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ export class ConsoleFormatter extends Writable {
chalk.dim(`\t${linkCount.toFixed(0)} links found. ${excludedResults.length.toFixed(0)} not checked. `) +
(brokenResults.length == 0 ?
(successResults.length > 0 ? chalk.green(`0 broken.`) : '') :
chalk.red(`${brokenResults.length} broken.`)),
)
chalk.red(`${brokenResults.length} broken.`)),
)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class TableFormatter extends Writable {
if (!verbose) {
if (isSuccessResult(result)) {
if (!result.leaf && [301, 302, 307].includes(result.status)) {
// don't log non-leaf redirects unless verbose
// don't log non-leaf redirects unless verbose
return
}

Expand Down
4 changes: 2 additions & 2 deletions src/formatters/write-out.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface WriteOutFormatterOptions {

export class WriteOutFormatter extends Writable {

public static readonly templateRegexp = /[\$\%]\{(?<key>[^\}]*)\}/g
public static readonly templateRegexp = /[$%]\{(?<key>[^}]*)\}/g
private readonly options: WriteOutFormatterOptions

private readonly results = new Map<string, Result>()
Expand Down Expand Up @@ -147,7 +147,7 @@ export class WriteOutFormatter extends Writable {
const {logger, formatter} = this.options
let matchedOne = false
let matches: RegExpExecArray | null
// tslint:disable-next-line: no-conditional-assignment
// eslint-disable-next-line no-cond-assign
while (matches = WriteOutFormatter.templateRegexp.exec(formatter)) {
matchedOne = true
if (matches.groups &&
Expand Down
4 changes: 2 additions & 2 deletions src/hostname_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class HostnameSet {
private readonly _options: HostnameSetOptions

constructor(public readonly hostnames: Set<string>,
options?: Options<HostnameSetOptions>) {
options?: Options<HostnameSetOptions>) {
this._options = assign({
followRedirects: false,
ignoreRobotsFile: false,
Expand All @@ -42,7 +42,7 @@ export class HostnameSet {
maxConcurrency: 1,
parsers: {},
},
options)
options)
}

public async lockFor(host: Host): Promise<Semaphore> {
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ export const runDefaults: Readonly<Args> = {
verbose: false,
debug: false,
progress: !!(
typeof process != 'undefined' &&
typeof process != 'undefined' &&
process.stderr.isTTY
),
),
}

/**
Expand Down Expand Up @@ -279,8 +279,8 @@ class Builder {
_progress?: Builder['_progress'],
},
) {
this._formatters = previousBuilder ? previousBuilder._formatters : []
this._progress = previousBuilder && previousBuilder._progress
this._formatters = previousBuilder ? previousBuilder._formatters : []
this._progress = previousBuilder && previousBuilder._progress
}

/**
Expand All @@ -294,7 +294,7 @@ class Builder {
f = defaultFormatter
} else if (formatters[formatter]) {
f = formatters[formatter]
} else if (/[\$\%]{/.test(formatter)) {
} else if (/[$%]{/.test(formatter)) {
f = formatters['write-out']
}
if (!f) {
Expand Down Expand Up @@ -325,7 +325,7 @@ class Builder {

return new Builder({
...this._options,
// the progress bar intercepts logging so as to clear & rewrite after each log line
// the progress bar intercepts logging so as to clear & rewrite after each log line
logger: _progress,
}, {
...this,
Expand Down
2 changes: 1 addition & 1 deletion src/parsers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const defaultParsers = (options?: Options<ParserOptions & { only: string[
return
}
// text/html => html, application/vnd.blah+json => json
const lastPart = key.split(/[\/\+]/).filter((p) => p.length > 0).pop()
const lastPart = key.split(/[/+]/).filter((p) => p.length > 0).pop()
if (lastPart && only.includes(lastPart)) {
return
}
Expand Down
17 changes: 9 additions & 8 deletions src/parsers/json-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const defaultIncludes = [
]

export class JsonParser {
public static readonly regexp = /^\s*((((ftp|http|https):)?\/\/)|\/)[^ "<\{\}]+\s*$/igm
public static readonly regexp = /^\s*((((ftp|http|https):)?\/\/)|\/)[^ "<{}]+\s*$/igm

private readonly _options: ParserOptions
private readonly _seen = new Set<string>()
Expand Down Expand Up @@ -64,7 +64,7 @@ export class JsonParser {
private* traverse(json: any): Iterable<string> {
for (const path of this._options.include) {
for (const obj of JSONPath({ path, json })) {
// directly selected strings
// directly selected strings
if (typeof obj == 'string') {
yield obj

Expand All @@ -79,6 +79,7 @@ export class JsonParser {
// objects
} else if (typeof obj == 'object') {
for (const key of Object.keys(obj)) {
// eslint-disable-next-line no-prototype-builtins
if (!obj.hasOwnProperty(key)) { continue }
if (typeof obj[key] != 'string') { continue }

Expand All @@ -95,11 +96,11 @@ export class JsonParser {
*/
function* traverse(o: any, path: string[] = []): Iterable<{ key: string, value: string, path: string[]}> {
for (const i of Object.keys(o)) {
const itemPath = path.concat(i)
yield {key: i, value: o[i], path: itemPath }
if (o[i] !== null && typeof(o[i]) == 'object') {
// going one step down in the object tree!!
yield* traverse(o[i], itemPath)
}
const itemPath = path.concat(i)
yield {key: i, value: o[i], path: itemPath }
if (o[i] !== null && typeof(o[i]) == 'object') {
// going one step down in the object tree!!
yield* traverse(o[i], itemPath)
}
}
}

0 comments on commit cf99df8

Please sign in to comment.