Skip to content

Commit

Permalink
feat(examples): add new 'vite-react-dom-with-ts-blank-eslint-parser-a…
Browse files Browse the repository at this point in the history
…pp' example
  • Loading branch information
Rel1cx committed Jan 24, 2025
1 parent 170bbef commit 945ca60
Show file tree
Hide file tree
Showing 24 changed files with 874 additions and 280 deletions.
2 changes: 1 addition & 1 deletion examples/dual-react-dom-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.24.1",
"@eslint/js": "^9.18.0",
"@eslint/js": "^9.19.0",
"@tsconfig/node22": "^22.0.0",
"@tsconfig/strictest": "^2.0.5",
"@types/node": "^22.10.10",
Expand Down
2 changes: 1 addition & 1 deletion examples/next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.24.1",
"@eslint/config-inspector": "^1.0.0",
"@eslint/js": "^9.18.0",
"@eslint/js": "^9.19.0",
"@next/eslint-plugin-next": "^15.1.6",
"@types/negotiator": "^0.6.3",
"@types/node": "^22.10.10",
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-react-dom-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.24.1",
"@eslint/config-inspector": "^1.0.0",
"@eslint/js": "^9.18.0",
"@eslint/js": "^9.19.0",
"@tsconfig/node22": "^22.0.0",
"@tsconfig/strictest": "^2.0.5",
"@types/react": "^19.0.8",
Expand Down
2 changes: 1 addition & 1 deletion examples/vite-react-dom-js-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.24.1",
"@eslint/config-inspector": "^1.0.0",
"@eslint/js": "^9.18.0",
"@eslint/js": "^9.19.0",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
Expand Down
6 changes: 3 additions & 3 deletions examples/vite-react-dom-js-with-babel-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"react-dom": "^19.0.0"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/core": "^7.26.7",
"@babel/eslint-parser": "^7.26.5",
"@babel/preset-env": "^7.26.0",
"@babel/preset-env": "^7.26.7",
"@babel/preset-react": "^7.26.3",
"@eslint-react/eslint-plugin": "^1.24.1",
"@eslint/config-inspector": "^1.0.0",
"@eslint/js": "^9.18.0",
"@eslint/js": "^9.19.0",
"@types/babel__core": "~7.20.5",
"@types/babel__preset-env": "~7.9.7",
"@types/react": "^19.0.8",
Expand Down
22 changes: 22 additions & 0 deletions examples/vite-react-dom-with-ts-blank-eslint-parser-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module "@eslint/js";
declare module "eslint-plugin-react-hooks";
declare module "eslint-plugin-react-refresh";
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// @ts-check
import eslintJs from "@eslint/js";
import eslintReact from "@eslint-react/eslint-plugin";
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
import globals from "globals";
import * as tsBlankEslintParser from "ts-blank-eslint-parser";

import TSCONFIG from "./tsconfig.json" with { type: "json" };
import TSCONFIG_NODE from "./tsconfig.node.json" with { type: "json" };

const GLOB_TS = ["**/*.ts", "**/*.tsx"];

export default [
// base configuration for browser environment source files
{
files: TSCONFIG.include,
languageOptions: {
globals: {
...globals.browser,
},
parser: tsBlankEslintParser,
parserOptions: {
jsxPragma: "React",
sourceType: "module",
},
},
rules: {
...eslintJs.configs.recommended.rules,
},
},
// base configuration for node environment source files (*.config.js, etc.)
{
files: TSCONFIG_NODE.include,
ignores: TSCONFIG_NODE.exclude,
languageOptions: {
globals: {
...globals.node,
},
parser: tsBlankEslintParser,
parserOptions: {
sourceType: "module",
},
},
rules: {
...eslintJs.configs.recommended.rules,
"no-console": "off",
},
},
// React configuration
{
files: TSCONFIG.include,
...eslintReact.configs.recommended,
},
// React Hooks configuration
{
files: TSCONFIG.include,
plugins: {
"react-hooks": eslintPluginReactHooks,
},
rules: eslintPluginReactHooks.configs.recommended.rules,
},
// React Refresh configuration
{
files: TSCONFIG.include,
plugins: {
"react-refresh": eslintPluginReactRefresh,
},
rules: {
"react-refresh/only-export-components": "warn",
},
},
];
15 changes: 15 additions & 0 deletions examples/vite-react-dom-with-ts-blank-eslint-parser-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>eslint-react-example</title>
</head>

<body>
<div id="root"></div>
<script type="module" src="/src/main.ts"></script>
</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "@examples/vite-react-dom-with-ts-blank-eslint-parser-app",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"inspect:eslint-config": "eslint-config-inspector",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@eslint-react/eslint-plugin": "^1.24.1",
"@eslint/config-inspector": "^1.0.0",
"@eslint/js": "^9.19.0",
"@tsconfig/node22": "^22.0.0",
"@tsconfig/strictest": "^2.0.5",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"eslint": "^9.18.0",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.18",
"globals": "^15.14.0",
"ts-blank-eslint-parser": "alpha",
"typescript": "^5.7.3",
"vite": "^6.0.11"
},
"engines": {
"node": ">=18.18.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 8em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}

.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a>.logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import "./App.css";

import { useState } from "react";

import logo from "./assets/eslint-react.svg";

function App() {
const [count, setCount] = useState(0n);

return (
<div>
<div>
<a href="https://eslint-react.xyz" target="_blank" rel="noopener noreferrer">
<img alt="logo" className="logo" src={logo} />
</a>
</div>
<div className="card">
<button type="button" onClick={() => setCount((count) => count + 1n)}>
count is {count.toString()}
</button>
</div>
</div>
);
}

export default App;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
:root {
font-family: ui-sans-serif,
system-ui,
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
Roboto,
'Helvetica Neue',
Arial,
'Noto Sans',
sans-serif,
'Apple Color Emoji',
'Segoe UI Emoji',
'Segoe UI Symbol',
'Noto Color Emoji';

line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}

a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}

button:hover {
border-color: #646cff;
}

button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}

a:hover {
color: #747bff;
}

button {
background-color: #f9f9f9;
}
}
Loading

0 comments on commit 945ca60

Please sign in to comment.