diff --git a/packages/gatsby-link/index.d.ts b/packages/gatsby-link/index.d.ts index 6792bdf51d765..e08b07f6b857c 100644 --- a/packages/gatsby-link/index.d.ts +++ b/packages/gatsby-link/index.d.ts @@ -1,6 +1,7 @@ import * as React from "react" import { NavigateFn, LinkProps } from "@reach/router" +// eslint-disable-next-line @typescript-eslint/interface-name-prefix export interface GatsbyLinkProps extends LinkProps { /** A class to apply when this Link is active */ activeClassName?: string @@ -41,21 +42,3 @@ export const navigate: NavigateFn */ export const withPrefix: (path: string) => string export const withAssetPrefix: (path: string) => string - -/** - * @deprecated - * TODO: Remove for Gatsby v3 - */ -export const push: (to: string) => void - -/** - * @deprecated - * TODO: Remove for Gatsby v3 - */ -export const replace: (to: string) => void - -/** - * @deprecated - * TODO: Remove for Gatsby v3 - */ -export const navigateTo: (to: string) => void diff --git a/packages/gatsby-link/src/__tests__/index.js b/packages/gatsby-link/src/__tests__/index.js index c813b0bb403e5..444c0df280f71 100644 --- a/packages/gatsby-link/src/__tests__/index.js +++ b/packages/gatsby-link/src/__tests__/index.js @@ -5,7 +5,7 @@ import { createHistory, LocationProvider, } from "@reach/router" -import Link, { navigate, push, replace, withPrefix, withAssetPrefix } from "../" +import Link, { navigate, withPrefix, withAssetPrefix } from "../" beforeEach(() => { global.__BASE_PATH__ = `` @@ -24,16 +24,6 @@ const getNavigate = () => { return navigate } -const getPush = () => { - global.___push = jest.fn() - return push -} - -const getReplace = () => { - global.___replace = jest.fn() - return replace -} - const getWithPrefix = (pathPrefix = ``) => { global.__BASE_PATH__ = pathPrefix return withPrefix @@ -243,16 +233,6 @@ describe(``, () => { }) }) - it(`push is called with correct args`, () => { - getPush()(`/some-path`) - expect(global.___push).toHaveBeenCalledWith(`/some-path`) - }) - - it(`replace is called with correct args`, () => { - getReplace()(`/some-path`) - expect(global.___replace).toHaveBeenCalledWith(`/some-path`) - }) - describe(`uses push or replace adequately`, () => { it(`respects force disabling replace`, () => { const to = `/` diff --git a/packages/gatsby-link/src/index.js b/packages/gatsby-link/src/index.js index 7d5a4f74ffa6d..de40caf135f4d 100644 --- a/packages/gatsby-link/src/index.js +++ b/packages/gatsby-link/src/index.js @@ -272,11 +272,6 @@ GatsbyLink.propTypes = { state: PropTypes.object, } -const showDeprecationWarning = (functionName, altFunctionName, version) => - console.warn( - `The "${functionName}" method is now deprecated and will be removed in Gatsby v${version}. Please use "${altFunctionName}" instead.` - ) - export default React.forwardRef((props, ref) => ( )) @@ -284,19 +279,3 @@ export default React.forwardRef((props, ref) => ( export const navigate = (to, options) => { window.___navigate(rewriteLinkPath(to, window.location.pathname), options) } - -export const push = to => { - showDeprecationWarning(`push`, `navigate`, 3) - window.___push(rewriteLinkPath(to, window.location.pathname)) -} - -export const replace = to => { - showDeprecationWarning(`replace`, `navigate`, 3) - window.___replace(rewriteLinkPath(to, window.location.pathname)) -} - -// TODO: Remove navigateTo for Gatsby v3 -export const navigateTo = to => { - showDeprecationWarning(`navigateTo`, `navigate`, 3) - return push(to) -} diff --git a/packages/gatsby-link/src/parse-path.js b/packages/gatsby-link/src/parse-path.js index a281cf8854cb6..3ce61599b15bf 100644 --- a/packages/gatsby-link/src/parse-path.js +++ b/packages/gatsby-link/src/parse-path.js @@ -1,15 +1,15 @@ export function parsePath(path) { - var pathname = path || `/` - var search = `` - var hash = `` + let pathname = path || `/` + let search = `` + let hash = `` - var hashIndex = pathname.indexOf(`#`) + let hashIndex = pathname.indexOf(`#`) if (hashIndex !== -1) { hash = pathname.substr(hashIndex) pathname = pathname.substr(0, hashIndex) } - var searchIndex = pathname.indexOf(`?`) + let searchIndex = pathname.indexOf(`?`) if (searchIndex !== -1) { search = pathname.substr(searchIndex) pathname = pathname.substr(0, searchIndex) diff --git a/packages/gatsby/index.d.ts b/packages/gatsby/index.d.ts index 1151edeb1051a..7df718223a866 100644 --- a/packages/gatsby/index.d.ts +++ b/packages/gatsby/index.d.ts @@ -19,9 +19,6 @@ export { default as Link, GatsbyLinkProps, navigate, - navigateTo, - push, - replace, withPrefix, withAssetPrefix, } from "gatsby-link"