chore: deep maintenance overhaul — builder-bob, ESLint 9, CI, tests, validator fixes & README rewrite#586
Open
kuraydev wants to merge 7 commits into
Open
chore: deep maintenance overhaul — builder-bob, ESLint 9, CI, tests, validator fixes & README rewrite#586kuraydev wants to merge 7 commits into
kuraydev wants to merge 7 commits into
Conversation
- Move source from lib/ to src/. - Fix passwordValidator regex (\\d -> \d) so the digit rule actually applies. - Guard LayoutAnimation on Android via setLayoutAnimationEnabledExperimental. - Replace any-typed props (logoImageSource, children, TouchableComponent) and rewrite useStateWithCallback with real generics. - Wrap LoginScreen in React.memo; memoize render helpers and tooltip content. - Derive widths from useWindowDimensions instead of a module-load Dimensions read. - Add accessibilityRole/accessibilityLabel to buttons and inputs. - Export prop types and password pattern presets from the barrel.
- Replace bespoke tsc+cpx+react-native-typescript-transformer pipeline with react-native-builder-bob (commonjs/module/typescript targets). - Add main/module/types/react-native/source/exports/files fields; keep the default + named exports and bare package-name import working. - Declare react/react-native peerDependencies (wide ranges) and bound react-native-text-input-interactive to >=0.1.4 <1.0.0. - Repoint repository/homepage/bugs/author URLs to kuraydev (npm name unchanged). - Drop dead deps (tslint ref, react-native-typescript-transformer, @types/react-native, cpx, npm-post-install, prettier-format, airbnb config). - Replace dead tslint lint script with ESLint 9 flat config; fix format glob. - Wire husky pre-commit to lint-staged.
Unit tests for emailValidator and passwordValidator (incl. the \d regression), plus render/interaction tests for LoginScreen and SocialButton.
CI runs install, lint, typecheck, test and build on a Node 18/20/22 matrix. A manual release workflow drives semantic-release. Adds issue + PR templates.
Fix the duplicated/incorrect props tables, document enablePasswordValidation, SocialButton, the exported validators and pattern presets, reconcile the dependency note, and add New Architecture/Expo/web platform guidance.
react-native-web does not implement LayoutAnimation, so the unconditional LayoutAnimation.spring() calls in the email/password validation flow threw or warned on web, breaking LoginScreen there (closes #56, #11). Add a web-only springLayoutAnimation() helper that no-ops on Platform.OS === "web" and runs the exact native animation everywhere else, so iOS/Android behavior is byte-for-byte unchanged. Bundled PNG assets already carry explicit width/height, so they render under RNW. Add a web smoke test (Platform.OS === "web") asserting the component renders without throwing and the tooltip degrades gracefully without invoking LayoutAnimation. Update README web-support note and CHANGELOG.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review fixes applied: bumped
package.jsonto6.0.0(was still5.0.0, identical to the last-published version) and retitled theCHANGELOG[Unreleased]section to[6.0.0], per the recommended major below.Summary
A full maintenance overhaul of
react-native-login-screenafter ~3.3 years without a release. The library's public API — exported names,ILoginScreenPropsprop names, and every runtime default value — is unchanged. The default export (import LoginScreen from "react-native-login-screen") and named exports (SocialButton,emailValidator,passwordValidator) still resolve exactly as before. The npm package name and license are untouched. Changes cluster into: broken-tooling repair, real tests + CI, packaging modernization, pure bug fixes, and a README rewrite.All work is verified locally (see Verification).
Non-breaking improvements
Tooling
tslint -p tsconfig.jsonlint script (TSLint removed from npm since 2019, not installed) witheslint ...eslintrc.jsto an ESLint 9 flateslint.config.js(typescript-eslint+eslint-plugin-react+react-hooks+eslint-config-prettier).formatscript glob (it targeted a non-existentsrc/**on the old layout).lint-stagedpre-commit,commitlintcommit-msg).CI / release
.github/workflows/ci.yml: install + lint + typecheck (tsc --noEmit) + test (with coverage) + build on a Node 18/20/22 matrix, on push/PR..github/workflows/release.yml(manual dispatch) wiring up the already-presentsemantic-release.Tests (library had zero)
@testing-library/react-native, 24 tests:emailValidator,passwordValidator(incl. the strength patterns),SocialButton, andLoginScreencovering rendering, text/placeholder overrides,disableSignup/disableSocialButtons/disablePasswordInput, the change/press handlers, email-validation tooltip behavior, and custom-button slots.Source quality (no public-API change)
anytypes:logoImageSource→ImageSourcePropType,children→React.ReactNode,TouchableComponent→ a realTouchableComponentType, and rewroteuseStateWithCallbackwith real generics.UIManager.setLayoutAnimationEnabledExperimental(true)guard so tooltipLayoutAnimation.spring()calls actually animate.Dimensions.get('screen')touseWindowDimensions()for responsive re-layout.React.memoand memoized therender*helpers and default tooltip content.accessibilityRole/accessibilityLabelto the login button, signup link, social buttons, and inputs.Packaging / metadata
kuraydev; kept the npm namereact-native-login-screen.react(>=16.8.0) andreact-native(>=0.60.0) peerDependencies with intentionally wide ranges.filesallowlist and explicittypes/module/react-native/source/exportsfields.tslintreference,@types/react-native,react-native-typescript-transformer,npm-post-install,prettier-format,eslint-config-airbnb.Docs / hygiene
disableEmailTooltiprow (was listed 3× with copy-pasted wrong descriptions) and the duplicated style/button rows; documentedenablePasswordValidation; added aSocialButtonprops table and exported-helper docs; added a ToC, TypeScript usage, and a New Architecture / Expo / web-support section; reconciled the peer-dep description.CHANGELOG.md(Keep a Changelog),CONTRIBUTING.md,.github/ISSUE_TEMPLATE/*, andPULL_REQUEST_TEMPLATE.md.Breaking changes (v6.0.0 major)
build/dist/*tolib/{commonjs,module,typescript}/*;main→lib/commonjs/index.jsand anexportsmap is added. The bare package import is preserved, but deep imports intobuild/dist/*(or the oldlib/*.tssource) will break.patternNormal/Medium/Highused\\d(literal backslash+d) and never matched digits; now corrected to\d. Passwords that passed the broken validation may now fail. Limited blast radius —enablePasswordValidationdefaults tofalse.react-native-text-input-interactivetightened from open-ended>=0.1.4to>=0.1.4 <1.0.0.react/react-nativeare now declared (very wide ranges); consumers may see new peer warnings.anyprops are now properly typed; strongly-typed consumers passing previously-anyvalues may surface new compile-time errors. No prop names or runtime defaults changed.Verification
Run on this branch (node 20 / npm 10):
npx tsc --noEmitnpx eslint .npx jestnpx bob buildfs.existsSync(main/module/types)Public
ILoginScreenPropsprop names and every runtime default are byte-identical tomaster.lib/is gitignored so no build artifacts are committed.Web issues
The two open web issues are addressed via documentation (react-native-web caveats around
Dimensions,require()'d PNG assets, andLayoutAnimation) plus theuseWindowDimensionsswap and the Android LayoutAnimation guard, rather than a verified web-rendering fix:react-native-web support (Closes #56, #11)
LoginScreenis a pure-JS component, so it can run on the web — but it didn't, because the email/password validation flow calledLayoutAnimation.spring()unconditionally.react-native-webdoes not implementLayoutAnimation, so those calls threw/warned and broke the screen on web.Fix (additive, web-only, non-breaking on native):
src/helpers/layoutAnimation.ts—springLayoutAnimation()no-ops whenPlatform.OS === 'web'and otherwise runs the exact nativeLayoutAnimation.spring(). Both former call sites inLoginScreen.tsxnow use it;LayoutAnimationis no longer statically imported by the component.Platform.OS === 'web').require()'d PNGs (logo, social icons, eye) all already carry explicitwidth/height, so they render under RNW; no native-only APIs likeKeyboard/BackHandlerare used.Tests / docs:
src/__tests__/LoginScreen.web.test.tsx(runs underPlatform.OS === 'web'): asserts the component renders without throwing and that an invalid-email Login press still shows the tooltip whileLayoutAnimation.springis never called.[Unreleased]CHANGELOG entry.No public exports/props/defaults/visuals changed; package name and version untouched.
Verification:
tsc --noEmitclean,eslint .clean,jest26/26 passing (24 → 26),bob build(commonjs/module/typescript) succeeds.