Add eslint to web module

pull/4/head
MiguelMLorente 2024-11-20 23:29:21 +01:00
parent 250325d8d2
commit 56705d3574
7 changed files with 916 additions and 75 deletions

17
web/.eslintrc.js Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
plugins: ["@typescript-eslint/eslint-plugin"],
extends: ["plugin:@typescript-eslint/strict", "plugin:prettier/recommended"],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: [".eslintrc.js", "dist/"],
rules: {},
};

926
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,9 +22,10 @@
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
"build": "react-scripts build", "build": "npm run lint && react-scripts build",
"test": "react-scripts test", "test": "react-scripts test",
"eject": "react-scripts eject" "eject": "react-scripts eject",
"lint": "eslint \"*/**/*.tsx\" \"*/**/*.ts\" --fix"
}, },
"eslintConfig": { "eslintConfig": {
"extends": [ "extends": [
@ -43,5 +44,13 @@
"last 1 firefox version", "last 1 firefox version",
"last 1 safari version" "last 1 safari version"
] ]
},
"devDependencies": {
"@eslint/js": "^8.0.0",
"@typescript-eslint/parser": "^8.15.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"typescript-eslint": "^8.15.0"
} }
} }

View File

@ -1,8 +1,8 @@
import React from 'react'; import React from "react";
import { render, screen } from '@testing-library/react'; import { render, screen } from "@testing-library/react";
import App from './App'; import App from "./App";
test('Renders hello world', () => { test("Renders hello world", () => {
render(<App />); render(<App />);
expect(screen.getByText("Hello World! Front")).toBeInTheDocument(); expect(screen.getByText("Hello World! Front")).toBeInTheDocument();
}); });

View File

@ -1,17 +1,18 @@
import React from 'react'; import React from "react";
import { io } from "socket.io-client"; import { io } from "socket.io-client";
function App() { function App() {
const socket = io("http://localhost:3010"); const socket = io("http://localhost:3010");
const emitData = () => console.log(socket.emit("example-request", "custom-request")); const emitData = () =>
socket.on("example-response", (data) => console.log(`Received response in front end with data: ${data}`)); console.log(socket.emit("example-request", "custom-request"));
socket.on("example-response", (data) =>
console.log(`Received response in front end with data: ${data}`),
);
return ( return (
<div className="App"> <div className="App">
<header className="App-header"> <header className="App-header">
<button onClick={emitData}> <button onClick={emitData}>Emit Data</button>
Emit Data
</button>
Hello World! Front Hello World! Front
</header> </header>
</div> </div>

View File

@ -1,13 +1,13 @@
import React from 'react'; import React from "react";
import ReactDOM from 'react-dom/client'; import ReactDOM from "react-dom/client";
import App from './App'; import App from "./App";
import './App.scss' import "./App.scss";
const root = ReactDOM.createRoot( const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement document.getElementById("root") as HTMLElement,
); );
root.render( root.render(
<React.StrictMode> <React.StrictMode>
<App /> <App />
</React.StrictMode> </React.StrictMode>,
); );

View File

@ -2,4 +2,4 @@
// allows you to do things like: // allows you to do things like:
// expect(element).toHaveTextContent(/react/i) // expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom // learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom'; import "@testing-library/jest-dom";