Skip to content

Commit

Permalink
feat(eslint-config): ban commonjs in js file
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Sep 18, 2023
1 parent 0a9be78 commit 2686f0b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-cheetahs-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@git-validator/eslint-config": patch
---

feat(eslint-config): ban commonjs in js file
10 changes: 6 additions & 4 deletions packages/eslint-config/src/js-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ export default {
// override standard config rules
"comma-dangle": ["error", "always-multiline"],
"brace-style": ["error", "1tbs", { allowSingleLine: false }], // https://github.com/standard/eslint-config-standard/pull/281
// `const fun = (foo: never) => foo['bar']` will be formatted to `const fun = (foo: never) => foo.bar`.
// it's incorrect when enabling ts-check. so turn it off.
"dot-notation": "off",
"dot-notation": "off", // conflict when enabling ts-check so turn it off

// code style for a better readability
"max-statements-per-line": ["error", { max: 1 }],
Expand All @@ -32,8 +30,12 @@ export default {
"arrow-body-style": ["error", "as-needed"],

// ban some syntaxes to reduce mistakes
"import/no-commonjs": [
"error",
{ allowRequire: false, allowConditionalRequire: false, allowPrimitiveModules: false },
],
"import/no-self-import": "error",
"import/no-dynamic-require": "error", // TODO remove it once we have ban commonjs in js file.
"import/no-dynamic-require": "error",
"import/no-relative-packages": "error",
"import/no-mutable-exports": "error", // forbid code like `export let count = 3`
// "import/no-named-as-default-member": "error", // forbid code like `import foo from './foo.js'; const bar = foo.bar;`
Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-config/src/ts-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,6 @@ export default {
"no-void": ["error", { allowAsStatement: true }],

// ban some syntaxes to reduce mistakes
"import/no-commonjs": [
"error",
{ allowRequire: false, allowConditionalRequire: false, allowPrimitiveModules: false },
], // TODO move this rule to base. js file should not use commonjs too.
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/method-signature-style": "error",
"@typescript-eslint/no-require-imports": "error",
Expand Down

0 comments on commit 2686f0b

Please sign in to comment.