Skip to content
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
63bcbee
feat(eslint): support eslint for ReactLynx
upupming Jul 11, 2025
ce23e61
chore: changeset
upupming Jul 11, 2025
0df8dc8
feat: simplify the mapESLintTemplate
upupming Jul 11, 2025
7a4871d
chore: update create-rstack
upupming Jul 14, 2025
1c63b9f
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 14, 2025
8209889
feat: add test for eslint template
upupming Jul 14, 2025
5015c6b
feat: files should be configured by user
upupming Jul 14, 2025
4b3727f
fix: eslint type issue in workspace
upupming Jul 14, 2025
8f3e648
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 14, 2025
9935b72
chore: remove test scripts
upupming Jul 15, 2025
f1d5c70
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 15, 2025
2d5f233
chore: update create-rstack
upupming Jul 15, 2025
2cb1a7d
fix: eslint config type issue
upupming Jul 15, 2025
2c9bceb
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 15, 2025
52714ac
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 16, 2025
11e4270
feat: remove @lynx-js/eslint-config-reactlynx to keep it simple
upupming Jul 24, 2025
b187872
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 24, 2025
f3db9c3
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Jul 24, 2025
1949847
fix: pnpm dedupe
upupming Jul 24, 2025
b9edc80
Update .changeset/floppy-singers-chew.md
upupming Aug 1, 2025
9106933
fix: cr
upupming Aug 1, 2025
2b0cba4
Merge remote-tracking branch 'gh/main' into feat/eslint
upupming Aug 1, 2025
20d001b
feat: pass eslint for examples
upupming Aug 1, 2025
93de49f
Merge remote-tracking branch 'upstream/main' into feat/eslint
colinaaa Aug 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/floppy-singers-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-rspeedy": patch
---

Support ESLint for ReactLynx templates
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,18 @@ jobs:
node packages/tools/canary-release/snapshot.js
pnpm --recursive publish --no-git-checks --access public --registry=http://localhost:4873
cd `mktemp -d`
npx --registry http://localhost:4873 create-rspeedy-canary@latest --template react --dir create-rspeedy-regression
npx --registry http://localhost:4873 create-rspeedy-canary@latest --template react --dir create-rspeedy-regression --tools eslint
cd create-rspeedy-regression
pnpm install --registry=http://localhost:4873
pnpm run build
pnpm run build --mode development
npx --registry http://localhost:4873 create-rspeedy-canary@latest --template react-vitest-rltl --dir create-rspeedy-regression-vitest-rltl
pnpm run lint
npx --registry http://localhost:4873 create-rspeedy-canary@latest --template react-vitest-rltl --dir create-rspeedy-regression-vitest-rltl --tools eslint
cd create-rspeedy-regression-vitest-rltl
pnpm install --registry=http://localhost:4873
pnpm run build
pnpm run build --mode development
pnpm run lint
pnpm run test
test-react:
needs: build
Expand Down
30 changes: 29 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import * as regexpPlugin from 'eslint-plugin-regexp';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';

export default tseslint.config(
// Global ignores
Expand Down Expand Up @@ -67,7 +69,6 @@ export default tseslint.config(

// TODO: enable eslint for react
// react
'examples/**',
'packages/react/types/**',
'packages/react/runtime/__test__/**',
'packages/react/runtime/jsx-dev-runtime/**',
Expand Down Expand Up @@ -383,4 +384,31 @@ export default tseslint.config(
'@typescript-eslint/require-await': 'off',
},
},
// React-related
{
files: [
'examples/**/*.{jsx,tsx}',
],
extends: [
reactHooks.configs['recommended-latest'],
reactRefresh.configs.vite,
],
},
{
files: [
'examples/**',
],
settings: {
'import/resolver': {
typescript: {
project: 'examples/**/tsconfig.json',
noWarnOnMultipleProjects: true,
},
},
},
rules: {
// TODO: enable header for examples
'headers/header-format': 'off',
},
},
);
2 changes: 1 addition & 1 deletion examples/react/lynx.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from '@lynx-js/rspeedy';
import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin';
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
import { defineConfig } from '@lynx-js/rspeedy';

const enableBundleAnalysis = !!process.env['RSPEEDY_BUNDLE_ANALYSIS'];

Expand Down
4 changes: 2 additions & 2 deletions examples/react/test/jsx-runtime.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import { assertType, describe, expectTypeOf, test } from 'vitest';

