fix eslint errors

master
Tudor Stanciu 2023-03-03 23:56:31 +02:00
parent 9757bf7561
commit 956d7b34ff
10 changed files with 113 additions and 4 deletions

38
.eslintrc.json Normal file
View File

@ -0,0 +1,38 @@
{
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jest/recommended"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"babelOptions": {
"presets": ["@babel/preset-react"]
},
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "jest"],
"ignorePatterns": ["**/public"],
"rules": {
"indent": 0,
"linebreak-style": 0,
"quotes": 0,
"semi": 0,
"no-console": 0,
"no-debugger": "warn",
"react/display-name": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"no-unused-vars": [1, { "args": "after-used", "argsIgnorePattern": "^_" }]
}
}

28
package-lock.json generated
View File

@ -73,6 +73,25 @@
} }
} }
}, },
"@babel/eslint-parser": {
"version": "7.19.1",
"resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.19.1.tgz",
"integrity": "sha512-AqNf2QWt1rtu2/1rLswy6CDP7H9Oh3mMhk177Y67Rg8d7RD9WfOLLv8CGn6tisFvS2htm86yIe1yLF6I1UDaGQ==",
"dev": true,
"requires": {
"@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1",
"eslint-visitor-keys": "^2.1.0",
"semver": "^6.3.0"
},
"dependencies": {
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true
}
}
},
"@babel/generator": { "@babel/generator": {
"version": "7.20.7", "version": "7.20.7",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.7.tgz", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.20.7.tgz",
@ -2314,6 +2333,15 @@
"@types/whatwg-streams": "^0.0.7" "@types/whatwg-streams": "^0.0.7"
} }
}, },
"@nicolo-ribaudo/eslint-scope-5-internals": {
"version": "5.1.1-v1",
"resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz",
"integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==",
"dev": true,
"requires": {
"eslint-scope": "5.1.1"
}
},
"@nodelib/fs.scandir": { "@nodelib/fs.scandir": {
"version": "2.1.5", "version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",

View File

@ -31,6 +31,7 @@
"react-toastify": "^6.2.0" "react-toastify": "^6.2.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/eslint-parser": "^7.16.5",
"@testing-library/jest-dom": "^5.11.6", "@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2", "@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.5.0", "@testing-library/user-event": "^12.5.0",

View File

@ -1,4 +1,5 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types";
import Layout from "./Layout"; import Layout from "./Layout";
import { BrowserRouter, Switch, Redirect, Route } from "react-router-dom"; import { BrowserRouter, Switch, Redirect, Route } from "react-router-dom";
import { useTuitioToken } from "@flare/tuitio-client-react"; import { useTuitioToken } from "@flare/tuitio-client-react";
@ -28,6 +29,11 @@ const PrivateRoute = ({ component, ...rest }) => {
); );
}; };
PrivateRoute.propTypes = {
component: PropTypes.node.isRequired,
location: PropTypes.string
};
const PublicRoute = ({ component, ...rest }) => { const PublicRoute = ({ component, ...rest }) => {
const { valid } = useTuitioToken(); const { valid } = useTuitioToken();
return ( return (
@ -48,7 +54,11 @@ const PublicRoute = ({ component, ...rest }) => {
); );
}; };
const AppWrapper = () => { PublicRoute.propTypes = {
component: PropTypes.node.isRequired
};
const App = () => {
return ( return (
<BrowserRouter basename={process.env.PUBLIC_URL || ""}> <BrowserRouter basename={process.env.PUBLIC_URL || ""}>
<Switch> <Switch>
@ -59,4 +69,4 @@ const AppWrapper = () => {
); );
}; };
export default AppWrapper; export default App;

View File

@ -1,4 +1,5 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
import { Typography } from "@material-ui/core"; import { Typography } from "@material-ui/core";
@ -13,7 +14,7 @@ const useStyles = makeStyles(theme => ({
})); }));
const PageTitle = ({ text }) => { const PageTitle = ({ text }) => {
var classes = useStyles(); const classes = useStyles();
return ( return (
<div className={classes.box}> <div className={classes.box}>
@ -24,4 +25,8 @@ const PageTitle = ({ text }) => {
); );
}; };
PageTitle.propTypes = {
text: PropTypes.string.isRequired
};
export default PageTitle; export default PageTitle;

View File

@ -1,4 +1,5 @@
import React, { useState } from "react"; import React, { useState } from "react";
import PropTypes from "prop-types";
import { import {
InputAdornment, InputAdornment,
TextField, TextField,
@ -53,4 +54,8 @@ const PasswordField = ({ label, ...rest }) => {
); );
}; };
PasswordField.propTypes = {
label: PropTypes.string
};
export default PasswordField; export default PasswordField;

View File

@ -14,7 +14,7 @@ const LoginContainer = () => {
const { error } = useToast(); const { error } = useToast();
const { t } = useTranslation(); const { t } = useTranslation();
const { login, logout } = useTuitioClient({ const { login, logout } = useTuitioClient({
onLoginFailed: response => error(t("Login.IncorrectCredentials")), onLoginFailed: () => error(t("Login.IncorrectCredentials")),
onLoginError: err => error(err.message) onLoginError: err => error(err.message)
}); });
const { valid: tokenIsValid } = useTuitioToken(); const { valid: tokenIsValid } = useTuitioToken();

View File

@ -41,6 +41,18 @@ const ActionButton = React.forwardRef((props, _ref) => {
); );
}); });
ActionButton.propTypes = {
machine: PropTypes.shape({
machineId: PropTypes.number.isRequired
}).isRequired,
action: PropTypes.shape({
code: PropTypes.string.isRequired,
tooltip: PropTypes.string.isRequired,
system: PropTypes.bool.isRequired,
effect: PropTypes.func.isRequired
}).isRequired
};
const Machine = ({ const Machine = ({
machine, machine,
actions, actions,

View File

@ -1,4 +1,5 @@
import React, { useReducer, useMemo } from "react"; import React, { useReducer, useMemo } from "react";
import PropTypes from "prop-types";
import { import {
ApplicationStateContext, ApplicationStateContext,
ApplicationDispatchContext ApplicationDispatchContext
@ -25,4 +26,8 @@ const ApplicationStateProvider = ({ children }) => {
); );
}; };
ApplicationStateProvider.propTypes = {
children: PropTypes.node.isRequired
};
export default ApplicationStateProvider; export default ApplicationStateProvider;

View File

@ -1,4 +1,5 @@
import React from "react"; import React from "react";
import PropTypes from "prop-types";
import { ToastContainer, Slide } from "react-toastify"; import { ToastContainer, Slide } from "react-toastify";
import "react-toastify/dist/ReactToastify.css"; import "react-toastify/dist/ReactToastify.css";
@ -23,4 +24,8 @@ const ToastProvider = ({ children }) => {
); );
}; };
ToastProvider.propTypes = {
children: PropTypes.node.isRequired
};
export default ToastProvider; export default ToastProvider;