Skip to content

feat: add reactNative preset + tsconfig (react-native-web ready)#1

Merged
a-tokyo merged 2 commits into
mainfrom
feat/react-native-preset
Jul 12, 2026
Merged

feat: add reactNative preset + tsconfig (react-native-web ready)#1
a-tokyo merged 2 commits into
mainfrom
feat/react-native-preset

Conversation

@a-tokyo

@a-tokyo a-tokyo commented Jul 12, 2026

Copy link
Copy Markdown
Member

What

Adds a fifth stack preset, reactNative, plus a matching tsconfig/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 react guardrails apply verbatim. A dedicated preset earns its place by:

  1. declaring the RN runtime globals (__DEV__, Hermes) so they don't trip no-undef (verified: __DEV__ is the only global antfu's browser+node set doesn't already cover);
  2. shipping a matching tsconfig without the Vite-specific bits;
  3. giving RN a documented, named entry point.

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.ts files already match the preset globs. The tsconfig keeps the DOM lib for the web target (TypeScript can't vary lib per file). Native-only projects can override lib to drop DOM. See docs/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 in eslint-plugin-react-native, which crashes on ESLint 10 — verified against 10.7: 5 of 7 rules call the removed context.getSourceCode()/getFilename() APIs. @react-native/eslint-plugin has no style rules. The full plan to add them once the ecosystem supports ESLint 10 is in docs/react-native.md.

Changes

  • eslint/react-native.js, eslint/index.js export, package.json exports (./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 new presetSuite case and a .js guard asserting __DEV__ is declared as a global (the .tsx clean test can't catch this — no-undef is 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 (new react-native suite: clean = 0 errors; dirty trips no-console + react/exhaustive-deps; __DEV__ guard passes)
  • npm run lint → clean
  • Manual: __DEV__ in a .js file produces no no-undef

🤖 Generated with Claude Code

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.js preset 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-native fixture + test coverage (including a JS-only guard for no-undef on __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.

Comment thread eslint/react-native.js Outdated
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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@a-tokyo a-tokyo merged commit fa15f26 into main Jul 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants