Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 0 additions & 17 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,4 @@ export default [
},

/* 5 - JSX files */
{
files: ['**/*.jsx'],
plugins: { node: nodePlugin, import: importPlugin },
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: { ...nodeGlobals, ...browserGlobals },
parserOptions: { ecmaFeatures: { jsx: true } },
},
rules: {
'node/no-unsupported-features/es-syntax': 'off',
'import/no-unresolved': 'error',
'import/named': 'error',
'import/default': 'error',
'import/no-absolute-path': 'error',
},
},
];
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
"workspaces": [
"packages/*"
],
"packageManager": "pnpm@10.13.1+sha512.37ebf1a5c7a30d5fabe0c5df44ee8da4c965ca0c5af3dbab28c3a1681b70a256218d05c81c9c0dcf767ef6b8551eb5b960042b9ed4300c59242336377e01cfad",
"packageManager": "pnpm@10.13.1",
"references": [
{
"path": "packages/core"
},
{
"path": "packages/cli"
},
{
"path": "packages/eslint-plugin-react-zero-ui"
}
],
"scripts": {
Expand All @@ -37,15 +40,16 @@
"size": "npx esbuild ./packages/core/dist/index.js --bundle --minify --format=esm --external:react --define:process.env.NODE_ENV='\"production\"' | gzip -c | wc -c"
},
"devDependencies": {
"@eslint/js": "^9.30.1",
"@types/node": "^24.0.13",
"esbuild": "^0.25.6",
"eslint": "^9.30.1",
"@eslint/js": "^9.32.0",
"@types/node": "^24.1.0",
"esbuild": "^0.25.8",
"eslint": "^9.32.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-react-zero-ui": "workspace:*",
"prettier": "^3.6.2",
"release-please": "^17.1.1",
"tsx": "^4.20.3",
"typescript": "^5.8.3"
"typescript": "^5.9.2"
}
}
}
52 changes: 52 additions & 0 deletions packages/core/__tests__/fixtures/next/app/LintFailures.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use client';
import { useScopedUI } from '@react-zero-ui/core';

/**
* This component is intentionally WRONG.
* – Missing data-attr on <section>
* – Missing ref attachment on <aside>
*
* The Zero-UI ESLint rule should flag both.
*/
export default function LintFailures() {
// #1 Setter attached but no data-scope attr β†’ missingAttr error
const [scope, setScope] = useScopedUI<'off' | 'on'>('scope', 'off');

// #2 No ref at all β†’ missingRef error
const [, setDialog] = useScopedUI<'open' | 'closed'>('dialog', 'closed');

return (
<main className="space-y-6 p-6">
{/* ❌ lint error expected here */}
<section
ref={setScope.ref}
className="scope-off:bg-red-100 scope-on:bg-red-600 scope-on:text-white p-4 rounded">
<button
className="border px-3 py-1"
onClick={() => setScope((prev) => (prev === 'on' ? 'off' : 'on'))}>
Toggle scope
</button>
</section>

{/* ❌ second lint error (missing .ref) */}
<aside className="dialog-open:block dialog-closed:hidden">
This dialog was never linked via <code>ref</code>
</aside>
</main>
);
}

/* ------------------------------------------------------------------ *
| Correct version (for reference) |
* ------------------------------------------------------------------ *
const [scope, setScope] = useScopedUI<'off' | 'on'>('scope', 'off');
<section
data-scope={scope}
ref={setScope.ref}
>
…
</section>

const [, setDialog] = useScopedUI<'open'|'closed'>('dialog','closed');
<aside ref={setDialog.ref} data-dialog="closed">…</aside>
*/
209 changes: 0 additions & 209 deletions packages/core/__tests__/fixtures/next/app/test/page.jsx

This file was deleted.

1 change: 1 addition & 0 deletions packages/core/__tests__/fixtures/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@tailwindcss/postcss": "^4.1.10",
"@types/node": "24.0.0",
"@types/react": "19.1.7",
"eslint-plugin-react-zero-ui": "0.0.1-beta.1",
"postcss": "^8.5.5",
"tailwindcss": "^4.1.10",
"typescript": "5.8.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@
"@types/react": "^19.1.8",
"tsx": "^4.20.3"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* AUTO-GENERATED - DO NOT EDIT */
export declare const bodyAttributes: {
"data-child": "closed" | "open";
"data-faq": "closed" | "open";
"data-mobile": "false" | "true";
"data-number": "1" | "2";
"data-scope": "off" | "on";
"data-theme": "dark" | "light";
"data-theme-2": "dark" | "light";
"data-theme-three": "dark" | "light";
"data-toggle-boolean": "false" | "true";
"data-toggle-function": "black" | "blue" | "green" | "red" | "white";
"data-use-effect-theme": "dark" | "light";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* AUTO-GENERATED - DO NOT EDIT */
export const bodyAttributes = {
"data-child": "closed",
"data-faq": "closed",
"data-mobile": "false",
"data-number": "1",
"data-scope": "off",
"data-theme": "light",
"data-theme-2": "light",
"data-theme-three": "light",
"data-toggle-boolean": "true",
"data-toggle-function": "white",
"data-use-effect-theme": "light"
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { type UISetterFn } from '@react-zero-ui/core';

export function ChildComponent({ setIsOpen }: { setIsOpen: UISetterFn }) {
return (
<div
className="child-closed:bg-gray-100 child-open:bg-gray-900 child-open:text-white"
data-testid="child-container">
<button
type="button"
onClick={() => setIsOpen((prev) => (prev === 'closed' ? 'open' : 'closed'))}
className="border-2 border-red-500"
data-testid="child-toggle">
Toggle Child
</button>
<div className="child-closed:bg-gray-100 child-open:bg-gray-900 flex">
Child: <span className="child-open:block child-closed:hidden">Open</span> <span className="child-closed:block child-open:hidden">Closed</span>
</div>
</div>
);
}
Loading