import {
Component,
forwardRef,
Fragment,
memo,
Suspense,
forwardRef,
memo,
useMainThreadRef,
useRef,
} from '@lynx-js/react';
Expand Down
2 changes: 1 addition & 1 deletion examples/react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"checkJs": true,
"isolatedDeclarations": false,
},
"include": ["src", "lynx.config.js", "test"],
"include": ["src", "lynx.config.js", "test", "vitest.config.ts"],
"references": [
{ "path": "../../packages/react/tsconfig.json" },
{ "path": "../../packages/rspeedy/core/tsconfig.build.json" },
Expand Down
5 changes: 3 additions & 2 deletions examples/tailwindcss/lynx.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { defineConfig } from '@lynx-js/rspeedy';
import { pluginTailwindCSS } from 'rsbuild-plugin-tailwindcss';

import { pluginQRCode } from '@lynx-js/qrcode-rsbuild-plugin';
import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
import { pluginTailwindCSS } from 'rsbuild-plugin-tailwindcss';
import { defineConfig } from '@lynx-js/rspeedy';

export default defineConfig({
plugins: [
Expand Down
1 change: 1 addition & 0 deletions examples/tailwindcss/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from '@lynx-js/react';

import { cn } from './utils.js';
import './App.css';

Expand Down
1 change: 1 addition & 0 deletions examples/tailwindcss/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { root } from '@lynx-js/react';

import { App } from './App.js';

root.render(
Expand Down
4 changes: 3 additions & 1 deletion examples/tailwindcss/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { clsx, type ClassValue } from 'clsx';
import { clsx } from 'clsx';
import type { ClassValue } from 'clsx';
import { twMerge } from 'tailwind-merge';

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
8 changes: 5 additions & 3 deletions examples/tailwindcss/test/App.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { assertType, describe, test } from 'vitest';
import type { JSX } from '@lynx-js/react';

import { App } from '@/App.js';
import { cn } from '@/utils.js';
import type { JSX } from '@lynx-js/react';

const handler = (prev: boolean): boolean => !prev;

describe('App Component Type Tests', () => {
test('App should return JSX.Element', () => {
Expand All @@ -10,14 +13,13 @@ describe('App Component Type Tests', () => {
});

test('bindtap handler should toggle boolean state', () => {
const handler = (prev: boolean): boolean => !prev;
assertType<(prev: boolean) => boolean>(handler);
});
});

describe('cn utility', () => {
test('cn() returns string', () => {
const result = cn('a', 'b', false && 'c');
const result = cn('a', 'b', 'c');
assertType<string>(result);
});
});
2 changes: 1 addition & 1 deletion examples/tailwindcss/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@/*": ["./src/*"],
},
},
"include": ["src", "lynx.config.js", "test"],
"include": ["src", "lynx.config.js", "test", "vitest.config.ts", "tailwind.config.ts"],
"exclude": ["dist/"],
"references": [
{ "path": "../../packages/react/tsconfig.json" },
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"eslint-plugin-headers": "^1.3.3",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-n": "^17.21.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"eslint-plugin-regexp": "^2.9.0",
"eslint-plugin-unicorn": "^59.0.1",
"globals": "^16.3.0",
Expand Down
18 changes: 15 additions & 3 deletions packages/rspeedy/create-rspeedy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,20 @@ void create({
),
version: devDependencies,
getTemplateName,
mapESLintTemplate() {
// TODO: support ESLint later
return null
mapESLintTemplate(templateName) {
const lang = TEMPLATES.find(({ template }) =>
templateName.startsWith(template)
)?.lang

if (!lang) return null

switch (lang) {
case 'js':
return 'react-js'
case 'ts':
return 'react-ts'
default:
return null
}
},
})
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// <reference types="@lynx-js/rspeedy/client" />

declare module '@lynx-js/types' {
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
interface GlobalProps {
/**
* Define your global properties in this interface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function App() {
to see updates!
</text>
</view>
<view style={{ flex: 1 }}></view>
<view style={{ flex: 1 }} />
</view>
</view>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function App() {
to see updates!
</text>
</view>
<view style={{ flex: 1 }}></view>
<view style={{ flex: 1 }} />
</view>
</view>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export function App(props) {

useEffect(() => {
console.info('Hello, ReactLynx')
props.onMounted?.()
}, [])
props.onRender?.()

const onTap = useCallback(() => {
'background only'
Expand Down Expand Up @@ -46,7 +46,7 @@ export function App(props) {
to see updates!
</text>
</view>
<view style={{ flex: 1 }}></view>
<view style={{ flex: 1 }} />
</view>
</view>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import lynxLogo from './assets/lynx-logo.png'
import reactLynxLogo from './assets/react-logo.png'

export function App(props: {
onMounted?: () => void
onRender?: () => void
}) {
const [alterLogo, setAlterLogo] = useState(false)

useEffect(() => {
console.info('Hello, ReactLynx')
props.onMounted?.()
}, [])
props.onRender?.()

const onTap = useCallback(() => {
'background only'
Expand Down Expand Up @@ -48,7 +48,7 @@ export function App(props: {
to see updates!
</text>
</view>
<view style={{ flex: 1 }}></view>
<view style={{ flex: 1 }} />
</view>
</view>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test('App', async () => {

render(
<App
onMounted={() => {
onRender={() => {
cb(`__MAIN_THREAD__: ${__MAIN_THREAD__}`)
}}
/>,
Expand Down
Loading
Loading