From c6d367a76f38ecfc83e894a3d2143bf29651b6c4 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Fri, 26 Dec 2025 10:11:08 +0800 Subject: [PATCH] lint update --- web/eslint-rules/rules/no-legacy-namespace-prefix.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/eslint-rules/rules/no-legacy-namespace-prefix.js b/web/eslint-rules/rules/no-legacy-namespace-prefix.js index b61aca6ad1..1159806cca 100644 --- a/web/eslint-rules/rules/no-legacy-namespace-prefix.js +++ b/web/eslint-rules/rules/no-legacy-namespace-prefix.js @@ -310,11 +310,15 @@ export default { fixes.push(fixer.insertTextBefore(firstProp, `ns: '${ns}', `)) } } + else if (hasSecondArg && secondArg.type === 'Literal' && typeof secondArg.value === 'string') { + // Second arg is a string (default value): 'default' -> { ns: 'xxx', defaultValue: 'default' } + fixes.push(fixer.replaceText(secondArg, `{ ns: '${ns}', defaultValue: ${sourceCode.getText(secondArg)} }`)) + } else if (!hasSecondArg) { // No second argument, add new object fixes.push(fixer.insertTextAfter(originalFirstArg, `, { ns: '${ns}' }`)) } - // If second arg exists but is not an object, skip (can't safely add ns) + // If second arg exists but is not an object or string, skip (can't safely add ns) } if (firstArg.type === 'Literal' && typeof firstArg.value === 'string') {