diff --git a/eslint.config.mjs b/eslint.config.mjs index 463795282..36d901c74 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -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, diff --git a/plugins/eslint-no-debug.js b/plugins/eslint-no-debug.js new file mode 100644 index 000000000..6a7683866 --- /dev/null +++ b/plugins/eslint-no-debug.js @@ -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.", + }) + } + }, + } + }, + }, + }, +}