diff --git a/examples/cms-agilitycms/lib/preview.ts b/examples/cms-agilitycms/lib/preview.ts index 42e456df04b67..dc0b0a7dd7c6f 100644 --- a/examples/cms-agilitycms/lib/preview.ts +++ b/examples/cms-agilitycms/lib/preview.ts @@ -88,7 +88,7 @@ export async function validatePreview({ agilityPreviewKey, slug, contentID }) { } //sanitize incoming key (replace spaces with '+') - if (agilityPreviewKey.indexOf(` `) > -1) { + if (agilityPreviewKey.includes(` `)) { agilityPreviewKey = agilityPreviewKey.split(` `).join(`+`) } diff --git a/packages/next-codemod/bin/cli.ts b/packages/next-codemod/bin/cli.ts index 5abf870f8090e..d388df289f0dc 100644 --- a/packages/next-codemod/bin/cli.ts +++ b/packages/next-codemod/bin/cli.ts @@ -27,7 +27,7 @@ export function checkGitStatus(force) { clean = isGitClean.sync(process.cwd()) errorMessage = 'Git directory is not clean' } catch (err) { - if (err && err.stderr && err.stderr.indexOf('Not a git repository') >= 0) { + if (err && err.stderr && err.stderr.includes('Not a git repository')) { clean = true } } diff --git a/packages/next-swc/crates/next-core/js/src/overlay/internal/components/Overlay/maintain--tab-focus.ts b/packages/next-swc/crates/next-core/js/src/overlay/internal/components/Overlay/maintain--tab-focus.ts index 17db3344c5b54..0771c0fe6eae6 100644 --- a/packages/next-swc/crates/next-core/js/src/overlay/internal/components/Overlay/maintain--tab-focus.ts +++ b/packages/next-swc/crates/next-core/js/src/overlay/internal/components/Overlay/maintain--tab-focus.ts @@ -1136,7 +1136,7 @@ function isUserModifyWritable(style) { // https://www.w3.org/TR/1999/WD-css3-userint-19990916#user-modify // https://github.com/medialize/ally.js/issues/17 var userModify = style.webkitUserModify || '' - return Boolean(userModify && userModify.indexOf('write') !== -1) + return Boolean(userModify && userModify.includes('write')) } function hasCssOverflowScroll(style) { diff --git a/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx b/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx index e02cf016d6aa9..679796e239624 100644 --- a/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx +++ b/packages/next/src/client/components/react-dev-overlay/hot-reloader-client.tsx @@ -469,9 +469,9 @@ export default function HotReload({ useEffect(() => { const handler = (event: MessageEvent) => { if ( - event.data.indexOf('action') === -1 && + !event.data.includes('action') && // TODO-APP: clean this up for consistency - event.data.indexOf('pong') === -1 + !event.data.includes('pong') ) { return } diff --git a/packages/next/src/client/dev/error-overlay/format-webpack-messages.ts b/packages/next/src/client/dev/error-overlay/format-webpack-messages.ts index 82a025f32f794..618bfb2af4d08 100644 --- a/packages/next/src/client/dev/error-overlay/format-webpack-messages.ts +++ b/packages/next/src/client/dev/error-overlay/format-webpack-messages.ts @@ -31,7 +31,7 @@ const WEBPACK_BREAKING_CHANGE_POLYFILLS = '\n\nBREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.' function isLikelyASyntaxError(message: string) { - return stripAnsi(message).indexOf(friendlySyntaxErrorLabel) !== -1 + return stripAnsi(message).includes(friendlySyntaxErrorLabel) } let hadMissingSassError = false diff --git a/packages/next/src/client/dev/error-overlay/hot-dev-client.ts b/packages/next/src/client/dev/error-overlay/hot-dev-client.ts index 8bbd9840989a1..c1f1522142b43 100644 --- a/packages/next/src/client/dev/error-overlay/hot-dev-client.ts +++ b/packages/next/src/client/dev/error-overlay/hot-dev-client.ts @@ -64,7 +64,7 @@ export default function connect() { register() addMessageListener((event) => { - if (event.data.indexOf('action') === -1) return + if (!event.data.includes('action')) return try { processMessage(event) diff --git a/packages/next/src/client/dev/on-demand-entries-client.ts b/packages/next/src/client/dev/on-demand-entries-client.ts index 94cfc4133f80a..a1b9c9ca7bc8b 100644 --- a/packages/next/src/client/dev/on-demand-entries-client.ts +++ b/packages/next/src/client/dev/on-demand-entries-client.ts @@ -27,7 +27,7 @@ export default async (page?: string) => { } addMessageListener((event) => { - if (event.data.indexOf('{') === -1) return + if (!event.data.includes('{')) return try { const payload = JSON.parse(event.data) // don't attempt fetching the page if we're already showing diff --git a/packages/next/src/client/next-dev.ts b/packages/next/src/client/next-dev.ts index 28a35e08c0c6c..12e7a7fe92a47 100644 --- a/packages/next/src/client/next-dev.ts +++ b/packages/next/src/client/next-dev.ts @@ -55,7 +55,7 @@ initialize({ webpackHMR }) let buildIndicatorHandler: any = () => {} function devPagesManifestListener(event: any) { - if (event.data.indexOf('devPagesManifest') !== -1) { + if (event.data.includes('devPagesManifest')) { fetch( `${assetPrefix}/_next/static/development/_devPagesManifest.json` ) @@ -66,9 +66,9 @@ initialize({ webpackHMR }) .catch((err) => { console.log(`Failed to fetch devPagesManifest`, err) }) - } else if (event.data.indexOf('middlewareChanges') !== -1) { + } else if (event.data.includes('middlewareChanges')) { return window.location.reload() - } else if (event.data.indexOf('serverOnlyChanges') !== -1) { + } else if (event.data.includes('serverOnlyChanges')) { const { pages } = JSON.parse(event.data) // Make sure to reload when the dev-overlay is showing for an diff --git a/packages/next/src/shared/lib/loadable.tsx b/packages/next/src/shared/lib/loadable.tsx index fabed3fd27ce9..1592d98551093 100644 --- a/packages/next/src/shared/lib/loadable.tsx +++ b/packages/next/src/shared/lib/loadable.tsx @@ -101,7 +101,7 @@ function createLoadableComponent(loadFn: any, options: any) { if (moduleIds) { READY_INITIALIZERS.push((ids: any) => { for (const moduleId of moduleIds) { - if (ids.indexOf(moduleId) !== -1) { + if (ids.includes(moduleId)) { return init() } } diff --git a/packages/next/src/shared/lib/router/utils/format-url.ts b/packages/next/src/shared/lib/router/utils/format-url.ts index efc9df8c4ea47..990dbde7bf7b5 100644 --- a/packages/next/src/shared/lib/router/utils/format-url.ts +++ b/packages/next/src/shared/lib/router/utils/format-url.ts @@ -91,7 +91,7 @@ export function formatWithValidation(url: UrlObject): string { if (process.env.NODE_ENV === 'development') { if (url !== null && typeof url === 'object') { Object.keys(url).forEach((key) => { - if (urlObjectKeys.indexOf(key) === -1) { + if (!urlObjectKeys.includes(key)) { console.warn( `Unknown key passed via urlObject into url.format: ${key}` ) diff --git a/packages/react-dev-overlay/src/internal/helpers/launchEditor.ts b/packages/react-dev-overlay/src/internal/helpers/launchEditor.ts index 593926e11b1d1..9d4dd4efd1685 100644 --- a/packages/react-dev-overlay/src/internal/helpers/launchEditor.ts +++ b/packages/react-dev-overlay/src/internal/helpers/launchEditor.ts @@ -226,7 +226,7 @@ function guessEditor(): string[] { const processNames = Object.keys(COMMON_EDITORS_MACOS) for (let i = 0; i < processNames.length; i++) { const processName = processNames[i] - if (output.indexOf(processName) !== -1) { + if (output.includes(processName)) { return [(COMMON_EDITORS_MACOS as any)[processName]] } } @@ -242,7 +242,7 @@ function guessEditor(): string[] { for (let i = 0; i < runningProcesses.length; i++) { const processPath = runningProcesses[i].trim() const processName = path.basename(processPath) - if (COMMON_EDITORS_WIN.indexOf(processName) !== -1) { + if (COMMON_EDITORS_WIN.includes(processName)) { return [processPath] } } @@ -256,7 +256,7 @@ function guessEditor(): string[] { const processNames = Object.keys(COMMON_EDITORS_LINUX) for (let i = 0; i < processNames.length; i++) { const processName = processNames[i] - if (output.indexOf(processName) !== -1) { + if (output.includes(processName)) { return [(COMMON_EDITORS_LINUX as any)[processName] as string] } } diff --git a/test/lib/next-webdriver.ts b/test/lib/next-webdriver.ts index c48b4a6a0f38c..34aab288d5804 100644 --- a/test/lib/next-webdriver.ts +++ b/test/lib/next-webdriver.ts @@ -120,7 +120,7 @@ export default async function webdriver( // if it's not a Next.js app return if ( - document.documentElement.innerHTML.indexOf('__NEXT_DATA__') === -1 && + !document.documentElement.innerHTML.includes('__NEXT_DATA__') && // @ts-ignore next exists on window if it's a Next.js page. typeof ((window as any).next && (window as any).next.version) === 'undefined'