From 82bad539dfc417e52ca680443a641bd9f9b15a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 20 Jul 2023 21:44:02 +0200 Subject: [PATCH] feat(remix-eslint-config)!: remove magic imports ESLint warnings (#6902) --- .../remove-magic-import-eslint-warnings.md | 5 + packages/remix-eslint-config/rules/core.js | 40 ----- .../rules/packageExports.js | 163 ------------------ 3 files changed, 5 insertions(+), 203 deletions(-) create mode 100644 .changeset/remove-magic-import-eslint-warnings.md delete mode 100644 packages/remix-eslint-config/rules/packageExports.js diff --git a/.changeset/remove-magic-import-eslint-warnings.md b/.changeset/remove-magic-import-eslint-warnings.md new file mode 100644 index 00000000000..da5994b7af5 --- /dev/null +++ b/.changeset/remove-magic-import-eslint-warnings.md @@ -0,0 +1,5 @@ +--- +"@remix-run/eslint-config": major +--- + +Remove magic imports ESLint warnings diff --git a/packages/remix-eslint-config/rules/core.js b/packages/remix-eslint-config/rules/core.js index 4da8a821cb9..1e760f6e6ec 100644 --- a/packages/remix-eslint-config/rules/core.js +++ b/packages/remix-eslint-config/rules/core.js @@ -1,46 +1,7 @@ -const { - defaultAdapterExports, - defaultRuntimeExports, - architectSpecificExports, - cloudflareSpecificExports, - cloudflarePagesSpecificExports, - cloudflareWorkersSpecificExports, - nodeSpecificExports, - reactSpecificExports, -} = require("./packageExports"); - // const OFF = 0; const WARN = 1; const ERROR = 2; -const getReplaceRemixImportsMessage = (packageName) => - `All \`remix\` exports are considered deprecated as of v1.3.3. Please use \`@remix-run/${packageName}\` instead. Run \`npx @remix-run/dev@latest codemod replace-remix-magic-imports\` to automatically migrate your code.`; - -const replaceRemixImportsOptions = [ - { - packageExports: defaultAdapterExports, - packageName: - "{architect|cloudflare-pages|cloudflare-workers|express|netlify|vercel}", - }, - { packageExports: defaultRuntimeExports, packageName: "{cloudflare|node}" }, - { packageExports: architectSpecificExports, packageName: "architect" }, - { packageExports: cloudflareSpecificExports, packageName: "cloudflare" }, - { - packageExports: cloudflarePagesSpecificExports, - packageName: "cloudflare-pages", - }, - { - packageExports: cloudflareWorkersSpecificExports, - packageName: "cloudflare-workers", - }, - { packageExports: nodeSpecificExports, packageName: "node" }, - { packageExports: reactSpecificExports, packageName: "react" }, -].map(({ packageExports, packageName }) => ({ - importNames: [...packageExports.value, ...packageExports.type], - message: getReplaceRemixImportsMessage(packageName), - name: "remix", -})); - module.exports = { "array-callback-return": WARN, "getter-return": WARN, @@ -88,7 +49,6 @@ module.exports = { "no-new-object": WARN, "no-octal": WARN, "no-redeclare": ERROR, - "no-restricted-imports": [WARN, ...replaceRemixImportsOptions], "no-script-url": WARN, "no-self-assign": WARN, "no-self-compare": WARN, diff --git a/packages/remix-eslint-config/rules/packageExports.js b/packages/remix-eslint-config/rules/packageExports.js deleted file mode 100644 index 827df215954..00000000000 --- a/packages/remix-eslint-config/rules/packageExports.js +++ /dev/null @@ -1,163 +0,0 @@ -const defaultAdapterExports = { - value: ["createRequestHandler"], - type: ["GetLoadContextFunction", "RequestHandler"], -}; - -const defaultRuntimeExports = { - value: [ - "createCookie", - "createCookieSessionStorage", - "createMemorySessionStorage", - "createRequestHandler", - "createSession", - "createSessionStorage", - "isCookie", - "isSession", - "json", - "MaxPartSizeExceededError", - "redirect", - "unstable_composeUploadHandlers", - "unstable_createMemoryUploadHandler", - "unstable_parseMultipartFormData", - ], - type: [ - "ActionFunction", - "AppData", - "AppLoadContext", - "Cookie", - "CookieOptions", - "CookieParseOptions", - "CookieSerializeOptions", - "CookieSignatureOptions", - "CreateRequestHandlerFunction", - "DataFunctionArgs", - "EntryContext", - "ErrorBoundaryComponent", - "HandleDataRequestFunction", - "HandleDocumentRequestFunction", - "HeadersArgs", - "HeadersFunction", - "HtmlLinkDescriptor", - "HtmlMetaDescriptor", - "LinkDescriptor", - "LinksFunction", - "LoaderFunction", - "MemoryUploadHandlerFilterArgs", - "MemoryUploadHandlerOptions", - "MetaDescriptor", - "MetaFunction", - "HandleErrorFunction", - "PageLinkDescriptor", - "RequestHandler", - "RouteComponent", - "RouteHandle", - "ServerBuild", - "ServerEntryModule", - "Session", - "SessionData", - "SessionIdStorageStrategy", - "SessionStorage", - "UploadHandler", - "UploadHandlerPart", - ], -}; - -const architectSpecificExports = { - value: ["createArcTableSessionStorage"], - type: [], -}; - -const cloudflareSpecificExports = { - value: ["createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"], - type: [], -}; - -const cloudflarePagesSpecificExports = { - value: ["createPagesFunctionHandler"], - type: ["createPagesFunctionHandlerParams"], -}; - -const cloudflareWorkersSpecificExports = { - value: ["createEventHandler", "handleAsset"], - type: [], -}; - -const nodeSpecificExports = { - value: [ - "AbortController", - "createFileSessionStorage", - "createReadableStreamFromReadable", - "fetch", - "FormData", - "Headers", - "installGlobals", - "NodeOnDiskFile", - "readableStreamToString", - "Request", - "Response", - "unstable_createFileUploadHandler", - "writeAsyncIterableToWritable", - "writeReadableStreamToWritable", - ], - type: ["HeadersInit", "RequestInfo", "RequestInit", "ResponseInit"], -}; - -const reactSpecificExports = { - value: [ - "Form", - "Link", - "Links", - "LiveReload", - "Meta", - "NavLink", - "Outlet", - "PrefetchPageLinks", - "RemixBrowser", - "RemixServer", - "Scripts", - "ScrollRestoration", - "useActionData", - "useBeforeUnload", - "useCatch", - "useFetcher", - "useFetchers", - "useFormAction", - "useHref", - "useLoaderData", - "useLocation", - "useMatches", - "useNavigate", - "useNavigationType", - "useOutlet", - "useOutletContext", - "useParams", - "useResolvedPath", - "useSearchParams", - "useSubmit", - ], - type: [ - "FormEncType", - "FormMethod", - "FormProps", - "HtmlLinkDescriptor", - "HtmlMetaDescriptor", - "LinkProps", - "NavLinkProps", - "RemixBrowserProps", - "RemixServerProps", - "SubmitFunction", - "SubmitOptions", - "ThrownResponse", - ], -}; - -module.exports = { - defaultAdapterExports, - defaultRuntimeExports, - architectSpecificExports, - cloudflareSpecificExports, - cloudflarePagesSpecificExports, - cloudflareWorkersSpecificExports, - nodeSpecificExports, - reactSpecificExports, -};