-
Notifications
You must be signed in to change notification settings - Fork 11.7k
chore: eslint rule for blocking importing features from appstore, lib, prisma #23832
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
Changes from 4 commits
6549534
9cfc88d
3acfe9e
a1f62d5
d64e3d0
114d2d1
d7d8773
162b67f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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,85 @@ module.exports = { | |
| "import/no-cycle": ["warn", { maxDepth: Infinity }], | ||
| }, | ||
| overrides: [ | ||
| // WARN: features must not be imported by app-store, prisma, or lib | ||
| { | ||
| files: ["packages/lib/**/*.{ts,tsx,js,jsx}", "packages/prisma/**/*.{ts,tsx,js,jsx}"], | ||
| files: [ | ||
| "packages/app-store/**/*.{ts,tsx,js,jsx}", | ||
| "packages/prisma/**/*.{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/*", | ||
|
Comment on lines
+19
to
+21
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might throw for valid imports e.g., importing a folder named features within the same package. |
||
| // Catch all alias imports | ||
| "@calcom/features", | ||
| "@calcom/features/*", | ||
| ], | ||
| message: | ||
| "Avoid importing @calcom/features from @calcom/app-store, @calcom/prisma, or @calcom/lib.", | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| // WARN: lib must not import app-store or features | ||
hbjORbj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| 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: ["@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 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.", | ||
| }, | ||
| ], | ||
| }, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patternsalone is sufficient