summaryrefslogtreecommitdiff
path: root/eslint.config.js
diff options
context:
space:
mode:
authorBrandon Keiji <[email protected]>2025-04-21 08:02:11 -0700
committerGitHub <[email protected]>2025-04-21 08:02:11 -0700
commite351baf10f06d2a1d1872bf2a6d7e9e709effed9 (patch)
treec4f21e287f0a8e4cecf995636aa1baf948962453 /eslint.config.js
parent39bdedab9c218ca1e4eb7204e7c1dd085be98635 (diff)
feat: add custom eslint rule for cross-package imports (#77)
Diffstat (limited to 'eslint.config.js')
-rw-r--r--eslint.config.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/eslint.config.js b/eslint.config.js
index a846d22d..16577628 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -13,6 +13,17 @@ import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import globals from 'globals';
import licenseHeader from 'eslint-plugin-license-header';
+import noRelativeCrossPackageImports from './eslint-rules/no-relative-cross-package-imports.js';
+import path from 'node:path'; // Use node: prefix for built-ins
+import url from 'node:url';
+
+// --- ESM way to get __dirname ---
+const __filename = url.fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
+// --- ---
+
+// Determine the monorepo root (assuming eslint.config.js is at the root)
+const projectRoot = __dirname;
export default tseslint.config(
{
@@ -22,6 +33,7 @@ export default tseslint.config(
'eslint.config.js',
'packages/cli/dist/**',
'packages/server/dist/**',
+ 'eslint-rules/*',
],
},
eslint.configs.recommended,
@@ -163,4 +175,24 @@ export default tseslint.config(
},
// Prettier config must be last
prettierConfig,
+ // Custom eslint rules for this repo
+ {
+ files: ['packages/**/*.{js,jsx,ts,tsx}'],
+ plugins: {
+ custom: {
+ rules: {
+ 'no-relative-cross-package-imports': noRelativeCrossPackageImports,
+ },
+ },
+ },
+ rules: {
+ // Enable and configure your custom rule
+ 'custom/no-relative-cross-package-imports': [
+ 'error',
+ {
+ root: path.join(projectRoot, 'packages'),
+ },
+ ],
+ },
+ },
);