chore: add eslint rules to avoid importing from app-store#23518
chore: add eslint rules to avoid importing from app-store#23518anikdhabal merged 1 commit intomainfrom
Conversation
WalkthroughAdds an overrides array to .eslintrc.js. The override targets files in packages/lib//*.{ts,tsx,js,jsx} and packages/prisma//.{ts,tsx,js,jsx}. Within this scope, it configures the no-restricted-imports rule to "warn" for direct imports of @calcom/app-store and any subpath via the pattern @calcom/app-store/. No other configurations are modified. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.eslintrc.js (2)
9-16: Catch deep subpaths and optionally enforce as an error with a guidance message"@calcom/app-store/*" won’t match nested paths like "@calcom/app-store/foo/bar". Also, adding a message helps devs know what to do. Consider making it an error (or keep warn if you’re phasing in).
"no-restricted-imports": [ - "warn", + "error", { - paths: ["@calcom/app-store"], - patterns: ["@calcom/app-store/*"], + paths: [ + { + "name": "@calcom/app-store", + "message": "Do not import from app-store within lib/prisma. Depend on lib contracts or introduce an explicit interface." + } + ], + patterns: ["@calcom/app-store/**"], }, ],
7-7: Broaden file globs to cover ESM/TS variantsIf these packages contain mjs/mts/cjs/cts files, they’ll bypass the rule. Expand the glob to future-proof.
- files: ["packages/lib/**/*.{ts,tsx,js,jsx}", "packages/prisma/**/*.{ts,tsx,js,jsx}"], + files: [ + "packages/lib/**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}", + "packages/prisma/**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}" + ],
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.eslintrc.js(1 hunks)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Install dependencies / Yarn install & cache
| "no-restricted-imports": [ | ||
| "warn", | ||
| { | ||
| paths: ["@calcom/app-store"], | ||
| patterns: ["@calcom/app-store/*"], | ||
| }, | ||
| ], | ||
| }, |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Confirm policy on type-only imports
Do you want to allow import type { … } from "@calcom/app-store" in these layers? If yes, we can tweak the rule configuration to allow type-only imports for the pattern; if no, current approach will block them as well.
🏁 Script executed:
#!/bin/bash
# Find any direct or subpath imports from @calcom/app-store in lib/prisma
rg -nP -C1 --glob 'packages/lib/**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}' --glob 'packages/prisma/**/*.{ts,tsx,js,jsx,mts,mjs,cts,cjs}' \
$'(^\\s*import\\s+type\\s+.*?from\\s+[\'"]@calcom/app-store(?:/[^\'"]*)?[\'"]|^\\s*import\\s+.*?from\\s+[\'"]@calcom/app-store(?:/[^\'"]*)?[\'"]|require\\(\\s*[\'"]@calcom/app-store(?:/[^\'"]*)?[\'"]\\s*\\)|import\\(\\s*[\'"]@calcom/app-store(?:/[^\'"]*)?[\'"]\\s*\\))'Length of output: 21103
Permit or block type-only @calcom/app-store imports
The rule will currently forbid all imports—including import type—but we’re using type-only imports across lib/ and prisma/; add allowTypeImports: true to only restrict runtime imports.
.eslintrc.js (lines 9–16)
"no-restricted-imports": [
"warn",
{
paths: ["@calcom/app-store"],
patterns: ["@calcom/app-store/*"],
+ allowTypeImports: true,
},
],📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "no-restricted-imports": [ | |
| "warn", | |
| { | |
| paths: ["@calcom/app-store"], | |
| patterns: ["@calcom/app-store/*"], | |
| }, | |
| ], | |
| }, | |
| "no-restricted-imports": [ | |
| "warn", | |
| { | |
| paths: ["@calcom/app-store"], | |
| patterns: ["@calcom/app-store/*"], | |
| allowTypeImports: true, | |
| }, | |
| ], |
🤖 Prompt for AI Agents
.eslintrc.js around lines 9 to 16: the "no-restricted-imports" rule currently
blocks all imports from "@calcom/app-store" including type-only imports; update
the rule configuration to allow TypeScript type-only imports by adding
"allowTypeImports: true" to the rule options so only runtime imports are
restricted, leaving existing paths/patterns intact.
E2E results are ready! |
What does this PR do?
Add some eslint rules to avoid importing from app-store inside lib and prisma modules. This was added as
warninstead oferrorto avoid building errors.