Skip to content

Commit

Permalink
Update ESlint plugins (#3980)
Browse files Browse the repository at this point in the history
* Update ESlint plugins

I wanted to fix the warning we get when running ESlint after update to
TypeScript 5.6, but latest typescript-eslint still doesn't support it:
typescript-eslint/typescript-eslint#9653

So we at least got the other updates and related lint fixes.

* chore(deps): dedupe deps

---------

Co-authored-by: Marcel Gerber <[email protected]>
  • Loading branch information
rakyi and marcelgerber authored Sep 22, 2024
1 parent b340d64 commit 5d94141
Show file tree
Hide file tree
Showing 35 changed files with 395 additions and 363 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('node:path');
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = require("node:path")

module.exports = {
extends: [
Expand Down Expand Up @@ -59,7 +60,7 @@ module.exports = {
"react/no-unescaped-entities": ["warn", { forbid: [">", "}"] }],
"react/prop-types": "warn",
"@typescript-eslint/no-floating-promises": "error",
"no-constant-binary-expression": "error"
"no-constant-binary-expression": "error",
},
settings: {
"import/resolver": {
Expand Down
2 changes: 1 addition & 1 deletion adminShared/SqlFilterSExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { isArray, tail, without } from "@ourworldindata/utils"
// transforms lists in S-Expressions into array, strings inside double quotes
// as String (note the uppercase! It really uses the rarely used String object) and
// all other tokes like numbers or symbols as normal string.
export type SExprAtom = string | String | SExprAtom[] // eslint-disable-line @typescript-eslint/ban-types
export type SExprAtom = string | String | SExprAtom[] // eslint-disable-line @typescript-eslint/no-wrapper-object-types

export type JSONPreciselyTyped =
| string
Expand Down
8 changes: 5 additions & 3 deletions adminSiteClient/AdminApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ class AdminErrorMessage extends React.Component<{ admin: Admin }> {
<Modal
className="errorMessage"
onClose={action(() => {
error.isFatal
? window.location.reload()
: (admin.errorMessage = undefined)
if (error.isFatal) {
window.location.reload()
} else {
admin.errorMessage = undefined
}
})}
>
<div className="modal-header">
Expand Down
2 changes: 1 addition & 1 deletion adminSiteClient/VariableEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ class VariableEditor extends React.Component<{
"include"
)
return true
} catch (err) {
} catch {
return false
}
}
Expand Down
1 change: 1 addition & 0 deletions adminSiteServer/adminRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
import { getMultiDimDataPageBySlug } from "../db/model/MultiDimDataPage.js"
import { renderMultiDimDataPageFromConfig } from "../baker/MultiDimBaker.js"

// eslint-disable-next-line @typescript-eslint/no-require-imports
require("express-async-errors")

// Used for rate-limiting important endpoints (login, register) to prevent brute force attacks
Expand Down
1 change: 1 addition & 0 deletions adminSiteServer/appClass.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react"
import { simpleGit } from "simple-git"
import express, { NextFunction } from "express"
// eslint-disable-next-line @typescript-eslint/no-require-imports
require("express-async-errors") // todo: why the require?
import cookieParser from "cookie-parser"
import http from "http"
Expand Down
1 change: 1 addition & 0 deletions adminSiteServer/mockSiteRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import { DEFAULT_LOCAL_BAKE_DIR } from "../site/SiteConstants.js"
import { DATA_INSIGHTS_ATOM_FEED_NAME } from "../site/gdocs/utils.js"
import { renderMultiDimDataPageBySlug } from "../baker/MultiDimBaker.js"

// eslint-disable-next-line @typescript-eslint/no-require-imports
require("express-async-errors")

// todo: switch to an object literal where the key is the path and the value is the request handler? easier to test, reflect on, and manipulate
Expand Down
2 changes: 1 addition & 1 deletion baker/DatapageHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const getPrimaryTopic = async (
let topicSlug: string
try {
topicSlug = await getSlugForTopicTag(knex, firstTopicTag)
} catch (e) {
} catch {
await logErrorAndMaybeSendToBugsnag(
`Data page is using "${firstTopicTag}" as its primary tag, which we are unable to resolve to a tag in the grapher DB`
)
Expand Down
2 changes: 1 addition & 1 deletion baker/DeployQueueServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class DeployQueueServer {
.map((line) => {
try {
return JSON.parse(line)
} catch (err) {
} catch {
return null
}
})
Expand Down
2 changes: 1 addition & 1 deletion baker/DeployUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export const deployIfQueueIsNotEmpty = async (
parsedQueue.every(isLightningChange) ? parsedQueue : undefined
)
await deployQueueServer.deletePendingFile()
} catch (err) {
} catch {
failures++
// The error is already sent to Slack inside the deploy() function.
// The deploy will be retried unless we've reached MAX_SUCCESSIVE_FAILURES.
Expand Down
2 changes: 1 addition & 1 deletion baker/siteRenderers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ const renderPostThumbnailBySlug = async (
let post
try {
post = await getFullPostBySlugFromSnapshot(knex, slug)
} catch (err) {
} catch {
// if no post is found, then we return early instead of throwing
}

Expand Down
2 changes: 1 addition & 1 deletion db/model/Chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ export async function getGptTopicSuggestions(
if (match) {
selectedTopics = JSON.parse(match[0])
}
} catch (e) {
} catch {
throw new JsonError(`GPT returned invalid JSON: "${json}"`, 500)
}

Expand Down
30 changes: 20 additions & 10 deletions db/model/Variable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -861,78 +861,88 @@ const buildWhereClauses = (query: string): string[] => {
}
if (part.startsWith("name:")) {
const q = part.substring("name:".length)
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(v.name, ${escape(q)}, 'i')`
)
}
} else if (part.startsWith("path:")) {
const q = part.substring("path:".length)
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(v.catalogPath, ${escape(q)}, 'i')`
)
}
} else if (part.startsWith("namespace:")) {
const q = part.substring("namespace:".length)
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(d.name, ${escape(q)}, 'i')`
)
}
} else if (part.startsWith("version:")) {
const q = part.substring("version:".length)
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(d.version, ${escape(q)}, 'i')`
)
}
} else if (part.startsWith("dataset:")) {
const q = part.substring("dataset:".length)
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(d.shortName, ${escape(q)}, 'i')`
)
}
} else if (part.startsWith("table:")) {
const q = part.substring("table:".length)
// NOTE: we don't have the table name in any db field, it's horrible to query
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(SUBSTRING_INDEX(SUBSTRING_INDEX(v.catalogPath, '/', 5), '/', -1), ${escape(
q
)}, 'i')`
)
}
} else if (part.startsWith("short:")) {
const q = part.substring("short:".length)
q &&
if (q) {
whereClauses.push(
`${not} REGEXP_LIKE(v.shortName, ${escape(q)}, 'i')`
)
}
} else if (part.startsWith("before:")) {
const q = part.substring("before:".length)
q &&
if (q) {
whereClauses.push(
`${not} IF(d.version is not null, d.version < ${escape(
q
)}, cast(date(d.createdAt) as char) < ${escape(q)})`
)
}
} else if (part.startsWith("after:")) {
const q = part.substring("after:".length)
q &&
if (q) {
whereClauses.push(
`${not} (IF (d.version is not null, d.version = "latest" OR d.version > ${escape(
q
)}, cast(date(d.createdAt) as char) > ${escape(q)}))`
)
}
} else if (part === "is:published") {
whereClauses.push(`${not} (NOT d.isPrivate)`)
} else if (part === "is:private") {
whereClauses.push(`${not} d.isPrivate`)
} else {
part &&
if (part) {
whereClauses.push(
`${not} (REGEXP_LIKE(v.name, ${escape(
part
)}, 'i') OR REGEXP_LIKE(v.catalogPath, ${escape(
part
)}, 'i'))`
)
}
}
}
return whereClauses
Expand Down
4 changes: 2 additions & 2 deletions explorer/ExplorerProgram.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ graphers
)
const def = program.getTableDef()!
expect(def.url).toBeFalsy()
expect(def.inlineData).toBeTruthy
expect(def.inlineData).toBeTruthy()
})
})

