chore: eslint rule for blocking importing features from appstore, lib, prisma (#23832)
* eslint rule * improve * fix * improve msg
This commit is contained in:
1 parent
7fbeeae25b
commit
ef8b0fa41c
1 file changed
+83
-8
+83
-8
@@ -1,4 +1,3 @@
|
|||||||
// This configuration only applies to the package manager root.
|
|
||||||
/** @type {import("eslint").Linter.Config} */
|
/** @type {import("eslint").Linter.Config} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extends: ["./packages/config/eslint-preset.js"],
|
extends: ["./packages/config/eslint-preset.js"],
|
||||||
@@ -7,29 +6,105 @@ module.exports = {
|
|||||||
"import/no-cycle": ["warn", { maxDepth: Infinity }],
|
"import/no-cycle": ["warn", { maxDepth: Infinity }],
|
||||||
},
|
},
|
||||||
overrides: [
|
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: {
|
rules: {
|
||||||
"no-restricted-imports": [
|
"no-restricted-imports": [
|
||||||
"warn",
|
"warn",
|
||||||
{
|
{
|
||||||
paths: ["@calcom/app-store"],
|
patterns: [
|
||||||
patterns: ["@calcom/app-store/*"],
|
{
|
||||||
|
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}"],
|
files: ["packages/app-store/**/*.{ts,tsx,js,jsx}"],
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-restricted-imports": [
|
"no-restricted-imports": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
patterns: [
|
patterns: [
|
||||||
{
|
{
|
||||||
group: ["@calcom/trpc/*", "@trpc/*"],
|
group: [
|
||||||
message: "tRPC imports are blocked in packages/app-store. Move UI to apps/web/components/apps or introduce an API boundary.",
|
// Catch all relative paths into trpc
|
||||||
allowTypeImports: false,
|
"**/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: [
|
||||||
|
// Catch all relative paths into features
|
||||||
|
"**/features",
|
||||||
|
"**/features/*",
|
||||||
|
// Catch all alias imports
|
||||||
|
"@calcom/features",
|
||||||
|
"@calcom/features/*",
|
||||||
|
],
|
||||||
|
message: "Avoid importing @calcom/features from @calcom/prisma.",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user