Skip to content

Commit

Permalink
[Linting] Update @typescript-eslint/eslint-plugin to v8 (#3222)
Browse files Browse the repository at this point in the history
* linting: update ts eslint package to v8

* linting: Update ts eslint package to v8

* change: removed redundant off-toggle of native eslint rules

* change: update interface declaration
  • Loading branch information
KenAJoh authored Oct 14, 2024
1 parent 2d438e1 commit 2e98a09
Show file tree
Hide file tree
Showing 19 changed files with 116 additions and 124 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ module.exports = {
"@typescript-eslint/no-shadow": ["error", { hoist: "all" }],
"@typescript-eslint/no-explicit-any": "off", // Temporary
"@typescript-eslint/array-type": "error",
"@typescript-eslint/no-unused-expressions": [
"error",
/* https://eslint.org/docs/latest/rules/no-unused-expressions#allowshortcircuit-and-allowternary */
{ allowShortCircuit: true, allowTernary: true },
],
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions @navikt/core/react/src/modal/dialog-polyfill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
// Some browsers throw on cssRules.
try {
cssRules = styleSheet.cssRules;
} catch (e) {
} catch {
/* empty */
}
if (!cssRules) {
Expand All @@ -530,7 +530,7 @@ dialogPolyfill.isInlinePositionSetByStylesheet = function (element) {
// Ignore errors on invalid selector texts.
try {
selectedNodes = document.querySelectorAll(rule.selectorText);
} catch (e) {
} catch {
/* empty */
}
if (!selectedNodes || !inNodeList(selectedNodes, element)) {
Expand Down
2 changes: 1 addition & 1 deletion @navikt/core/react/src/overlays/action-menu/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ const ActionMenuRadioItem = forwardRef<
/* -------------------------------------------------------------------------- */
type ActionMenuDividerElement = React.ElementRef<typeof Menu.Divider>;
type MenuDividerProps = React.ComponentPropsWithoutRef<typeof Menu.Divider>;
interface ActionMenuDividerProps extends Omit<MenuDividerProps, "asChild"> {}
type ActionMenuDividerProps = Omit<MenuDividerProps, "asChild">;

const ActionMenuDivider = forwardRef<
ActionMenuDividerElement,
Expand Down
36 changes: 17 additions & 19 deletions @navikt/core/react/src/overlays/floating-menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const MenuAnchor = forwardRef<MenuAnchorElement, MenuAnchorProps>(
/* Menu Content */
/* -------------------------------------------------------------------------- */
type MenuContentElement = MenuContentInternalElement;
interface MenuContentProps extends MenuContentInternalTypeProps {}
type MenuContentProps = MenuContentInternalTypeProps;

const MenuContent = React.forwardRef<
MenuContentInternalElement,
Expand Down Expand Up @@ -370,11 +370,10 @@ const MenuContentInternal = forwardRef<
},
);

interface MenuContentInternalTypeProps
extends Omit<
MenuContentInternalProps,
keyof MenuContentInternalPrivateProps
> {}
type MenuContentInternalTypeProps = Omit<
MenuContentInternalProps,
keyof MenuContentInternalPrivateProps
>;

/* -------------------------------------------------------------------------- */
/* Menu item */
Expand Down Expand Up @@ -560,7 +559,7 @@ const MenuItemInternal = forwardRef<
/* -------------------------------------------------------------------------- */
/* Menu Group */
/* -------------------------------------------------------------------------- */
interface MenuGroupProps extends SlottedDivProps {}
type MenuGroupProps = SlottedDivProps;

const MenuGroup = forwardRef<SlottedDivElementRef, MenuGroupProps>(
(props: MenuGroupProps, ref) => {
Expand Down Expand Up @@ -634,7 +633,7 @@ const [MenuItemIndicatorProvider, useMenuItemIndicatorContext] = createContext<{
hookName: "useMenuItemIndicatorContext",
});

interface MenuItemIndicatorProps extends SlottedDivProps {}
type MenuItemIndicatorProps = SlottedDivProps;

const MenuItemIndicator = forwardRef<
SlottedDivElementRef,
Expand Down Expand Up @@ -726,7 +725,7 @@ const MenuCheckboxItem = forwardRef<MenuItemElement, MenuCheckboxItemProps>(
/* -------------------------------------------------------------------------- */
/* Menu Divider */
/* -------------------------------------------------------------------------- */
interface MenuDividerProps extends SlottedDivProps {}
type MenuDividerProps = SlottedDivProps;

const MenuDivider = forwardRef<SlottedDivElementRef, MenuDividerProps>(
(props: MenuDividerProps, ref) => {
Expand Down Expand Up @@ -821,7 +820,7 @@ const MenuSub: React.FC<MenuSubProps> = ({
/* -------------------------------------------------------------------------- */
/* Menu SubMenu Trigger */
/* -------------------------------------------------------------------------- */
interface MenuSubTriggerProps extends MenuItemInternalProps {}
type MenuSubTriggerProps = MenuItemInternalProps;

const MenuSubTrigger = forwardRef<MenuItemElement, MenuSubTriggerProps>(
(props: MenuSubTriggerProps, forwardedRef) => {
Expand Down Expand Up @@ -885,15 +884,14 @@ const MenuSubTrigger = forwardRef<MenuItemElement, MenuSubTriggerProps>(
/* -------------------------------------------------------------------------- */
/* Menu SubMenu Content */
/* -------------------------------------------------------------------------- */
interface MenuSubContentProps
extends Omit<
MenuContentInternalProps,
| keyof MenuContentInternalPrivateProps
| "onCloseAutoFocus"
| "onEntryFocus"
| "side"
| "align"
> {}
type MenuSubContentProps = Omit<
MenuContentInternalProps,
| keyof MenuContentInternalPrivateProps
| "onCloseAutoFocus"
| "onEntryFocus"
| "side"
| "align"
>;

const MenuSubContent = forwardRef<
MenuContentInternalElement,
Expand Down
7 changes: 2 additions & 5 deletions @navikt/core/react/src/overlays/floating/Floating.utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import type { Middleware, Placement } from "@floating-ui/react-dom";

const SIDE_OPTIONS = ["top", "right", "bottom", "left"] as const;
const ALIGN_OPTIONS = ["start", "center", "end"] as const;

type Side = (typeof SIDE_OPTIONS)[number];
type Align = (typeof ALIGN_OPTIONS)[number];
type Side = "top" | "right" | "bottom" | "left";
type Align = "start" | "center" | "end";
type Measurable = { getBoundingClientRect(): DOMRect };

/**
Expand Down
10 changes: 4 additions & 6 deletions @navikt/core/react/src/table/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import cl from "clsx";
import React, { forwardRef } from "react";

export interface BodyProps
extends React.HTMLAttributes<HTMLTableSectionElement> {}
export type BodyProps = React.HTMLAttributes<HTMLTableSectionElement>;

export interface BodyType
extends React.ForwardRefExoticComponent<
BodyProps & React.RefAttributes<HTMLTableSectionElement>
> {}
export type BodyType = React.ForwardRefExoticComponent<
BodyProps & React.RefAttributes<HTMLTableSectionElement>
>;

export const Body: BodyType = forwardRef(({ className, ...rest }, ref) => (
<tbody {...rest} ref={ref} className={cl("navds-table__body", className)} />
Expand Down
7 changes: 3 additions & 4 deletions @navikt/core/react/src/table/ColumnHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ export interface ColumnHeaderProps extends HeaderCellProps {
sortable?: boolean;
}

export interface ColumnHeaderType
extends React.ForwardRefExoticComponent<
ColumnHeaderProps & React.RefAttributes<HTMLTableCellElement>
> {}
export type ColumnHeaderType = React.ForwardRefExoticComponent<
ColumnHeaderProps & React.RefAttributes<HTMLTableCellElement>
>;

export const ColumnHeader: ColumnHeaderType = forwardRef(
({ className, children, sortable = false, sortKey, ...rest }, ref) => {
Expand Down
7 changes: 3 additions & 4 deletions @navikt/core/react/src/table/ExpandableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ export interface ExpandableRowProps extends Omit<RowProps, "content"> {
colSpan?: number;
}

export interface ExpandableRowType
extends React.ForwardRefExoticComponent<
ExpandableRowProps & React.RefAttributes<HTMLTableRowElement>
> {}
export type ExpandableRowType = React.ForwardRefExoticComponent<
ExpandableRowProps & React.RefAttributes<HTMLTableRowElement>
>;

export const ExpandableRow: ExpandableRowType = forwardRef(
(
Expand Down
10 changes: 4 additions & 6 deletions @navikt/core/react/src/table/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import cl from "clsx";
import React, { forwardRef } from "react";

export interface HeaderProps
extends React.HTMLAttributes<HTMLTableSectionElement> {}
export type HeaderProps = React.HTMLAttributes<HTMLTableSectionElement>;

export interface HeaderType
extends React.ForwardRefExoticComponent<
HeaderProps & React.RefAttributes<HTMLTableSectionElement>
> {}
export type HeaderType = React.ForwardRefExoticComponent<
HeaderProps & React.RefAttributes<HTMLTableSectionElement>
>;

export const Header: HeaderType = forwardRef(({ className, ...rest }, ref) => (
<thead {...rest} ref={ref} className={cl("navds-table__header", className)} />
Expand Down
7 changes: 3 additions & 4 deletions @navikt/core/react/src/table/HeaderCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export interface HeaderCellProps
textSize?: "medium" | "small";
}

export interface HeaderCellType
extends React.ForwardRefExoticComponent<
HeaderCellProps & React.RefAttributes<HTMLTableCellElement>
> {}
export type HeaderCellType = React.ForwardRefExoticComponent<
HeaderCellProps & React.RefAttributes<HTMLTableCellElement>
>;

export const HeaderCell: HeaderCellType = forwardRef(
({ className, children, align, textSize, ...rest }, ref) => {
Expand Down
7 changes: 3 additions & 4 deletions @navikt/core/react/src/table/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ export interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
shadeOnHover?: boolean;
}

export interface RowType
extends React.ForwardRefExoticComponent<
RowProps & React.RefAttributes<HTMLTableRowElement>
> {}
export type RowType = React.ForwardRefExoticComponent<
RowProps & React.RefAttributes<HTMLTableRowElement>
>;

export const Row: RowType = forwardRef(
({ className, selected = false, shadeOnHover = true, ...rest }, ref) => (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { forwardRef } from "react";
import { useVirtualFocusInternalContext } from "../Context";

export interface VirtualFocusContentProps
extends Omit<React.HTMLAttributes<HTMLDivElement>, "id"> {}
export type VirtualFocusContentProps = Omit<
React.HTMLAttributes<HTMLDivElement>,
"id"
>;

export const VirtualFocusContent = forwardRef<
HTMLDivElement,
Expand Down
2 changes: 1 addition & 1 deletion aksel.nav.no/website/components/hooks/useCheckAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useCheckAuth = (skipCheck?: boolean) => {
try {
setUser(!!JSON.parse(response)?.id);
return;
} catch (e) {
} catch {
setUser(false);
}
setUser(false);
Expand Down
2 changes: 1 addition & 1 deletion aksel.nav.no/website/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function middleware(req: NextRequest) {
}

return NextResponse.next();
} catch (e) {
} catch {
return NextResponse.next();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const editorField = defineField({
email: currentUser.email,
title: currentUser.name,
});
} catch (error) {
} catch {
const { logger } = await import("@navikt/next-logger");
logger.error({
message: "Failed to create sanity profile for user.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function extractMetadata(

try {
return JSON5.parse(metadata);
} catch (e) {
} catch {
console.error(`Could not parse JSON5 in ${dirName}`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function validateExamples(exampleData: ExampleDataT[]) {
try {
const cmd = `yarn tsc --noEmit --noUnusedLocals true --incremental false -p ${tempTsConfigFile}`;
execSync(cmd, { stdio: "inherit" }); // Setting stdio to inherit makes the output visible in the console
} catch (e) {
} catch {
success = false;
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@
"@storybook/theming": "^8.3.4",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"@vitest/eslint-plugin": "^1.1.4",
"@whitespace/storybook-addon-html": "^6.1.1",
"chromatic": "11.5.4",
Expand Down
Loading

0 comments on commit 2e98a09

Please sign in to comment.