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.

Flag bare TextInput screens in keyboard-cover (#170)

Dani34d7b0e45b17
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.js
index d9bb155..cc543bd 100644
--- a/skills/unslop-anything/scripts/detect.js
+++ b/skills/unslop-anything/scripts/detect.js
@@ -1200,10 +1200,13 @@ const rules = [
stacks: ["js"],
message: "Screen with a text input and no keyboard handling. The keyboard may cover the field.",
fix: "Use KeyboardAvoidingView, automaticallyAdjustKeyboardInsets, or the project's keyboard library, and set keyboardShouldPersistTaps on the scroll view. Check it on a small phone.",
- find({ code }) {
+ find({ code, file }) {
const input = /<TextInput\b/.exec(code);
if (!input) return [];
- if (!/<(?:ScrollView|FlatList|FlashList|SafeAreaView|KeyboardAwareScrollView)\b/.test(code)) return [];
+ const where = file.replace(/\\/g, "/");
+ const name = path.basename(where).replace(/\.[^.]+$/, "");
+ const screenPath = /(?:^|\/)screens\//.test(where) || /Screen$/.test(name) || (/(?:^|\/)app\//.test(where) && !name.startsWith("_"));
+ if (!screenPath && !/<(?:ScrollView|FlatList|FlashList|SafeAreaView|KeyboardAwareScrollView)\b/.test(code)) return [];
if (/KeyboardAvoidingView|KeyboardAware|KeyboardProvider|KeyboardStickyView|KeyboardController|automaticallyAdjustKeyboardInsets|keyboardShouldPersistTaps/.test(code)) return [];
return [input.index];
},
diff --git a/test/detect.test.js b/test/detect.test.js
index d17f4c0..d21e5d0 100644
--- a/test/detect.test.js
+++ b/test/detect.test.js
@@ -2131,6 +2131,24 @@ test("drawer-nav catches React Native Paper's icon=\"menu\" (issue #226)", () =>
assert.deepStrictEqual(lines('<Appbar.Action icon="dots-vertical" />\n'), []);
});
+test("keyboard-cover flags a bare TextInput on a screen file, not in a reusable input", () => {
+ const rulesFor = (src, file) => scanSource(src, file).filter((f) => f.rule === "keyboard-cover").map((f) => f.line);
+ const bare = 'import { TextInput, View } from "react-native";\n\nexport default function Login() {\n return (\n <View>\n <TextInput placeholder="Email" />\n </View>\n );\n}\n';
+ assert.deepStrictEqual(rulesFor(bare, "app/login.tsx"), [6]);
+ assert.deepStrictEqual(rulesFor(bare, "app/(auth)/login.tsx"), [6]);
+ assert.deepStrictEqual(rulesFor(bare, "src/screens/LoginScreen.tsx"), [6]);
+ assert.deepStrictEqual(rulesFor(bare, "src/features/auth/LoginScreen.tsx"), [6]);
+ assert.deepStrictEqual(rulesFor(bare, "src\\screens\\Login.tsx"), [6]);
+ const searchBar = 'import { TextInput, View } from "react-native";\n\nexport function SearchBar({ value, onChange }) {\n return (\n <View style={styles.bar}>\n <TextInput value={value} onChangeText={onChange} placeholder="Search" />\n </View>\n );\n}\n';
+ assert.deepStrictEqual(rulesFor(searchBar, "components/SearchBar.tsx"), []);
+ assert.deepStrictEqual(rulesFor(searchBar, "app/_layout.tsx"), []);
+ assert.deepStrictEqual(rulesFor(searchBar, "src/myapp/SearchBar.tsx"), []);
+ const scroll = "<ScrollView>\n <TextInput placeholder=\"Email\" />\n</ScrollView>\n";
+ assert.deepStrictEqual(rulesFor(scroll, "components/Form.tsx"), [2]);
+ const handled = "<KeyboardAvoidingView behavior=\"padding\">\n <TextInput placeholder=\"Email\" />\n</KeyboardAvoidingView>\n";
+ assert.deepStrictEqual(rulesFor(handled, "app/login.tsx"), []);
+});
+
test("clickable-div flags Angular (click) and Alpine x-on:click handlers", () => {
const rulesFor = (src) => scanSource(src, "a.html").map((f) => f.rule);
assert.deepStrictEqual(rulesFor('<div class="card" (click)="open()">Details</div>\n'), ["clickable-div"]);