Skip to content

Commit

Permalink
fix(plugins/eslint-plugin): Unexpected top-level property 'name' in l…
Browse files Browse the repository at this point in the history
…egacy configs, closes #863
  • Loading branch information
Rel1cx committed Nov 21, 2024
1 parent d41ead8 commit ba34c8e
Show file tree
Hide file tree
Showing 15 changed files with 359 additions and 4 deletions.
16 changes: 16 additions & 0 deletions examples/vite-react-dom-legacy/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
env: {
browser: true,
},
parser: "@typescript-eslint/parser",
plugins: ["@eslint-react/eslint-plugin"],
extends: ["eslint:recommended"],
overrides: [
{
files: ["src/**/*.{ts, tsx}"],
extends: [
"plugin:@eslint-react/recommended-legacy",
],
},
],
};
22 changes: 22 additions & 0 deletions examples/vite-react-dom-legacy/.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?
5 changes: 5 additions & 0 deletions examples/vite-react-dom-legacy/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
15 changes: 15 additions & 0 deletions examples/vite-react-dom-legacy/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.js"></script>
</body>

</html>
33 changes: 33 additions & 0 deletions examples/vite-react-dom-legacy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "vite-react-dom-legacy",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"build": "tsc && vite build",
"dev": "vite",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@eslint-react/eslint-plugin": "workspace:*",
"@eslint/config-inspector": "^0.5.6",
"@eslint/js": "^9.15.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"eslint": "^9.15.0",
"eslint-plugin-react-hooks": "rc",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.12.0",
"vite": "^5.4.11"
}
}
41 changes: 41 additions & 0 deletions examples/vite-react-dom-legacy/src/App.css
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;
}
26 changes: 26 additions & 0 deletions examples/vite-react-dom-legacy/src/App.jsx
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;
13 changes: 13 additions & 0 deletions examples/vite-react-dom-legacy/src/assets/eslint-react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions examples/vite-react-dom-legacy/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions examples/vite-react-dom-legacy/src/index.css
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;
}
}
7 changes: 7 additions & 0 deletions examples/vite-react-dom-legacy/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "./index.css";

import ReactDOM from "react-dom/client";

import { root } from "./root";

ReactDOM.createRoot(document.querySelector("#root")).render(root);
9 changes: 9 additions & 0 deletions examples/vite-react-dom-legacy/src/root.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";

import App from "./App";

export const root = (
<React.StrictMode>
<App />
</React.StrictMode>
);
9 changes: 9 additions & 0 deletions examples/vite-react-dom-legacy/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
],
});
4 changes: 2 additions & 2 deletions packages/plugins/eslint-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ type Config = {
};

function makeLegacyConfig<T extends Config>(config: T) {
const { name: _, ...rest } = config;
return {
...config,
name: `${config.name}-legacy`,
...rest,
plugins: ["@eslint-react"],
};
}
Expand Down
Loading

0 comments on commit ba34c8e

Please sign in to comment.