chore(plugin): add eslint to check no debug code in prod

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei
2024-09-24 16:37:46 +08:00
parent 280222a4aa
commit 41d1882dce
2 changed files with 36 additions and 0 deletions
+5
View File
@@ -2,6 +2,7 @@
import { defineConfig } from "eslint-config-hyoban"
import checkI18nJson from "./plugins/eslint-check-i18n-json.js"
import noDebug from "./plugins/eslint-no-debug.js"
import recursiveSort from "./plugins/eslint-recursive-sort.js"
export default defineConfig(
@@ -22,7 +23,11 @@ export default defineConfig(
whitelist: ["center"],
},
},
plugins: {
"no-debug": noDebug,
},
rules: {
"no-debug/no-debug-stack": "error",
"unicorn/prefer-math-trunc": "off",
"@eslint-react/no-clone-element": 0,
"@eslint-react/hooks-extra/no-direct-set-state-in-use-effect": 0,
+31
View File
@@ -0,0 +1,31 @@
/**
* @type {import("eslint").ESLint.Plugin}
*/
export default {
rules: {
"no-debug-stack": {
meta: {
type: "problem",
docs: {
description: "Disallow use of debugStack() function",
category: "Possible Errors",
recommended: true,
},
fixable: null,
},
create(context) {
return {
CallExpression(node) {
if (node.callee.type === "Identifier" && node.callee.name === "debugStack") {
context.report({
node,
message:
"Unexpected debugStack() statement. Remove debugStack() calls from production code.",
})
}
},
}
},
},
},
}