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(detect): treat AvoidSoftInputView as keyboard handling in keyboard-cover (#309)

Jayb1ff5fb6928f
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index a0cfb42..ec95db3 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1229,6 +1229,9 @@ const rules = [
// useAnimatedKeyboard, or useKeyboardHandler / useReanimatedKeyboardAnimation from
// react-native-keyboard-controller (#286). The hook has to be called, not just imported.
if (/\b(?:useAnimatedKeyboard|useKeyboardHandler|useReanimatedKeyboardAnimation)\s*\(/.test(code)) return [];
+ // react-native-avoid-softinput (#306): an opening <AvoidSoftInputView> tag or an app-wide
+ // AvoidSoftInput.setEnabled(true) call handles the keyboard. A bare import does not count.
+ if (/<AvoidSoftInputView\b/.test(code) || /\bAvoidSoftInput\.setEnabled\s*\(\s*true\s*,?\s*\)/.test(code)) return [];
return [input.index];
},
},
diff --git a/test/detect.test.js b/test/detect.test.js
index 72e3240..e2930a9 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -2628,6 +2628,43 @@ test("keyboard-cover flags a bare TextInput on a screen file, not in a reusable
assert.deepStrictEqual(rulesFor(handled, "app/login.tsx"), []);
});
+test("keyboard-cover stays quiet for react-native-avoid-softinput (issue #306)", () => {
+ const rulesFor = (src, file = "app/chat.tsx") => scanSource(src, file).filter((f) => f.rule === "keyboard-cover").map((f) => f.line);
+ const screen = (importLine, body) => [
+ importLine,
+ 'import { TextInput, View } from "react-native";',
+ "",
+ "export default function Chat() {",
+ ...(body ? [` ${body}`] : []),
+ " return (",
+ " <View>",
+ ' <TextInput placeholder="Message" />',
+ " </View>",
+ " );",
+ "}",
+ ].join("\n");
+ const avoid = 'import { AvoidSoftInputView } from "react-native-avoid-softinput";';
+ // Issue #306 repro: wrapped in AvoidSoftInputView
+ const wrapped = [
+ 'import { TextInput } from "react-native";',
+ 'import { AvoidSoftInputView } from "react-native-avoid-softinput";',
+ "",
+ "export default function Chat() {",
+ " return (",
+ " <AvoidSoftInputView>",
+ ' <TextInput placeholder="Message" />',
+ " </AvoidSoftInputView>",
+ " );",
+ "}",
+ ].join("\n");
+ assert.deepStrictEqual(rulesFor(wrapped), []);
+ // Enabled app-wide through the module-level API
+ assert.deepStrictEqual(rulesFor(screen(avoid, "AvoidSoftInput.setEnabled(true);")), []);
+ assert.deepStrictEqual(rulesFor(screen(avoid, "AvoidSoftInput.setEnabled(false);")), [8]);
+ // Imported but never used: still flagged
+ assert.deepStrictEqual(rulesFor(screen(avoid, "")), [7]);
+});
+
test("keyboard-cover stays quiet when a screen calls a keyboard hook (issue #286)", () => {
const rulesFor = (src, file = "app/chat.tsx") => scanSource(src, file).filter((f) => f.rule === "keyboard-cover").map((f) => f.line);
// Issue #286 repro: