Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(remix-eslint-config): enable deprecated imports warnings #3285

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 37 additions & 38 deletions packages/remix-eslint-config/rules/core.js
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
// const {
// defaultAdapterExports,
// defaultRuntimeExports,
// architectSpecificExports,
// cloudflareSpecificExports,
// cloudflarePagesSpecificExports,
// cloudflareWorkersSpecificExports,
// nodeSpecificExports,
// reactSpecificExports,
// } = require("./packageExports");
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. You can run \`remix migrate --migration replace-remix-imports\` to automatically migrate your code.`;
const getReplaceRemixImportsMessage = (packageName) =>
`All \`remix\` exports are considered deprecated as of v1.3.3. Please use \`@remix-run/${packageName}\` instead. You can run \`remix migrate --migration replace-remix-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",
// }));
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,
Expand Down Expand Up @@ -89,8 +89,7 @@ module.exports = {
"no-new-object": WARN,
"no-octal": WARN,
"no-redeclare": ERROR,
// TODO: once we officially deprecate this we can bring this back
// "no-restricted-imports": [WARN, ...replaceRemixImportsOptions],
"no-restricted-imports": [WARN, ...replaceRemixImportsOptions],
"no-script-url": WARN,
"no-self-assign": WARN,
"no-self-compare": WARN,
Expand Down