Added eslint and prop-types

master
Tudor Stanciu 2022-12-14 19:12:26 +02:00
parent 3029df96a2
commit 2b9bc9fb08
9 changed files with 95 additions and 0 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", "src/components/*", "src/pages/*"],
"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": "^_" }]
}
}

25
package-lock.json generated
View File

@ -47,6 +47,23 @@
}
}
},
"@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==",
"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=="
}
}
},
"@babel/generator": {
"version": "7.14.5",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.5.tgz",
@ -2367,6 +2384,14 @@
"resolved": "https://registry.npmjs.org/@mdi/react/-/react-1.4.0.tgz",
"integrity": "sha512-OUH9RhfDJPhybQL3owwrSDIXz2yVKXg5lYeOZjyRCiT9wqywNK0FeYyDByOwNIZnnIQoQYmuSrMv+pOX0Uqkmw=="
},
"@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==",
"requires": {
"eslint-scope": "5.1.1"
}
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",

View File

@ -26,6 +26,7 @@
"@material-ui/styles": "^4.11.3",
"@mdi/js": "^5.9.55",
"@mdi/react": "^1.4.0",
"@babel/eslint-parser": "^7.16.5",
"apexcharts": "^3.24.0",
"axios": "^0.19.2",
"classnames": "^2.2.6",
@ -35,6 +36,7 @@
"i18next-http-backend": "^1.0.10",
"moment": "^2.29.4",
"mui-datatables": "^3.7.4",
"prop-types": "15.7.2",
"react": "^16.14.0",
"react-apexcharts": "^1.3.7",
"react-dom": "^16.14.0",

View File

@ -1,4 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
var LayoutStateContext = React.createContext();
var LayoutDispatchContext = React.createContext();
@ -26,6 +27,10 @@ function LayoutProvider({ children }) {
);
}
LayoutProvider.propTypes = {
children: PropTypes.node
};
function useLayoutState() {
var context = React.useContext(LayoutStateContext);
if (context === undefined) {

View File

@ -1,4 +1,5 @@
import React, { useReducer, useMemo, useCallback } from "react";
import PropTypes from "prop-types";
import { toast } from "react-toastify";
import useStyles from "../components/Toast/styles";
import ToastContainer from "../components/Toast/ToastContainer";
@ -137,6 +138,10 @@ const ToastProvider = ({ children }) => {
);
};
ToastProvider.propTypes = {
children: PropTypes.node
};
const useToast = () => {
const context = React.useContext(ToastDispatchContext);
if (context === undefined) {

View File

@ -1,4 +1,5 @@
import React from "react";
import PropTypes from "prop-types";
import { authenticate, invalidate, validateToken } from "../utils/identity";
var UserStateContext = React.createContext();
@ -38,6 +39,10 @@ function UserProvider({ children }) {
);
}
UserProvider.propTypes = {
children: PropTypes.node
};
function useUserState() {
var context = React.useContext(UserStateContext);
if (context === undefined) {

View File

@ -0,0 +1,3 @@
const ResourcePreviewComponent = () => {};
export default ResourcePreviewComponent;

View File

@ -1,4 +1,5 @@
import React, { forwardRef } from "react";
import PropTypes from "prop-types";
import { IconButton, Tooltip } from "@material-ui/core";
const ActionButton = forwardRef((props, _ref) => {
@ -21,4 +22,9 @@ const ActionButton = forwardRef((props, _ref) => {
);
});
ActionButton.propTypes = {
action: PropTypes.object.isRequired,
resource: PropTypes.object.isRequired
};
export default ActionButton;

View File

@ -1,4 +1,5 @@
import React, { useState } from "react";
import PropTypes from "prop-types";
import { Menu } from "@material-ui/core";
import ActionButton from "./ActionButton";
import { MoreHorizOutlined } from "@material-ui/icons";
@ -40,4 +41,9 @@ const SecondaryActionsGroup = ({ resource, actions }) => {
);
};
SecondaryActionsGroup.propTypes = {
resource: PropTypes.object.isRequired,
actions: PropTypes.array.isRequired
};
export default SecondaryActionsGroup;