Expand Down Expand Up @@ -302,7 +302,7 @@ usa,Life expectancy
france,Life expectancy`
)
expect(true).toBe(false)
} catch (err) {
} catch {
expect(true).toBe(true)
}
})
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,18 @@
"@types/url-parse": "^1.4.8",
"@types/webfontloader": "^1.6.34",
"@types/workerpool": "^6.1.0",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
"@vitejs/plugin-react": "^4.3.1",
"@yarnpkg/types": "^4.0.0",
"bundlewatch": "^0.4.0",
"cypress": "9.3.1",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react-hooks": "^4.6.2",
"flag-icons": "^7.2.3",
"http-server": "^14.1.1",
"husky": "^9.0.11",
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@types/react": "^17.0.69",
"@types/react-dom": "^17.0.22",
"esbuild-sass-plugin": "^3.3.1",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
"typescript": "~5.6.2"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/core-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"devDependencies": {
"@types/d3": "^6",
"eslint": "^8.57.0",
"eslint": "^8.57.1",
"typescript": "~5.6.2"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/core-table/src/CoreTableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const makeRowFromColumnStore = (
return row
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
// eslint-disable-next-line @typescript-eslint/no-empty-interface, @typescript-eslint/no-empty-object-type
export interface InterpolationContext {}

export interface LinearInterpolationContext extends InterpolationContext {
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/grapher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
"enzyme": "^3.11.0",
"esbuild": "^0.21.5",
"esbuild-sass-plugin": "^3.3.1",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"tsup": "^8.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export class StaticCaptionedChart extends CaptionedChart {
try {
if (this.manager.bakedGrapherURL)
origin = new URL(this.manager.bakedGrapherURL).origin
} catch (e) {}
} catch {}
const css = `@import url(${origin}/fonts.css)`
return (
<defs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class EntityPicker extends React.Component<{
).map((region) => region.name)

if (userRegionNames) this.localEntityNames = userRegionNames
} catch (err) {}
} catch {}
}

@computed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class GlobalEntitySelector extends React.Component<{
(entity): boolean => entity.code === localCountryCode.code
)
if (country) this.localEntityName = country.name
} catch (err) {}
} catch {}
}

@action.bound private prepareOptionGroups(): GroupBase<DropdownEntity>[] {
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/grapher/src/core/grapher.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "./grapher.scss"

// Enable mobx-formatters
import * as Mobx from "mobx"
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const mobxFormatters = require("mobx-formatters").default
mobxFormatters(Mobx)
//Mobx.useStrict(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class EntitySelector extends React.Component<{
)

if (localEntityNames) this.set({ localEntityNames })
} catch (err) {}
} catch {}
}

private clearSearchInput(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function evalExpression<D>(
if (expr === undefined) return defaultOnError
try {
return expr.evaluate(context) as number
} catch (e) {
} catch {
return defaultOnError
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ export class ScatterPoint extends React.Component<{
)}
key={series.displayKey}
className={series.displayKey}
onMouseEnter={(): void => {
onMouseEnter && onMouseEnter(series.seriesName)
}}
onMouseLeave={(): void => {
onMouseLeave && onMouseLeave()
}}
onMouseEnter={
onMouseEnter
? (): void => onMouseEnter(series.seriesName)
: undefined
}
onMouseLeave={onMouseLeave}
>
{series.isFocus && (
<circle
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"keywords": [],
"author": "",
"devDependencies": {
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
"jest": "^29.7.0",
"typescript": "~5.6.2"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/@ourworldindata/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"@types/react-tag-autocomplete": "^6.1.1",
"@types/string-pixel-width": "^1.7.2",
"@types/url-parse": "^1.4.8",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint": "^8.57.1",
"eslint-plugin-react-hooks": "^4.6.2",
"jest": "^29.7.0",
"typescript": "~5.6.2"
},
Expand Down
Loading

0 comments on commit 5d94141

Please sign in to comment.