Skip to content

Commit 7f0ebdd

Browse files
Merge pull request #1566 from ASU/fix-publish-errors
Fix publish errors
2 parents 27e3819 + 0a67a10 commit 7f0ebdd

File tree

13 files changed

+174
-123
lines changed

13 files changed

+174
-123
lines changed

eslint.config.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const js = require("@eslint/js");
77
const importPlugin = require("eslint-plugin-import");
88
const jsxA11y = require("eslint-plugin-jsx-a11y");
99
const prettier = require("eslint-plugin-prettier");
10+
const eslintPluginPrettier = require("eslint-config-prettier");
11+
const eslintPluginReactHooks = require("eslint-plugin-react-hooks");
1012

1113
module.exports = [
1214
js.configs.recommended,
@@ -31,6 +33,8 @@ module.exports = [
3133
import: importPlugin,
3234
"jsx-a11y": jsxA11y,
3335
prettier,
36+
eslintPluginPrettier,
37+
"react-hooks": eslintPluginReactHooks,
3438
},
3539
settings: {
3640
react: {
@@ -51,6 +55,12 @@ module.exports = [
5155
"react/jsx-no-useless-fragment": "off",
5256
"react/require-default-props": "off",
5357
"react/jsx-props-no-spreading": "off",
58+
"react/jsx-uses-vars": "error", // Marks JSX variables as used
59+
"react/jsx-uses-react": "error", // Marks React as used in JSX files
60+
61+
// React Hooks rules
62+
"react-hooks/rules-of-hooks": "error",
63+
"react-hooks/exhaustive-deps": "warn",
5464

5565
// Import rules
5666
"import/no-relative-packages": "off",
@@ -74,7 +84,8 @@ module.exports = [
7484
"no-console": 1,
7585
"no-unused-vars": ["warn", {
7686
argsIgnorePattern: "^_",
77-
varsIgnorePattern: "^(React|_)",
87+
varsIgnorePattern: "^(React|_|expect|test|describe|it|beforeEach|afterEach|beforeAll|afterAll|jest|vi|fixture|page)$",
88+
ignoreRestSiblings: true,
7889
}],
7990
"no-undef": "off", // Disable for config files and test files
8091

@@ -110,6 +121,7 @@ module.exports = [
110121
import: importPlugin,
111122
"jsx-a11y": jsxA11y,
112123
prettier,
124+
"react-hooks": eslintPluginReactHooks,
113125
},
114126
settings: {
115127
react: {
@@ -141,11 +153,16 @@ module.exports = [
141153
extensions: [".js", ".jsx", ".ts", ".tsx"],
142154
}],
143155
"@typescript-eslint/ban-ts-comment": ["warn"],
144-
"no-unused-vars": "off",
156+
"no-unused-vars": ["warn", {
157+
argsIgnorePattern: "^_",
158+
varsIgnorePattern: "^(React|_|expect|test|describe|it|beforeEach|afterEach|beforeAll|afterAll|jest|vi|fixture|page)$",
159+
ignoreRestSiblings: true,
160+
}],
145161
"react/require-default-props": "off",
146-
"@typescript-eslint/no-unused-vars": ["error", {
162+
"@typescript-eslint/no-unused-vars": ["warn", {
147163
argsIgnorePattern: "^_",
148-
varsIgnorePattern: "^(React|_)",
164+
varsIgnorePattern: "^(React|_|expect|test|describe|it|beforeEach|afterEach|beforeAll|afterAll|jest|vi|fixture|page)$",
165+
ignoreRestSiblings: true,
149166
}],
150167
"@typescript-eslint/no-empty-function": "off",
151168

@@ -160,6 +177,12 @@ module.exports = [
160177
"no-promise-executor-return": "off",
161178
"default-param-last": "off",
162179
"react/jsx-props-no-spreading": "off",
180+
"react/jsx-uses-vars": "error", // Marks JSX variables as used
181+
"react/jsx-uses-react": "error", // Marks React as used in JSX files
182+
183+
// React Hooks rules
184+
"react-hooks/rules-of-hooks": "error",
185+
"react-hooks/exhaustive-deps": "warn",
163186
"prettier/prettier": ["error", {}, {
164187
usePrettierrc: true,
165188
}],

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@
7777
"eslint": "^9",
7878
"eslint-config-prettier": "^8.2.0",
7979
"eslint-plugin-import": "^2.22.1",
80-
"eslint-plugin-import-helpers": "^1.1.0",
80+
"eslint-plugin-import-helpers": "^2",
8181
"eslint-plugin-jest": "^28",
8282
"eslint-plugin-jsx-a11y": "^6.10.2",
8383
"eslint-plugin-prettier": "^5.5.1",
8484
"eslint-plugin-react": "^7.37.4",
85-
"eslint-plugin-react-hooks": "^4",
85+
"eslint-plugin-react-hooks": "^5",
8686
"eslint-plugin-storybook": "^9.0.13",
8787
"gh-pages": "^6.0.0",
8888
"globals": "^16.2.0",
@@ -93,7 +93,7 @@
9393
"mini-css-extract-plugin": "^2.0.0",
9494
"nunjucks": "^3.2.0",
9595
"playwright": "1.50.1",
96-
"prettier": "^2.2.1",
96+
"prettier": "^3",
9797
"purgecss-webpack-plugin": "^4.0.3",
9898
"react": "^18.3.1",
9999
"react-dom": "^18.3.1",

packages/app-rfi/src/components/AsuRfi/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ const AsuRfi = props => {
6363
}
6464
}, []);
6565

66-
if (typeof submissionUrl === "undefined") {
67-
return <></>;
68-
}
69-
7066
const rfiState = useRfiState(betterPropNames(props));
7167

7268
const noRfiAvailable = `RFI form not displayed. ${programOfInterest} has rfiDisplay set to false or does not exist`;
@@ -75,6 +71,11 @@ const AsuRfi = props => {
7571
console.log(noRfiAvailable);
7672
}
7773
}, [rfiState.showForm]);
74+
75+
if (typeof submissionUrl === "undefined") {
76+
return <></>;
77+
}
78+
7879
if (!rfiState.showForm) {
7980
return <div style={{ display: "none" }}>{noRfiAvailable}</div>;
8081
}

packages/app-rfi/src/components/controls/RfiSelect.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// DISABLED@ts-check
2-
/* eslint-disable no-unused-vars */
32

43
import { Field, useField, useFormikContext } from "formik";
54
import PropTypes from "prop-types";

packages/shared/assets/index.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
import * as _images from "./img/list";
22
export { imageName } from "./img/named";
33

4-
const _imageArray = Object.values(_images).reduce(
5-
(result, val) => [...result, val.default],
6-
[]
7-
);
8-
9-
export const imageArray = [
10-
..._imageArray,
11-
..._imageArray,
12-
..._imageArray,
13-
..._imageArray,
14-
..._imageArray,
15-
]; // make it bigger
4+
export const imageArray = Object.values(_images);
165
export const imageAny = () =>
176
imageArray[Math.floor(Math.random() * imageArray.length)];

packages/static-site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@typescript-eslint/eslint-plugin": "^6.0.0",
2929
"@typescript-eslint/parser": "^6.0.0",
3030
"@vitejs/plugin-react": "^4.3.1",
31-
"eslint-plugin-react-hooks": "^4.6.0",
31+
"eslint-plugin-react-hooks": "^5",
3232
"eslint-plugin-react-refresh": "^0.4.3",
3333
"typescript": "^5.0.2",
3434
"vite": "^5.3.5",

packages/unity-bootstrap-theme/src/js/calendar.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ function initCalendar() {
9090

9191
calendarContainer.innerHTML = `
9292
<h2><span class="highlight-black">${months[state.month]} ${
93-
state.year
94-
}</span></h2>
93+
state.year
94+
}</span></h2>
9595
<div class="calendar-grid">
9696
<div class="heading desktop">
9797
${desktopDaysOfWeek.map(day => `<p>${day}</p>`).join("")}
@@ -113,8 +113,8 @@ function initCalendar() {
113113
: ""
114114
}>
115115
<span class="${date.todayClass ? date.todayClass : ""}">${
116-
date.date
117-
}</span>
116+
date.date
117+
}</span>
118118
</h3>`
119119
)
120120
.join("")}

packages/unity-react-core/src/components/ComponentCarousel/components/ImageGalleryCarousel/ImageGalleryCarousel.jsx

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*/
1010
import PropTypes from "prop-types";
11-
import React, { useEffect, useState } from "react";
11+
import React, { useEffect, useState, useCallback } from "react";
1212

1313
import { BaseCarousel } from "../../core/components/BaseCarousel";
1414
import {
@@ -92,21 +92,26 @@ const htmlTemplate = ({ id, imageSource, imageAltText }) => ({
9292
* @returns { JSX.Element }
9393
*/
9494
const CustomNavComponent = ({ instanceName, imageItems, hasContent }) => {
95-
if (!imageItems || imageItems.length === 0) {
96-
return null;
97-
}
9895
const ATTR_INDEX = "data-current-index";
99-
const [title, setTitle] = useState(imageItems[0].title);
100-
101-
const [content, setContent] = useState(imageItems[0].content);
96+
const [title, setTitle] = useState(imageItems?.[0]?.title || "");
97+
const [content, setContent] = useState(imageItems?.[0]?.content || "");
10298

103-
const onItemClick = currentIndex => {
104-
const item = imageItems[currentIndex];
105-
setTitle(item.title);
106-
setContent(item.content);
107-
};
99+
const onItemClick = useCallback(
100+
currentIndex => {
101+
const item = imageItems?.[currentIndex];
102+
if (item) {
103+
setTitle(item.title);
104+
setContent(item.content);
105+
}
106+
},
107+
[imageItems]
108+
);
108109

109110
useEffect(() => {
111+
if (!imageItems || imageItems.length === 0) {
112+
return;
113+
}
114+
110115
/** @type {HTMLElement} */
111116
const textArea = document.querySelector(
112117
`.image-gallery figcaption .uds-caption-text div`
@@ -127,21 +132,35 @@ const CustomNavComponent = ({ instanceName, imageItems, hasContent }) => {
127132
}
128133

129134
const currentSlider = document.querySelector(`#${instanceName}`);
135+
if (!currentSlider) {
136+
return;
137+
}
130138

131139
function onDataCurrentIndexChange(mutations) {
132140
for (const mutation of mutations) {
133141
if (mutation && mutation.attributeName === ATTR_INDEX) {
134-
return onItemClick(+currentSlider.getAttribute(ATTR_INDEX));
142+
const index = currentSlider.getAttribute(ATTR_INDEX);
143+
if (index !== null) {
144+
onItemClick(+index);
145+
}
146+
return;
135147
}
136148
}
137-
return null;
138149
}
139150

140151
const observer = new MutationObserver(onDataCurrentIndexChange);
141152
observer.observe(currentSlider, {
142153
attributes: true,
143154
});
144-
}, [instanceName]);
155+
156+
return () => {
157+
observer.disconnect();
158+
};
159+
}, [instanceName, imageItems, onItemClick]);
160+
161+
if (!imageItems || imageItems.length === 0) {
162+
return null;
163+
}
145164

146165
const bulletItems = imageItems.map(item => item.imageSource);
147166
return (

0 commit comments

Comments
 (0)