Skip to content

Commit

Permalink
Update eslint typescript plugin (#1788)
Browse files Browse the repository at this point in the history
can't update eslint as react hook plugin doesn't support 9+
disable rule about unused expression as it would not allow a && c()
fix unused variables in catch blocks

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
  • Loading branch information
FredLL-Avaiga and Fred Lefévère-Laoide authored Sep 15, 2024
1 parent 8209983 commit 1bb9f30
Show file tree
Hide file tree
Showing 17 changed files with 359 additions and 337 deletions.
1 change: 1 addition & 0 deletions frontend/taipy-gui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-expressions": "off", // allows a && b()
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
"react-hooks/exhaustive-deps": "error", // Checks effect dependencies
"tsdoc/syntax": "off", // "warn" to check tsdoc syntax
Expand Down
361 changes: 215 additions & 146 deletions frontend/taipy-gui/package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions frontend/taipy-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"@types/react-window-infinite-loader": "^1.0.5",
"@types/sprintf-js": "^1.1.2",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0",
"add-asset-html-webpack-plugin": "^6.0.0",
"autoprefixer": "^10.4.0",
"copy-webpack-plugin": "^12.0.1",
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Button = (props: ButtonProps) => {
if (props.label === undefined && defaultLabel) {
try {
return JSON.parse(defaultLabel) as Icon;
} catch (e) {
} catch {
return defaultLabel;
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const Chart = (props: ChartProp) => {
if (typeof val === "string") {
try {
val = JSON.parse(val) as number[];
} catch (e) {
} catch {
// too bad
val = [];
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/taipy-gui/src/components/Taipy/DateRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ const getRangeDateTime = (
if (typeof json == "string") {
try {
dates = JSON.parse(json);
} catch (e) {}
} catch {
// too bad
}
} else {
dates = json as string[];
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/MenuCtl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const MenuCtl = (props: MenuCtlProps) => {
if (props.defaultInactiveIds) {
try {
return JSON.parse(props.defaultInactiveIds) as string[];
} catch (e) {
} catch {
// too bad
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/Selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ const Selector = (props: SelTreeProps) => {
let parsedValue;
try {
parsedValue = JSON.parse(defaultValue);
} catch (e) {
} catch {
parsedValue = defaultValue;
}
setSelectedValue(Array.isArray(parsedValue) ? parsedValue : [parsedValue]);
Expand Down
8 changes: 4 additions & 4 deletions frontend/taipy-gui/src/components/Taipy/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const Slider = (props: SliderProps) => {
if (idx == -1) {
try {
idx = parseInt(key, 10);
} catch (e) {
} catch {
// too bad
}
}
Expand All @@ -176,7 +176,7 @@ const Slider = (props: SliderProps) => {
if (marks.length) {
return marks;
}
} catch (e) {
} catch {
// won't happen
}
}
Expand Down Expand Up @@ -221,7 +221,7 @@ const Slider = (props: SliderProps) => {
const val = lovList.findIndex((item) => item.id === arr[0])
return val === -1 ? 0 : val
}
} catch (e) {
} catch {
throw new Error("Slider lov value couldn't be parsed");
}
}
Expand All @@ -234,7 +234,7 @@ const Slider = (props: SliderProps) => {
throw new Error("Slider values should all be numbers")
}
return arr
} catch (e) {
} catch {
// Invalid values
return 0
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const TreeView = (props: TreeViewProps) => {
let parsedValue;
try {
parsedValue = JSON.parse(defaultValue);
} catch (e) {
} catch {
parsedValue = defaultValue;
}
setSelectedValue(Array.isArray(parsedValue) ? parsedValue : [parsedValue]);
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/components/Taipy/lovUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const useLovListMemo = (lov: LoV | undefined, defaultLov: string, tree =
let parsedLov;
try {
parsedLov = JSON.parse(defaultLov);
} catch (e) {
} catch {
parsedLov = [];
}
return parsedLov.map((elt: LoVElt) => getLovItem(elt, tree));
Expand Down
4 changes: 2 additions & 2 deletions frontend/taipy-gui/src/components/Taipy/tableUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,14 @@ export const EditableCell = (props: EditableCellProps) => {
case "int":
try {
castVal = parseInt(val as string, 10);
} catch (e) {
} catch {
// ignore
}
break;
case "float":
try {
castVal = parseFloat(val as string);
} catch (e) {
} catch {
// ignore
}
break;
Expand Down
2 changes: 1 addition & 1 deletion frontend/taipy-gui/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const getDateTime = (value: string | null | undefined, tz?: string, withT
}
try {
return tz && tz !== "Etc/Unknown" && withTime ? toZonedTime(value, tz) : new Date(value);
} catch (e) {
} catch {
return null;
}
};
Expand Down
1 change: 1 addition & 0 deletions frontend/taipy/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = {
// Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-expressions": "off", // allow a && b()
"react-hooks/rules-of-hooks": "error", // Checks rules of Hooks
"react-hooks/exhaustive-deps": "error", // Checks effect dependencies
"tsdoc/syntax": "off", // "warn" to check tsdoc syntax
Expand Down
Loading

0 comments on commit 1bb9f30

Please sign in to comment.