Skip to content

Commit

Permalink
Upgrade eslint to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Apr 23, 2021
1 parent 079c629 commit 286101a
Show file tree
Hide file tree
Showing 15 changed files with 885 additions and 545 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"extends": ["plugin:jest/recommended"],
"rules": {
"jest/expect-expect": "off",
"jest/no-disabled-tests": "off"
"jest/no-disabled-tests": "off",
"jest/no-conditional-expect": "off",
"jest/valid-title": "off",
"jest/no-interpolation-in-snapshots": "off"
}
},
{ "files": ["**/__tests__/**"], "env": { "jest": true } },
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"@types/http-proxy": "1.17.3",
"@types/jest": "24.0.13",
"@types/string-hash": "1.1.1",
"@typescript-eslint/eslint-plugin": "2.17.0",
"@typescript-eslint/parser": "2.17.0",
"@typescript-eslint/eslint-plugin": "4.22.0",
"@typescript-eslint/parser": "4.22.0",
"@zeit/next-css": "1.0.2-canary.2",
"@zeit/next-sass": "1.0.2-canary.2",
"@zeit/next-typescript": "1.1.2-canary.0",
Expand All @@ -71,11 +71,11 @@
"cross-env": "6.0.3",
"cross-spawn": "6.0.5",
"escape-string-regexp": "2.0.0",
"eslint": "6.8.0",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jest": "23.13.1",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "2.3.0",
"eslint": "7.24.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.3.5",
"eslint-plugin-react": "7.23.2",
"eslint-plugin-react-hooks": "4.2.0",
"execa": "2.0.3",
"express": "4.17.0",
"faunadb": "2.6.1",
Expand All @@ -87,7 +87,6 @@
"image-size": "0.9.3",
"is-animated": "2.0.0",
"isomorphic-unfetch": "3.0.0",
"jest-cli": "27.0.0-next.5",
"ky": "0.19.1",
"ky-universal": "0.6.0",
"lerna": "4.0.0",
Expand Down Expand Up @@ -129,7 +128,8 @@
"wait-port": "0.2.2",
"web-streams-polyfill": "2.1.1",
"webpack-bundle-analyzer": "4.3.0",
"worker-loader": "3.0.7"
"worker-loader": "3.0.7",
"jest": "27.0.0-next.8"
},
"resolutions": {
"browserslist": "4.16.1",
Expand Down
7 changes: 2 additions & 5 deletions packages/next/build/output/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ export function startedDevelopmentServer(appUrl: string, bindAddr: string) {
let previousClient: import('webpack').Compiler | null = null
let previousServer: import('webpack').Compiler | null = null

type CompilerDiagnosticsWithFile = {
errors: { file: string | undefined; message: string }[] | null
warnings: { file: string | undefined; message: string }[] | null
}

type CompilerDiagnostics = {
errors: string[] | null
warnings: string[] | null
Expand Down Expand Up @@ -44,6 +39,8 @@ type BuildStatusStore = {
amp: AmpPageStatus
}

// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
enum WebpackStatusPhase {
COMPILING = 1,
COMPILED_WITH_ERRORS = 2,
Expand Down
9 changes: 6 additions & 3 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,10 @@ export default async function getBaseWebpackConfig(
async function handleExternals(
context: string,
request: string,
getResolve: () => (context: string, request: string) => Promise<string>
getResolve: () => (
resolveContext: string,
resolveRequest: string
) => Promise<string>
) {
if (request === 'next') {
return `commonjs ${request}`
Expand Down Expand Up @@ -763,8 +766,8 @@ export default async function getBaseWebpackConfig(
context: string
request: string
getResolve: () => (
context: string,
request: string
resolveContext: string,
resolveRequest: string
) => Promise<string>
}) => handleExternals(context, request, getResolve)
: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export interface IConformanceAnomaly {
stack_trace?: string
}

// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
export enum IConformanceTestStatus {
SUCCESS,
FAILED,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* @eslint-disable no-redeclare */
import chalk from 'chalk'
import {
CONFORMANCE_ERROR_PREFIX,
Expand All @@ -10,11 +11,6 @@ import {
} from '../TestInterface'
import { deepEqual } from '../utils/utils'

export interface GranularChunksConformanceCheck
extends IWebpackConformanceTest {
granularChunksConfig: any
}

function getWarningMessage(modifiedProp: string) {
return (
`${CONFORMANCE_WARNING_PREFIX}: The splitChunks config has been carefully ` +
Expand All @@ -33,7 +29,9 @@ function getErrorMessage(message: string) {
)
}

export class GranularChunksConformanceCheck {
/* @eslint-disable-next-line no-redeclare */
export class GranularChunksConformanceCheck implements IWebpackConformanceTest {
granularChunksConfig: any
constructor(granularChunksConfig: any) {
this.granularChunksConfig = granularChunksConfig
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/lib/recursive-copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function recursiveCopy(
}: {
concurrency?: number
overwrite?: boolean
filter?(path: string): boolean
filter?(filePath: string): boolean
} = {}
): Promise<void> {
const cwdPath = process.cwd()
Expand Down
2 changes: 2 additions & 0 deletions packages/next/lib/typescript/diagnosticFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'
import chalk from 'chalk'
import path from 'path'

// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
export enum DiagnosticCategory {
Warning = 0,
Error = 1,
Expand Down
16 changes: 8 additions & 8 deletions packages/next/next-server/lib/post-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type renderOptions = {
getFontDefinition?: (url: string) => string
}

type postProcessData = {
type PostProcessData = {
preloads: {
images: Array<string>
}
Expand All @@ -23,12 +23,12 @@ type postProcessData = {
interface PostProcessMiddleware {
inspect: (
originalDom: HTMLElement,
data: postProcessData,
data: PostProcessData,
options: renderOptions
) => void
mutate: (
markup: string,
data: postProcessData,
data: PostProcessData,
options: renderOptions
) => Promise<string>
}
Expand Down Expand Up @@ -58,7 +58,7 @@ async function processHTML(
if (!middlewareRegistry[0]) {
return html
}
const postProcessData: postProcessData = {
const postProcessData: PostProcessData = {
preloads: {
images: [],
},
Expand Down Expand Up @@ -92,7 +92,7 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
fontDefinitions: (string | undefined)[][] = []
inspect(
originalDom: HTMLElement,
_data: postProcessData,
_data: PostProcessData,
options: renderOptions
) {
if (!options.getFontDefinition) {
Expand Down Expand Up @@ -121,7 +121,7 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
}
mutate = async (
markup: string,
_data: postProcessData,
_data: PostProcessData,
options: renderOptions
) => {
let result = markup
Expand Down Expand Up @@ -157,7 +157,7 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
}

class ImageOptimizerMiddleware implements PostProcessMiddleware {
inspect(originalDom: HTMLElement, _data: postProcessData) {
inspect(originalDom: HTMLElement, _data: PostProcessData) {
const imgElements = originalDom.querySelectorAll('img')
let eligibleImages: Array<HTMLElement> = []
for (let i = 0; i < imgElements.length; i++) {
Expand All @@ -178,7 +178,7 @@ class ImageOptimizerMiddleware implements PostProcessMiddleware {
}
}
}
mutate = async (markup: string, _data: postProcessData) => {
mutate = async (markup: string, _data: PostProcessData) => {
let result = markup
let imagePreloadTags = _data.preloads.images
.filter((imgHref) => !preloadTagAlreadyExists(markup, imgHref))
Expand Down
3 changes: 1 addition & 2 deletions packages/next/next-server/lib/router/router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global __NEXT_DATA__ */
// tslint:disable:no-console
import { ParsedUrlQuery } from 'querystring'
import { ComponentType } from 'react'
Expand Down Expand Up @@ -554,7 +553,7 @@ export default class Router implements BaseRouter {
pageLoader: any
Component: ComponentType
App: AppComponent
wrapApp: (App: AppComponent) => any
wrapApp: (WrapAppComponent: AppComponent) => any
err?: Error
isFallback: boolean
locale?: string
Expand Down
6 changes: 3 additions & 3 deletions packages/next/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export default class Document<P = {}> extends Component<DocumentProps & P> {
return { html, head, styles }
}

static renderDocument<P>(
DocumentComponent: new () => Document<P>,
props: DocumentProps & P
static renderDocument<Y>(
DocumentComponent: new () => Document<Y>,
props: DocumentProps & Y
): React.ReactElement {
return (
<DocumentComponentContext.Provider value={props}>
Expand Down
2 changes: 2 additions & 0 deletions packages/next/telemetry/trace/shared.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
export enum TARGET {
CONSOLE = 'CONSOLE',
ZIPKIN = 'ZIPKIN',
Expand Down
2 changes: 2 additions & 0 deletions packages/next/telemetry/trace/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const NUM_OF_MICROSEC_IN_SEC = BigInt('1000')

const getId = () => randomBytes(8).toString('hex')

// eslint typescript has a bug with TS enums
/* eslint-disable no-shadow */
export enum SpanStatus {
Started,
Stopped,
Expand Down
2 changes: 1 addition & 1 deletion packages/next/types/webpack.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/no-unused-vars */
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/no-unused-vars , no-shadow */
// Type definitions for webpack 4.39
// Project: https://github.com/webpack/webpack
// Definitions by: Qubo <https://github.com/tkqubo>
Expand Down
Loading

0 comments on commit 286101a

Please sign in to comment.