Skip to content

Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.

fix: flag welcome-back greetings with or without '!' (#30)

Nguyễn Tuấn Anh195b21816cc6
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index 34742b3..58a1963 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -767,10 +767,14 @@ const rules = [
family: "copy",
severity: "minor",
stacks: null,
- message: "\"Welcome back!\" spending prime screen space on a greeting.",
+ message: "\"Welcome back\" spending prime screen space on a greeting.",
fix: "Use that space for what a returning user came to do.",
find({ code }) {
- return [...matches(/welcome back\s*(?:,[^"'<\n]*)?!/i, code)].map((m) => m.index);
+ // Flag the greeting with or without "!": "Welcome back", "Welcome back,
+ // Sarah", "Welcome back!". The lookahead is the guard against prose:
+ // the greeting must end at punctuation, a string/JSX boundary, or the
+ // end of the line, so "Welcome back to the team page" stays quiet.
+ return [...matches(/welcome back\s*(?:,[^"'<\n]*)?(?=[!?.]|["'}]|\s*<|$)/i, code)].map((m) => m.index);
},
},
{
diff --git a/test/detect.test.js b/test/detect.test.js
index 685c475..623d47e 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -154,6 +154,17 @@ test("slop-gradient reads Android #AARRGGBB colors", () => {
assert.deepStrictEqual(scanSource(scrim, "a.css"), []);
});
+test("welcome-back fires with or without '!'", () => {
+ const withName = "export const A = () => <h1>Welcome back, {name}</h1>;\n";
+ const bare = "export const B = () => <h1>Welcome back</h1>;\n";
+ assert.deepStrictEqual(scanSource(withName, "a.tsx").map((f) => f.rule), ["welcome-back"]);
+ assert.deepStrictEqual(scanSource(bare, "a.tsx").map((f) => f.rule), ["welcome-back"]);
+ assert.deepStrictEqual(scanSource("<Text>Welcome back!</Text>\n", "a.tsx").map((f) => f.rule), ["welcome-back"]);
+ assert.deepStrictEqual(scanSource("<Text>Welcome back, Sarah</Text>\n", "a.tsx").map((f) => f.rule), ["welcome-back"]);
+ // Prose that only contains the words stays quiet.
+ assert.deepStrictEqual(scanSource("<p>Welcome back to the team page</p>\n", "a.tsx"), []);
+});
+
test("XML ignore comments work", () => {
const src = '<resources>\n <!-- unslop-anything-ignore template-theme -->\n <color name="purple_500">#6200EE</color>\n</resources>\n';
assert.deepStrictEqual(scanSource(src, "colors.xml"), []);