Skip to content

Commit

Permalink
chore(deps-dev): bump eslint-config-ipfs from 2.1.0 to 3.1.1 (#300)
Browse files Browse the repository at this point in the history
* chore(deps-dev): bump eslint-config-ipfs from 2.1.0 to 3.1.1

Bumps [eslint-config-ipfs](https://github.com/ipfs/eslint-config-ipfs) from 2.1.0 to 3.1.1.
- [Release notes](https://github.com/ipfs/eslint-config-ipfs/releases)
- [Commits](ipfs/eslint-config-ipfs@v2.1.0...v3.1.1)

---
updated-dependencies:
- dependency-name: eslint-config-ipfs
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: add return types

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com>
  • Loading branch information
dependabot[bot] and SgtPooki authored Oct 5, 2022
1 parent 1d62fc3 commit f1bce91
Show file tree
Hide file tree
Showing 16 changed files with 1,807 additions and 1,296 deletions.
3,011 changes: 1,761 additions & 1,250 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"browserslist": "^4.21.4",
"check-aegir-project": "^1.1.1",
"cp-cli": "^2.0.0",
"eslint-config-ipfs": "^2.1.0",
"eslint-config-ipfs": "^3.1.1",
"eslint-plugin-compat": "^4.0.2",
"fetch-ponyfill": "^7.1.0",
"ipfs": "^0.64.2",
Expand Down
10 changes: 5 additions & 5 deletions src/CheckBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ class CheckBase extends UiComponent implements Checkable {
_className = 'Not-set'
_tagName = 'Not-set'

get className () {
get className (): string {
return this._className
}

get tagName () {
get tagName (): string {
return this._tagName
}

constructor (protected readonly parent: Checker | GatewayNode, ...tagParams: ConstructorParameters<typeof Tag>) {
super(parent, ...tagParams)
}

check () {
check (): void {

}

checked () {
checked (): void {

}

onerror () {
onerror (): void {
this.tag.err()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ class Checker {
this.updateStats = this.updateStats.bind(this)
}

private updateStats () {
private updateStats (): void {
this.stats.update()
}

async checkGateways (gateways: string[]) {
async checkGateways (gateways: string[]): Promise<void> {
const allChecks: Array<Promise<void>> = []
for (const gateway of gateways) {
const node = new GatewayNode(this.results, gateway, this.nodes.length)
Expand Down
6 changes: 3 additions & 3 deletions src/Cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Cors extends CheckBase implements Checkable {
super(parent, 'div', 'Cors')
}

async check () {
async check (): Promise<void> {
const now = Date.now()
const gatewayAndHash = this.parent.gateway.replace(':hash', HASH_TO_TEST)
const testUrl = `${gatewayAndHash}?now=${now}#x-ipfs-companion-no-redirect`
Expand All @@ -44,11 +44,11 @@ class Cors extends CheckBase implements Checkable {
}
}

checked () {
checked (): void {
log.warn('Not implemented yet')
}

onerror () {
onerror (): void {
this.tag.empty()
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Flag extends UiComponent {
super(parent, 'div', 'Flag')
}

async check () {
async check (): Promise<void> {
let ask = true

try {
Expand Down Expand Up @@ -45,7 +45,7 @@ class Flag extends UiComponent {
}
}

private startLimiters () {
private startLimiters (): void {
if (Flag.googleLimiter.isStopped === true) {
Flag.googleLimiter.start()
}
Expand Down Expand Up @@ -93,7 +93,7 @@ class Flag extends UiComponent {
}
}

async handleDnsQueryResponse (response: DnsQueryResponse) {
async handleDnsQueryResponse (response: DnsQueryResponse): Promise<void> {
if (response.Answer == null) {
log.error('Response does not contain the "Answer" property:', response)
return this.onError()
Expand Down Expand Up @@ -126,11 +126,11 @@ class Flag extends UiComponent {
}
}

private onError () {
private onError (): void {
this.tag.empty()
}

onResponse (response: IpfsGeoip.LookupResponse) {
onResponse (response: IpfsGeoip.LookupResponse): void {
this.tag.style.setProperty('background-image', `url('https://ipfs.io/ipfs/QmaYjj5BHGAWfopTdE8ESzypbuthsZqTeqz9rEuh3EJZi6/${response.country_code.toLowerCase()}.svg')`)
this.tag.title = response.country_name
this.tag.empty() // remove textContent icon since we're using a background image
Expand Down
6 changes: 3 additions & 3 deletions src/GatewayNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class GatewayNode extends UiComponent /* implements Checkable */ {
this.checkingTime = 0
}

public async check () {
public async check (): Promise<void> {
this.checkingTime = Date.now()
// const onFailedCheck = () => { this.status.down = true }
// const onSuccessfulCheck = () => { this.status.up = true }
Expand Down Expand Up @@ -100,7 +100,7 @@ class GatewayNode extends UiComponent /* implements Checkable */ {
})
}

private onSuccessfulCheck () {
private onSuccessfulCheck (): void {
if (!this.atLeastOneSuccess) {
log.info(`For gateway '${this.gateway}', at least one check was successful`)
this.atLeastOneSuccess = true
Expand Down Expand Up @@ -135,7 +135,7 @@ class GatewayNode extends UiComponent /* implements Checkable */ {
// }
// }

onerror () {
onerror (): void {
this.tag.err()
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ class Log {
* @param method - log
* @param args
*/
private log<M extends Extract<keyof Console, keyof Omit<Log, 'log'>>>(method: M, ...args: Parameters<Console[M]>) {
private log<M extends Extract<keyof Console, keyof Omit<Log, 'log'>>>(method: M, ...args: Parameters<Console[M]>): void {
const [msg, ...optionalParams] = args
const prefix = this.namespace != null ? `${this.namespace}.${method}: ` : ''

// eslint-disable-next-line no-console
console[method](`${prefix}${msg as string}`, ...optionalParams)
}

debug (...args: Parameters<Console['debug']>) {
debug (...args: Parameters<Console['debug']>): void {
this.log('debug', ...args)
}

info (...args: Parameters<Console['info']>) {
info (...args: Parameters<Console['info']>): void {
this.log('info', ...args)
}

warn (...args: Parameters<Console['warn']>) {
warn (...args: Parameters<Console['warn']>): void {
this.log('warn', ...args)
}

error (...args: Parameters<Console['error']>) {
error (...args: Parameters<Console['error']>): void {
this.log('error', ...args)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Origin {
this.tag = new Tag('div', 'Origin')
}

async check () {
async check (): Promise<void> {
// we are unable to check url after subdomain redirect because some gateways
// may not have proper CORS in place. instead, we manually construct subdomain
// URL and check if it loading known image works
Expand All @@ -34,7 +34,7 @@ class Origin {
.catch((err) => this.onerror(err))
}

onerror (err: Error) {
onerror (err: Error): void {
log.error(err)
this.tag.err()
throw err
Expand Down
2 changes: 1 addition & 1 deletion src/Results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Checker } from './Checker'
import type { Tag } from './Tag'

class Results {
append (tag: Tag) {
append (tag: Tag): void {
this.element.append(tag.element)
}

Expand Down
2 changes: 1 addition & 1 deletion src/Stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Stats extends UiComponent {
this.tag.append(this.totals)
}

public update () {
public update (): void {
let up = 0
let down = 0
for (const savedNode of this.parent.nodes) {
Expand Down
8 changes: 4 additions & 4 deletions src/Status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Status extends UiComponent {
super(parent, 'div', 'Status')
}

async check () {
async check (): Promise<void> {
// test by loading subresource via img.src (path will work on both old and subdomain gws)
const gwUrl = new URL(this.parent.gateway)
const imgPathUrl = new URL(`${gwUrl.protocol}//${gwUrl.hostname}/ipfs/${IMG_HASH}?now=${Date.now()}&filename=1x1.png#x-ipfs-companion-no-redirect`)
Expand All @@ -37,7 +37,7 @@ class Status extends UiComponent {
})
}

get down () {
get down (): boolean {
return this._down
}

Expand All @@ -48,7 +48,7 @@ class Status extends UiComponent {
}
}

get up () {
get up (): boolean {
return this._up
}

Expand All @@ -65,7 +65,7 @@ class Status extends UiComponent {
// // this.tag.global()
// }

onerror () {
onerror (): void {
throw new Error('Not implemented')
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Tag {
this.textContent = textContent
}

public static fromElement (element: HTMLElement) {
public static fromElement (element: HTMLElement): Tag {
const tag = new Tag('div')
tag.element = element

Expand All @@ -26,15 +26,15 @@ class Tag {
/**
* Use the below functions to keep displays consistent
*/
asterisk () {
asterisk (): void {
this.textContent = TagStatus.asterisk
}

lose () {
lose (): void {
this.textContent = TagStatus.failed
}

win (url?: string) {
win (url?: string): void {
if (url != null) {
this.textContent = TagStatus.empty
const linkToImageSubdomain = document.createElement('a')
Expand All @@ -48,30 +48,30 @@ class Tag {
}
}

global () {
global (): void {
this.textContent = TagStatus.global
}

err () {
err (): void {
this.textContent = TagStatus.caution
}

empty () {
empty (): void {
this.textContent = TagStatus.empty
}

get style () {
get style (): CSSStyleDeclaration {
return this.element.style
}

append (child: string | Node | Tag) {
append (child: string | Node | Tag): void {
if (child instanceof Tag) {
child = child.element
}
return this.element.append(child)
}

get classList () {
get classList (): DOMTokenList {
return this.element.classList
}

Expand Down
4 changes: 2 additions & 2 deletions src/checkViaImgSrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

// const log = new Log('checkViaImgSrc')

async function checkViaImgSrc (imgUrl: string | URL) {
async function checkViaImgSrc (imgUrl: string | URL): Promise<void> {
// we check if gateway is up by loading 1x1 px image:
// this is more robust check than loading js, as it won't be blocked
// by privacy protections present in modern browsers or in extensions such as Privacy Badger
const imgCheckTimeout = 15000
return await new Promise<void>((resolve, reject) => {
return await new Promise((resolve, reject) => {
const img = new Image()
const timer: ReturnType<typeof setTimeout> = setTimeout(() => {
// clearTimeout(timer)
Expand Down
2 changes: 1 addition & 1 deletion src/expectSubdomainRedirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Log } from './Log'

const log = new Log('expectSubdomainRedirect')

async function expectSubdomainRedirect (url: string | URL) {
async function expectSubdomainRedirect (url: string | URL): Promise<void> {
// Detecting redirects on remote Origins is extra tricky,
// but we seem to be able to access xhr.responseURL which is enough to see
// if paths are redirected to subdomains.
Expand Down
2 changes: 1 addition & 1 deletion src/gatewayHostname.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HASH_TO_TEST } from './constants'

function gatewayHostname (url: URL) {
function gatewayHostname (url: URL): string {
let urlString: string = url.toString()

if (url?.hostname != null) {
Expand Down

0 comments on commit f1bce91

Please sign in to comment.