summaryrefslogtreecommitdiff
path: root/eslint.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'eslint.config.js')
-rw-r--r--eslint.config.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/eslint.config.js b/eslint.config.js
index 5483f8aa..668930f6 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -154,6 +154,34 @@ export default tseslint.config(
},
},
},
+ // Override for .cjs files to use CommonJS
+ {
+ files: ['**/*.cjs'],
+ languageOptions: {
+ sourceType: 'commonjs',
+ globals: {
+ ...globals.node, // Add all Node.js globals
+ __dirname: 'readonly',
+ __filename: 'readonly',
+ exports: 'writable',
+ module: 'readonly',
+ require: 'readonly',
+ },
+ },
+ rules: {
+ // Disable rules that are not applicable to CommonJS
+ '@typescript-eslint/no-require-imports': 'off',
+ 'no-restricted-syntax': [
+ 'error',
+ // Keep other restricted syntaxes, but allow require for .cjs
+ {
+ selector: 'ThrowStatement > Literal:not([value=/^\\\\w+Error:/])',
+ message:
+ 'Do not throw string literals or non-Error objects. Throw new Error("...") instead.',
+ },
+ ],
+ },
+ },
// Prettier config must be last
prettierConfig,
// Custom eslint rules for this repo