feat: add reactNative preset + tsconfig (react-native-web ready)#1
Merged
Conversation
Adds a fifth stack preset for React Native, mirroring the `react` preset's foundation (antfu react support + the SonarQube-compatibility layer) since RN is just React + TS/JS and SonarQube ships no RN-specific rules. The preset adds the RN runtime globals (`__DEV__`, Hermes) so they don't trip `no-undef`, and a matching `tsconfig/react-native.json`. Works for react-native-web universal codebases with no extra ESLint config (browser globals + `.web.tsx` globs are already covered); the tsconfig keeps the DOM lib for the web target. The RN-idiom style rules (no-inline-styles, no-color-literals, no-unused-styles, split-platform-components) are intentionally deferred: their only source, eslint-plugin-react-native@5, crashes on ESLint 10 (calls the removed context.getSourceCode/getFilename APIs). The upgrade path is tracked in docs/react-native.md. - eslint/react-native.js, eslint/index.js, package.json exports - tsconfig/react-native.json (extends base, jsx, DOM lib for RNW) - test fixture + suite, incl. a .js guard that __DEV__ is declared - README + docs/react-native.md (RNW notes, deferred-rules plan) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds first-class React Native support to the @zoldytech/javascript ESLint/tsconfig “house style” package by introducing a dedicated reactNative preset and a matching tsconfig/react-native.json, with explicit support for react-native-web.
Changes:
- Introduces
eslint/react-native.jspreset that mirrors the existing React preset and adds RN runtime globals (__DEV__,HermesInternal). - Adds
tsconfig/react-native.json(extends base,jsx: react-jsx, DOM libs retained for RNW). - Adds a new
react-nativefixture + test coverage (including a JS-only guard forno-undefon__DEV__) and documents behavior in README/docs.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
tsconfig/react-native.json |
New RN-focused tsconfig extending base, aligned for RN + RNW usage. |
eslint/react-native.js |
New reactNative() flat-config preset (React parity + RN globals + sonar/prettier layers). |
eslint/index.js |
Exports reactNative from the main ESLint entrypoint. |
package.json |
Adds exports for ./eslint/react-native and ./tsconfig/react-native.json. |
test/presets.test.js |
Adds react-native preset suite and a JS fixture test guarding __DEV__ global. |
test/fixtures/react-native/eslint.config.mjs |
Fixture ESLint config using the new preset. |
test/fixtures/react-native/clean.tsx |
Clean RN TSX fixture. |
test/fixtures/react-native/dirty.tsx |
Dirty RN TSX fixture to assert expected rule failures. |
test/fixtures/react-native/dev-global.js |
JS fixture ensuring __DEV__ doesn’t trigger no-undef. |
README.md |
Documents the new preset + tsconfig availability and RN/RNW positioning. |
docs/react-native.md |
New detailed RN/RNW docs and deferred rule plan. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses Copilot review: the header still said the tsconfig had no DOM lib, but it keeps DOM for the react-native-web target. Also spell the Hermes global `HermesInternal` to match the implementation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds a fifth stack preset,
reactNative, plus a matchingtsconfig/react-native.json, so React Native (and react-native-web) projects get the same SonarQube-compatible house style as the other stacks.Why
The team uses React Native heavily. RN is just React + TS/JS, and SonarQube ships no RN-specific rules, so the existing
reactguardrails apply verbatim. A dedicated preset earns its place by:__DEV__, Hermes) so they don't tripno-undef(verified:__DEV__is the only global antfu's browser+node set doesn't already cover);react-native-web
Universal RN+web codebases are supported with no extra ESLint config — RNW runs in the browser, so antfu's browser globals cover the web APIs,
__DEV__is declared, and.web.tsx/.web.tsfiles already match the preset globs. The tsconfig keeps the DOM lib for the web target (TypeScript can't varylibper file). Native-only projects can overridelibto drop DOM. Seedocs/react-native.md.Deferred: RN-idiom style rules (blocked on ESLint 10)
The style rules (
no-inline-styles,no-color-literals,no-unused-styles,split-platform-components, …) live only ineslint-plugin-react-native, which crashes on ESLint 10 — verified against 10.7: 5 of 7 rules call the removedcontext.getSourceCode()/getFilename()APIs.@react-native/eslint-pluginhas no style rules. The full plan to add them once the ecosystem supports ESLint 10 is indocs/react-native.md.Changes
eslint/react-native.js,eslint/index.jsexport,package.jsonexports (./eslint/react-native,./tsconfig/react-native.json)tsconfig/react-native.json(extends base,jsx: react-jsx, DOM lib for RNW)test/fixtures/react-native/+ a newpresetSuitecase and a.jsguard asserting__DEV__is declared as a global (the.tsxclean test can't catch this —no-undefis off in TS)README.md+docs/react-native.md(RNW notes + deferred-rules upgrade path)No new runtime dependency added.
Verification
npm test→ 11/11 pass (newreact-nativesuite: clean = 0 errors; dirty tripsno-console+react/exhaustive-deps;__DEV__guard passes)npm run lint→ clean__DEV__in a.jsfile produces nono-undef🤖 Generated with Claude Code