Skip to content

Commit ef8b0fa

Browse files
authored
chore: eslint rule for blocking importing features from appstore, lib, prisma (calcom#23832)
* eslint rule * improve * fix * improve msg
1 parent 7fbeeae commit ef8b0fa

1 file changed

Lines changed: 83 additions & 8 deletions

File tree

.eslintrc.js

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// This configuration only applies to the package manager root.
21
/** @type {import("eslint").Linter.Config} */
32
module.exports = {
43
extends: ["./packages/config/eslint-preset.js"],
@@ -7,29 +6,105 @@ module.exports = {
76
"import/no-cycle": ["warn", { maxDepth: Infinity }],
87
},
98
overrides: [
9+
// WARN: features must not be imported by app-store or lib
1010
{
11-
files: ["packages/lib/**/*.{ts,tsx,js,jsx}", "packages/prisma/**/*.{ts,tsx,js,jsx}"],
11+
files: ["packages/app-store/**/*.{ts,tsx,js,jsx}", "packages/lib/**/*.{ts,tsx,js,jsx}"],
1212
rules: {
1313
"no-restricted-imports": [
1414
"warn",
1515
{
16-
paths: ["@calcom/app-store"],
17-
patterns: ["@calcom/app-store/*"],
16+
patterns: [
17+
{
18+
group: [
19+
// Catch all relative paths into features
20+
"**/features",
21+
"**/features/*",
22+
// Catch all alias imports
23+
"@calcom/features",
24+
"@calcom/features/*",
25+
],
26+
message: "Avoid importing @calcom/features from @calcom/app-store or @calcom/lib.",
27+
},
28+
],
1829
},
1930
],
2031
},
2132
},
33+
// WARN: lib must not import app-store or features
34+
{
35+
files: ["packages/lib/**/*.{ts,tsx,js,jsx}"],
36+
rules: {
37+
"no-restricted-imports": [
38+
"warn",
39+
{
40+
patterns: [
41+
{
42+
group: [
43+
// Catch all relative paths into app-store
44+
"**/app-store",
45+
"**/app-store/*",
46+
// Catch all relative paths into features
47+
"**/features",
48+
"**/features/*",
49+
// Catch alias imports
50+
"@calcom/app-store",
51+
"@calcom/app-store/*",
52+
"@calcom/features",
53+
"@calcom/features/*",
54+
],
55+
message: "@calcom/lib should not import @calcom/app-store or @calcom/features.",
56+
},
57+
],
58+
},
59+
],
60+
},
61+
},
62+
// ERROR: app-store must not import trpc
2263
{
2364
files: ["packages/app-store/**/*.{ts,tsx,js,jsx}"],
2465
rules: {
25-
"@typescript-eslint/no-restricted-imports": [
66+
"no-restricted-imports": [
67+
"error",
68+
{
69+
patterns: [
70+
{
71+
group: [
72+
// Catch all relative paths into trpc
73+
"**/trpc",
74+
"**/trpc/*",
75+
// Catch alias imports
76+
"@calcom/trpc",
77+
"@calcom/trpc/*",
78+
"@trpc",
79+
"@trpc/*",
80+
],
81+
message:
82+
"@calcom/app-store must not import trpc. Move UI to apps/web/components/apps or introduce an API boundary.",
83+
},
84+
],
85+
},
86+
],
87+
},
88+
},
89+
90+
// ERROR: prisma must not import `features` package
91+
{
92+
files: ["packages/prisma/**/*.{ts,tsx,js,jsx}"],
93+
rules: {
94+
"no-restricted-imports": [
2695
"error",
2796
{
2897
patterns: [
2998
{
30-
group: ["@calcom/trpc/*", "@trpc/*"],
31-
message: "tRPC imports are blocked in packages/app-store. Move UI to apps/web/components/apps or introduce an API boundary.",
32-
allowTypeImports: false,
99+
group: [
100+
// Catch all relative paths into features
101+
"**/features",
102+
"**/features/*",
103+
// Catch all alias imports
104+
"@calcom/features",
105+
"@calcom/features/*",
106+
],
107+
message: "Avoid importing @calcom/features from @calcom/prisma.",
33108
},
34109
],
35110
},

0 commit comments

Comments
 (0)