Skip to content

Scheduling infrastructure for absolutely everyone.

chore: eslint rule for blocking importing features from appstore, lib, prisma (#23832)

Benny Jooef8b0fa41cb7
diff --git a/.eslintrc.js b/.eslintrc.js
index 43c0cd83593..6d6b21761b4 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,4 +1,3 @@
-// This configuration only applies to the package manager root.
/** @type {import("eslint").Linter.Config} */
module.exports = {
extends: ["./packages/config/eslint-preset.js"],
@@ -7,29 +6,105 @@ module.exports = {
"import/no-cycle": ["warn", { maxDepth: Infinity }],
},
overrides: [
+ // WARN: features must not be imported by app-store or lib
{
- files: ["packages/lib/**/*.{ts,tsx,js,jsx}", "packages/prisma/**/*.{ts,tsx,js,jsx}"],
+ files: ["packages/app-store/**/*.{ts,tsx,js,jsx}", "packages/lib/**/*.{ts,tsx,js,jsx}"],
rules: {
"no-restricted-imports": [
"warn",
{
- paths: ["@calcom/app-store"],
- patterns: ["@calcom/app-store/*"],
+ patterns: [
+ {
+ group: [
+ // Catch all relative paths into features
+ "**/features",
+ "**/features/*",
+ // Catch all alias imports
+ "@calcom/features",
+ "@calcom/features/*",
+ ],
+ message: "Avoid importing @calcom/features from @calcom/app-store or @calcom/lib.",
+ },
+ ],
},
],
},
},
+ // WARN: lib must not import app-store or features
+ {
+ files: ["packages/lib/**/*.{ts,tsx,js,jsx}"],
+ rules: {
+ "no-restricted-imports": [
+ "warn",
+ {
+ patterns: [
+ {
+ group: [
+ // Catch all relative paths into app-store
+ "**/app-store",
+ "**/app-store/*",
+ // Catch all relative paths into features
+ "**/features",
+ "**/features/*",
+ // Catch alias imports
+ "@calcom/app-store",
+ "@calcom/app-store/*",
+ "@calcom/features",
+ "@calcom/features/*",
+ ],
+ message: "@calcom/lib should not import @calcom/app-store or @calcom/features.",
+ },
+ ],
+ },
+ ],
+ },
+ },
+ // ERROR: app-store must not import trpc
{
files: ["packages/app-store/**/*.{ts,tsx,js,jsx}"],
rules: {
- "@typescript-eslint/no-restricted-imports": [
+ "no-restricted-imports": [
+ "error",
+ {
+ patterns: [
+ {
+ group: [
+ // Catch all relative paths into trpc
+ "**/trpc",
+ "**/trpc/*",
+ // Catch alias imports
+ "@calcom/trpc",
+ "@calcom/trpc/*",
+ "@trpc",
+ "@trpc/*",
+ ],
+ message:
+ "@calcom/app-store must not import trpc. Move UI to apps/web/components/apps or introduce an API boundary.",
+ },
+ ],
+ },
+ ],
+ },
+ },
+
+ // ERROR: prisma must not import `features` package
+ {
+ files: ["packages/prisma/**/*.{ts,tsx,js,jsx}"],
+ rules: {
+ "no-restricted-imports": [
"error",
{
patterns: [
{
- group: ["@calcom/trpc/*", "@trpc/*"],
- message: "tRPC imports are blocked in packages/app-store. Move UI to apps/web/components/apps or introduce an API boundary.",
- allowTypeImports: false,
+ group: [
+ // Catch all relative paths into features
+ "**/features",
+ "**/features/*",
+ // Catch all alias imports
+ "@calcom/features",
+ "@calcom/features/*",
+ ],
+ message: "Avoid importing @calcom/features from @calcom/prisma.",
},
],
},