Skip to content

Commit

Permalink
Merge branch 'main' into 908-local-repo-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
TanyaStere42 authored Dec 4, 2024
2 parents 6c1bf1d + 29ddda1 commit 1f4c16d
Show file tree
Hide file tree
Showing 19 changed files with 3,674 additions and 403 deletions.
62 changes: 44 additions & 18 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import pluginJs from "@eslint/js";
import pluginReactConfig from "eslint-plugin-react/configs/recommended.js";
import babelParser from "@babel/eslint-parser";
import reactHooks from "eslint-plugin-react-hooks";
import jestPlugin from "eslint-plugin-jest";

export default [
pluginJs.configs.recommended,
pluginReactConfig,
{
ignores: ["**/frontend/build/**", "**/frontend/coverage/**"],
},
{
files: ["**/*.{js,mjs,cjs,jsx}"],
plugins: {
Expand All @@ -18,16 +22,15 @@ export default [
process: "readonly",
},
parser: babelParser,

},
settings: {
react: {
version: "detect"
}
version: "detect",
},
},

rules: {
"semi": 2,
semi: 2,
"react/prop-types": 0,
"jsx-no-bind": 0,
"react/jsx-no-bind": 0,
Expand All @@ -36,35 +39,51 @@ export default [
"react/destructuring-assignment": 0,
"react/forbid-prop-types": 0,
"react/jsx-wrap-multilines": 0,
"react/style-prop-object": [2, { "allow": ["FormattedNumber"] }],
"react/style-prop-object": [2, { allow: ["FormattedNumber"] }],
"import/prefer-default-export": 0,
"function-paren-newline": 0,
"react/function-component-definition": 0,
"func-names": 0,
"no-underscore-dangle": 0,
"no-unused-vars": [
"error",
{
vars: "all",
args: "after-used",
ignoreRestSiblings: false,
varsIgnorePattern: "^_",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
},
],
"no-console": 1,
"prefer-destructuring": 0,
"operator-linebreak": 0,
"indent": 0,
"camelcase": 0,
indent: 0,
camelcase: 0,
"space-before-function-paren": 0,
"implicit-arrow-linebreak": 0,
"nonblock-statement-body-position": 0,
"react/prefer-stateless-function": 0,
"curly": 0,
curly: 0,
"object-curly-newline": 0,
"prefer-template": 0,
"arrow-parens": 0,
"no-param-reassign": 0,
"no-mixed-operators": 0,
"no-else-return": 0,

},
},
{
files: ['frontend/babel.config.js', 'frontend/jest.config.js', 'babel.config.js'], // Specify the config files
files: [
"frontend/babel.config.js",
"frontend/jest.config.js",
"babel.config.js",
], // Specify the config files
languageOptions: {
globals: {
...globals.node,
require: "readonly",
module: "readonly",
__dirname: "readonly",
Expand All @@ -73,16 +92,23 @@ export default [
},
},
{
files: ["**/__tests__/**/*.{js,jsx}", "**/*.test.{js,jsx}"],
files: ["**/*.{js,cjs}", "**/scripts/**/*.js"],
languageOptions: {
globals: {
jest: "readonly", // Define Jest-specific globals
test: "readonly",
expect: "readonly",
...globals.node,
},
},
},
{
files: ["**/__tests__/**/*.{js,jsx}", "**/*.test.{js,jsx}"],
plugins: {
jest: jestPlugin,
},
languageOptions: {
globals: jestPlugin.environments.globals.globals,
},
rules: {
"react/react-in-jsx-scope": 0, // Disable React in scope for JSX cuz we are using React 17+
}
}
];
...jestPlugin.configs.recommended.rules,
},
},
];
1 change: 0 additions & 1 deletion frontend/config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// config-overrides.js
/* eslint-disable no-undef */
const webpack = require("webpack");
module.exports = function override(config, env) {
if (env === "production") {
Expand Down
2 changes: 0 additions & 2 deletions frontend/config/webpack/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-undef */

const path = require("path");
const webpack = require("webpack");
const UnusedWebpackPlugin = require("unused-webpack-plugin");
Expand Down
3 changes: 0 additions & 3 deletions frontend/config/webpack/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/* eslint-disable no-undef */

// const webpack = require("webpack");
const { resolve } = require("path");
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/AuthenticatedSwitch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ import AdminLogs from "./pages/AdminLogs";
import ReportEncounter from "./pages/ReportsAndManagamentPages/ReportEncounter";
import ReportConfirm from "./pages/ReportsAndManagamentPages/ReportConfirm";

export default function AuthenticatedSwitch({ showAlert, setShowAlert, showclassicsubmit }) {
export default function AuthenticatedSwitch({
showAlert,
setShowAlert,
showclassicsubmit,
}) {
const { data } = useGetMe();
const username = data?.username;
// eslint-disable-next-line no-undef
const avatar =
data?.imageURL || `${process.env.PUBLIC_URL}/images/Avatar.png`;
const [header, setHeader] = React.useState(true);
Expand Down
12 changes: 9 additions & 3 deletions frontend/src/components/AuthenticatedAppHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import React, { useContext } from "react";
import { Navbar, Nav } from "react-bootstrap";
import "../css/dropdown.css";
Expand All @@ -10,7 +9,11 @@ import Menu from "./header/Menu";
import FooterVisibilityContext from "../FooterVisibilityContext";
import Logo from "./svg/Logo";

export default function AuthenticatedAppHeader({ username, avatar, showclassicsubmit }) {
export default function AuthenticatedAppHeader({
username,
avatar,
showclassicsubmit,
}) {
const { visible } = useContext(FooterVisibilityContext);

const {
Expand Down Expand Up @@ -68,7 +71,10 @@ export default function AuthenticatedAppHeader({ username, avatar, showclassicsu
marginLeft: "auto",
}}
>
<Menu username={username} showclassicsubmit={showclassicsubmit}/>
<Menu
username={username}
showclassicsubmit={showclassicsubmit}
/>
</Nav>
<NotificationButton
collaborationTitle={collaborationTitle}
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/Form/LabelledKeywordFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ const colourStyles = {

export default function LabelledKeywordFilter({ data, onChange }) {
const [isChecked_keyword, setIsChecked_keyword] = React.useState(false);
// eslint-disable-next-line no-unused-vars
const labelledKeywordsOptions =
Object.entries(data?.labeledKeyword || {}).map(([key, value]) => {
Object.entries(data?.labeledKeyword || {}).map(([key, _]) => {
return {
value: key,
label: key,
Expand Down
27 changes: 12 additions & 15 deletions frontend/src/components/Link.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { forwardRef } from 'react';
import { Link as RouterLink } from 'react-router-dom';
import React, { forwardRef } from "react";
import { Link as RouterLink } from "react-router-dom";

function Link(
{
Expand All @@ -15,12 +15,12 @@ function Link(
},
ref,
) {
const styles = {
color: disabled ? 'grey' : 'unset',
textDecoration: noUnderline ? 'unset' : 'underline',
cursor: disabled ? 'default' : 'pointer',
...style,
};
const styles = {
color: disabled ? "grey" : "unset",
textDecoration: noUnderline ? "unset" : "underline",
cursor: disabled ? "default" : "pointer",
...style,
};

if (disabled) {
return (
Expand All @@ -32,20 +32,17 @@ function Link(

if (external) {
return (
/* eslint-disable react/jsx-no-target-blank */
/* This rule is actually followed, but eslint doesn't understand the ternary */
<a
href={href}
target={newTab ? '_blank' : undefined}
rel={newTab ? 'noreferrer' : undefined}
target={newTab ? "_blank" : undefined}
rel={newTab ? "noreferrer" : undefined}
style={styles}
onClick={onClick}
ref={ref}
{...rest}
>
{children}
</a>
/* eslint-enable react/jsx-no-target-blank */
);
}

Expand All @@ -54,8 +51,8 @@ function Link(
to={href}
style={styles}
onClick={onClick}
target={newTab ? '_blank' : undefined}
rel={newTab ? 'noreferrer' : undefined}
target={newTab ? "_blank" : undefined}
rel={newTab ? "noreferrer" : undefined}
ref={ref}
{...rest}
>
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/UnAuthenticatedAppHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import React, { useContext, useState } from "react";
import { Navbar, Nav, NavDropdown } from "react-bootstrap";
import "../css/dropdown.css";
Expand All @@ -10,7 +9,7 @@ import { FormattedMessage } from "react-intl";
import FooterVisibilityContext from "../FooterVisibilityContext";
import Logo from "./svg/Logo";

export default function AuthenticatedAppHeader({showclassicsubmit}) {
export default function AuthenticatedAppHeader({ showclassicsubmit }) {
const { visible } = useContext(FooterVisibilityContext);
const [dropdownShows, setDropdownShows] = useState({
dropdown1: false,
Expand Down
1 change: 0 additions & 1 deletion frontend/src/constants/navMenu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-undef */
import React from "react";
import { FormattedMessage } from "react-intl";

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/useFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function refreshNoop() {
function formatError(response) {
try {
return response?.error ? response.error.toJSON().message : null;
} catch (e) {
} catch (_error) {
return "Error could not be formatted as JSON";
}
}
Expand Down
Loading

0 comments on commit 1f4c16d

Please sign in to comment.