chore: Adds deprecated-imports-next-router (#14486)
This commit is contained in:
1 parent
3084013269
commit
f2eebe95bd
9 files changed
+46
-13
No files matched your search
@@ -3,6 +3,7 @@ const recommended = {
|
||||
parserOptions: { sourceType: "module" },
|
||||
rules: {
|
||||
"@calcom/eslint/deprecated-imports": "error",
|
||||
"@calcom/eslint/deprecated-imports-next-router": "error",
|
||||
"@calcom/eslint/avoid-web-storage": "error",
|
||||
"@calcom/eslint/avoid-prisma-client-import-for-enums": "error",
|
||||
},
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { ESLintUtils } from "@typescript-eslint/utils";
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator((name) => `https://developer.cal.com/eslint/rule/${name}`);
|
||||
|
||||
const rule = createRule({
|
||||
name: "deprecated-imports-next-router",
|
||||
meta: {
|
||||
fixable: "code",
|
||||
docs: {
|
||||
description: "Importing router from 'next/router' is deprecated, use 'next/navigation' instead",
|
||||
recommended: "error",
|
||||
},
|
||||
messages: {
|
||||
"deprecated-next-router":
|
||||
"Importing router from 'next/router' is deprecated, use 'next/navigation' instead",
|
||||
},
|
||||
type: "problem",
|
||||
schema: [],
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
if (node.source.value === "next/router") {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "deprecated-next-router",
|
||||
fix: function (fixer) {
|
||||
return fixer.replaceText(node.source, "'next/navigation'");
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default rule;
|
||||
@@ -5,4 +5,5 @@ export default {
|
||||
"deprecated-imports": require("./deprecated-imports").default,
|
||||
"avoid-web-storage": require("./avoid-web-storage").default,
|
||||
"avoid-prisma-client-import-for-enums": require("./avoid-prisma-client-import-for-enums").default,
|
||||
"deprecated-imports-next-router": require("./deprecated-imports-next-router").default,
|
||||
} as ESLint.Plugin["rules"];
|
||||
Reference in new issue
Block a user