From 6b0c2a993da571bad6858a1cdec5010b97b1e6be Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 16 May 2024 14:04:18 +0200 Subject: [PATCH 1/7] feat: Added biome again --- biome.json | 82 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 ++- yarn.lock | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 biome.json diff --git a/biome.json b/biome.json new file mode 100644 index 0000000000..7fd63d801a --- /dev/null +++ b/biome.json @@ -0,0 +1,82 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.7.0/schema.json", + "organizeImports": { + "enabled": true + }, + "javascript": { + "jsxRuntime": "reactClassic" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "a11y": { + "noSvgWithoutTitle": "off", + "noNoninteractiveElementToInteractiveRole": "off", + "useValidAnchor": "off", + "useButtonType": "off", + "useValidAriaRole": "off", + "useValidAriaValues": "off", + "useMediaCaption": "off", + "useKeyWithClickEvents": "off", + "noNoninteractiveTabindex": "off", + "useAriaPropsForRole": "off" + }, + "style": { + "useImportType": "off", + "useTemplate": "off", + "noUselessElse": "off", + "useNodejsImportProtocol": "off", + "useConst": "off", + "noUnusedTemplateLiteral": "off", + "noInferrableTypes": "off", + "noVar": "off", + "noParameterAssign": "off", + "useNumberNamespace": "off", + "noNonNullAssertion": "off", + "useSelfClosingElements": "off", + "useDefaultParameterLast": "off" + }, + "suspicious": { + "noExplicitAny": "off", + "noShadowRestrictedNames": "off", + "noArrayIndexKey": "off", + "noAssignInExpressions": "off", + "noImplicitAnyLet": "off", + "noDoubleEquals": "off", + "useIsArray": "off", + "noGlobalIsNan": "off", + "noMisleadingCharacterClass": "off", + "noGlobalIsFinite": "off" + }, + "complexity": { + "noForEach": "off", + "useLiteralKeys": "off", + "useOptionalChain": "off", + "useArrowFunction": "off", + "noUselessTernary": "off" + }, + "performance": { + "noAccumulatingSpread": "off" + }, + "correctness": { + "useExhaustiveDependencies": "off", + "noInnerDeclarations": "off", + "useJsxKeyInIterable": "off", + "noSelfAssign": "off" + } + }, + "ignore": [ + "**/node_modules/**", + "**/lib/**", + "**/public/**", + "**/examples/**", + "**/esm/**", + "**/cjs/**", + "**/dist/**", + "**/codemod/**/*.js", + "**/tailwind/tailwind.config.js", + "**/.next/**" + ] + } +} diff --git a/package.json b/package.json index c2e1085793..1f9074847a 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "lint:css": "yarn stylelint '@navikt/**/*.css'", "changeset": "changeset", "version": "changeset version && yarn changelog", - "release": "yarn boot && yarn docgen && changeset publish" + "release": "yarn boot && yarn docgen && changeset publish", + "biome:lint": "yarn biome lint ." }, "workspaces": [ "@navikt/core/*", @@ -142,6 +143,7 @@ "url": "https://github.com/navikt/aksel.git" }, "devDependencies": { + "@biomejs/biome": "1.7.3", "@changesets/cli": "2.26.2", "@storybook/addon-a11y": "^8.0.5", "@storybook/addon-essentials": "^8.0.5", diff --git a/yarn.lock b/yarn.lock index 5a3d487ccb..c6f2d45f6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1701,6 +1701,97 @@ __metadata: languageName: node linkType: hard +"@biomejs/biome@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/biome@npm:1.7.3" + dependencies: + "@biomejs/cli-darwin-arm64": 1.7.3 + "@biomejs/cli-darwin-x64": 1.7.3 + "@biomejs/cli-linux-arm64": 1.7.3 + "@biomejs/cli-linux-arm64-musl": 1.7.3 + "@biomejs/cli-linux-x64": 1.7.3 + "@biomejs/cli-linux-x64-musl": 1.7.3 + "@biomejs/cli-win32-arm64": 1.7.3 + "@biomejs/cli-win32-x64": 1.7.3 + dependenciesMeta: + "@biomejs/cli-darwin-arm64": + optional: true + "@biomejs/cli-darwin-x64": + optional: true + "@biomejs/cli-linux-arm64": + optional: true + "@biomejs/cli-linux-arm64-musl": + optional: true + "@biomejs/cli-linux-x64": + optional: true + "@biomejs/cli-linux-x64-musl": + optional: true + "@biomejs/cli-win32-arm64": + optional: true + "@biomejs/cli-win32-x64": + optional: true + bin: + biome: bin/biome + checksum: ad6a6585f1d6fcb9c060319c614b4437d715637ecedbe5f4d45f170f0532894654e7cf5c80420da38c8c626d76fef4b6334c7ee85e6c790bd5ad4f7aa49c5182 + languageName: node + linkType: hard + +"@biomejs/cli-darwin-arm64@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-darwin-arm64@npm:1.7.3" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@biomejs/cli-darwin-x64@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-darwin-x64@npm:1.7.3" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@biomejs/cli-linux-arm64-musl@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-linux-arm64-musl@npm:1.7.3" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + +"@biomejs/cli-linux-arm64@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-linux-arm64@npm:1.7.3" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + +"@biomejs/cli-linux-x64-musl@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-linux-x64-musl@npm:1.7.3" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + +"@biomejs/cli-linux-x64@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-linux-x64@npm:1.7.3" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + +"@biomejs/cli-win32-arm64@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-win32-arm64@npm:1.7.3" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@biomejs/cli-win32-x64@npm:1.7.3": + version: 1.7.3 + resolution: "@biomejs/cli-win32-x64@npm:1.7.3" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@bjoerge/mutiny@npm:^0.5.1": version: 0.5.3 resolution: "@bjoerge/mutiny@npm:0.5.3" @@ -8433,6 +8524,7 @@ __metadata: version: 0.0.0-use.local resolution: "aksel@workspace:." dependencies: + "@biomejs/biome": 1.7.3 "@changesets/cli": 2.26.2 "@storybook/addon-a11y": ^8.0.5 "@storybook/addon-essentials": ^8.0.5 From c8a59145d5d386e116f98ac9c013277f6933d544 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 16 May 2024 19:06:40 +0200 Subject: [PATCH 2/7] bug: Fixes Disallow use of implicit any type on variable declarations. --- .../core/react/src/date/utils/navigation.ts | 6 +- .../core/react/src/date/utils/parse-date.ts | 11 +- .../filteredOptionsContext.tsx | 3 +- .../core/react/src/modal/dialog-polyfill.ts | 16 ++- .../tabs/parts/tablist/useScrollButtons.ts | 4 +- @navikt/core/react/src/util/debounce.ts | 2 +- .../search/__tests__/group-results.test.ts | 113 ++++++++++-------- .../providers/SearchNavigationProvider.tsx | 2 +- biome.json | 1 - 9 files changed, 93 insertions(+), 65 deletions(-) diff --git a/@navikt/core/react/src/date/utils/navigation.ts b/@navikt/core/react/src/date/utils/navigation.ts index f44e71bfa0..894409c168 100644 --- a/@navikt/core/react/src/date/utils/navigation.ts +++ b/@navikt/core/react/src/date/utils/navigation.ts @@ -2,7 +2,7 @@ import { setYear } from "date-fns"; import { Matcher, isMatch } from "./is-match"; export const nextEnabled = ( - months, + months: Date[], key: string, disabled: Matcher[], currentMonth: Date, @@ -258,13 +258,13 @@ const isOutOfRange = ( const nextOnRow = ( currentIndex: number, - months, + months: Date[], yearState: Date, disabled: Matcher[], mode: "home" | "end", ) => { const row = getRow(currentIndex); - let monthsOfRow; + let monthsOfRow: Date[] = []; switch (row) { case 1: diff --git a/@navikt/core/react/src/date/utils/parse-date.ts b/@navikt/core/react/src/date/utils/parse-date.ts index a3fd26fc5b..e27f9c6310 100644 --- a/@navikt/core/react/src/date/utils/parse-date.ts +++ b/@navikt/core/react/src/date/utils/parse-date.ts @@ -29,7 +29,7 @@ export const parseDate = ( type: "date" | "month", allowTwoDigitYear: boolean, ): Date => { - let parsed; + let parsed: Date; const ALLOWED_FORMATS = type === "date" ? ALLOWED_INPUT_FORMATS_DATE : ALLOWED_INPUT_FORMATS_MONTH; @@ -75,8 +75,13 @@ export const parseDate = ( } }; -function isTwoDigitYear(dateString, today, locale, formats) { - let parsed; +function isTwoDigitYear( + dateString: string, + today: Date, + locale: Locale, + formats: string[], +) { + let parsed: Date; const newFormat = formats.map((x) => x.replace("yyyy", "yy")); for (const format of newFormat) { parsed = parse(dateString, format, today, { locale }); diff --git a/@navikt/core/react/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx b/@navikt/core/react/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx index 8c9b62a1f4..df81b9fcf8 100644 --- a/@navikt/core/react/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +++ b/@navikt/core/react/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx @@ -148,7 +148,7 @@ const FilteredOptionsProvider = ({ ); const ariaDescribedBy = useMemo(() => { - let activeOption; + let activeOption: string = ""; if (!isLoading && filteredOptions.length === 0 && !allowNewValues) { activeOption = filteredOptionsUtils.getNoHitsId(id); } else if (value || isLoading) { @@ -164,6 +164,7 @@ const FilteredOptionsProvider = ({ const maybeMaxSelectedOptionsId = maxSelected?.isLimitReached && filteredOptionsUtils.getMaxSelectedOptionsId(id); + return ( cl(activeOption, maybeMaxSelectedOptionsId, partialAriaDescribedBy) || undefined diff --git a/@navikt/core/react/src/modal/dialog-polyfill.ts b/@navikt/core/react/src/modal/dialog-polyfill.ts index ef27e47ade..355c9ef917 100644 --- a/@navikt/core/react/src/modal/dialog-polyfill.ts +++ b/@navikt/core/react/src/modal/dialog-polyfill.ts @@ -260,7 +260,7 @@ function dialogPolyfillInfo(dialog) { removed ? this.downgradeModal() : this.maybeHideModal(); removed = false; }.bind(this); - var timeout; + var timeout: ReturnType; var delayModel = function (ev) { if (ev.target !== dialog) { return; @@ -631,7 +631,7 @@ dialogPolyfill.DialogManager = function () { this.mo_ = new MutationObserver(function (records) { var removed = []; records.forEach(function (rec) { - for (var i = 0, c; (c = rec.removedNodes[i]); ++i) { + for (var i = 0, c: Node; (c = rec.removedNodes[i]); ++i) { if (!(c instanceof Element)) { continue; } else if (c.localName === "dialog") { @@ -675,7 +675,11 @@ dialogPolyfill.DialogManager.prototype.unblockDocument = function () { dialogPolyfill.DialogManager.prototype.updateStacking = function () { var zIndex = this.zIndexHigh_; - for (var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i) { + for ( + var i = 0, dpi: { updateZIndex: (arg0: number, arg1: number) => void }; + (dpi = this.pendingDialogStack[i]); + ++i + ) { dpi.updateZIndex(--zIndex, --zIndex); if (i === 0) { this.overlay.style.zIndex = --zIndex; @@ -700,7 +704,11 @@ dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function ( candidate, ) { while ((candidate = findNearestDialog(candidate))) { - for (var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i) { + for ( + var i = 0, dpi: { dialog: any }; + (dpi = this.pendingDialogStack[i]); + ++i + ) { if (dpi.dialog === candidate) { return i === 0; // only valid if top-most } diff --git a/@navikt/core/react/src/tabs/parts/tablist/useScrollButtons.ts b/@navikt/core/react/src/tabs/parts/tablist/useScrollButtons.ts index 9c60087bab..f757635a66 100644 --- a/@navikt/core/react/src/tabs/parts/tablist/useScrollButtons.ts +++ b/@navikt/core/react/src/tabs/parts/tablist/useScrollButtons.ts @@ -32,9 +32,9 @@ export function useScrollButtons(listRef: React.RefObject) { const win = listRef.current?.ownerDocument ?? document ?? window; win.addEventListener("resize", handleResize); - let resizeObserver; + let resizeObserver: ResizeObserver; - if (typeof ResizeObserver !== "undefined") { + if (typeof ResizeObserver !== "undefined" && listRef.current) { resizeObserver = new ResizeObserver(handleResize); resizeObserver.observe(listRef.current); } diff --git a/@navikt/core/react/src/util/debounce.ts b/@navikt/core/react/src/util/debounce.ts index 3b6d4020ff..743b151c93 100644 --- a/@navikt/core/react/src/util/debounce.ts +++ b/@navikt/core/react/src/util/debounce.ts @@ -1,7 +1,7 @@ "use client"; // https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js export default function debounce(func, wait = 166) { - let timeout; + let timeout: ReturnType; function debounced(this: any, ...args) { const later = () => { func.apply(this, args); diff --git a/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts b/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts index 405dcf159c..37e2b4a5d4 100644 --- a/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts +++ b/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts @@ -1,73 +1,84 @@ +import { FuseResult } from "fuse.js"; import { beforeEach, describe, expect, test } from "vitest"; -import { SearchResultsT } from "@/types"; +import { FuseItemT, SearchHitT, SearchResultsT } from "@/types"; import { createSearchResult } from "../utils"; describe("createSearchResult", () => { - let result; - let rawResults; + let result: SearchHitT[]; + let rawResults: FuseResult[]; + + const placeholders = { heading: "", slug: "", content: [] }; beforeEach(() => { - result = [ - { - item: { _type: "komponent_artikkel" }, - score: 0.05, - matches: [], - }, - { - item: { _type: "aksel_artikkel" }, - score: 0.1, - matches: [], - }, - { - item: { _type: "ds_artikkel" }, - score: 0.15, - matches: [], - }, - { - item: { _type: "aksel_blogg" }, - score: 0.2, - matches: [], - }, - { - item: { _type: "aksel_prinsipp" }, - score: 0.25, - matches: [], - }, - { - item: { _type: "aksel_standalone" }, - score: 0.3, - matches: [], + const items = { + komponent_artikkel: { score: 0.05 }, + aksel_artikkel: { score: 0.1 }, + ds_artikkel: { score: 0.15 }, + aksel_blogg: { score: 0.2 }, + aksel_prinsipp: { score: 0.25 }, + aksel_standalone: { score: 0.3 }, + }; + + result = Object.entries(items).map(([key, value]) => ({ + item: { + _type: key as keyof typeof items, + ...placeholders, }, - ]; - rawResults = [ - { item: { _type: "komponent_artikkel" }, score: 0.05 }, - { item: { _type: "aksel_artikkel" }, score: 0.1 }, - { item: { _type: "ds_artikkel" }, score: 0.15 }, - { item: { _type: "aksel_blogg" }, score: 0.2 }, - { item: { _type: "aksel_prinsipp" }, score: 0.25 }, - { item: { _type: "aksel_standalone" }, score: 0.3 }, - ]; + score: value.score, + matches: [], + })); + + rawResults = Object.entries(items).map(([key, value]) => ({ + item: { _type: key as keyof typeof items, ...placeholders }, + score: value.score, + refIndex: 0, + matches: [], + })); }); test("should group hits by type", () => { const expected = { komponent_artikkel: [ - { item: { _type: "komponent_artikkel" }, score: 0.05, matches: [] }, + { + item: { _type: "komponent_artikkel", ...placeholders }, + score: 0.05, + matches: [], + }, ], aksel_artikkel: [ - { item: { _type: "aksel_artikkel" }, score: 0.1, matches: [] }, + { + item: { _type: "aksel_artikkel", ...placeholders }, + score: 0.1, + matches: [], + }, ], ds_artikkel: [ - { item: { _type: "ds_artikkel" }, score: 0.15, matches: [] }, + { + item: { _type: "ds_artikkel", ...placeholders }, + score: 0.15, + matches: [], + }, ], aksel_blogg: [ - { item: { _type: "aksel_blogg" }, score: 0.2, matches: [] }, + { + item: { _type: "aksel_blogg", ...placeholders }, + score: 0.2, + matches: [], + }, ], aksel_prinsipp: [ - { item: { _type: "aksel_prinsipp" }, score: 0.25, matches: [] }, + { + item: { _type: "aksel_prinsipp", ...placeholders }, + score: 0.25, + matches: [], + }, ], aksel_standalone: [ - { item: { _type: "aksel_standalone" }, score: 0.3, matches: [] }, + { + item: { _type: "aksel_standalone", ...placeholders }, + score: 0.3, + matches: [], + }, ], }; const actual: SearchResultsT = createSearchResult(result, rawResults); @@ -76,7 +87,11 @@ describe("createSearchResult", () => { test("should return top 3 results with score < 0.1", () => { const expected = [ - { item: { _type: "komponent_artikkel" }, score: 0.05, matches: [] }, + { + item: { _type: "komponent_artikkel", ...placeholders }, + score: 0.05, + matches: [], + }, ]; const actual: SearchResultsT = createSearchResult(result, rawResults); expect(actual.topResults).toEqual(expected); diff --git a/aksel.nav.no/website/components/website-modules/search/providers/SearchNavigationProvider.tsx b/aksel.nav.no/website/components/website-modules/search/providers/SearchNavigationProvider.tsx index a6270df116..200cde027e 100644 --- a/aksel.nav.no/website/components/website-modules/search/providers/SearchNavigationProvider.tsx +++ b/aksel.nav.no/website/components/website-modules/search/providers/SearchNavigationProvider.tsx @@ -28,7 +28,7 @@ export const SearchNavigationProvider = ({ /* Add a small delay to get a precieved smoother navigation */ useEffect(() => { - let timeout: NodeJS.Timeout; + let timeout: ReturnType; const handler = () => { timeout && clearTimeout(timeout); diff --git a/biome.json b/biome.json index 7fd63d801a..8fee2d74bb 100644 --- a/biome.json +++ b/biome.json @@ -42,7 +42,6 @@ "noShadowRestrictedNames": "off", "noArrayIndexKey": "off", "noAssignInExpressions": "off", - "noImplicitAnyLet": "off", "noDoubleEquals": "off", "useIsArray": "off", "noGlobalIsNan": "off", From 0732441e8fdc4d397039b31b2575c3bd35647db5 Mon Sep 17 00:00:00 2001 From: Ken Date: Thu, 16 May 2024 19:07:54 +0200 Subject: [PATCH 3/7] refactor: Import as type --- .../website-modules/search/__tests__/group-results.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts b/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts index 37e2b4a5d4..e190f82b92 100644 --- a/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts +++ b/aksel.nav.no/website/components/website-modules/search/__tests__/group-results.test.ts @@ -1,6 +1,6 @@ import { FuseResult } from "fuse.js"; import { beforeEach, describe, expect, test } from "vitest"; -import { FuseItemT, SearchHitT, SearchResultsT } from "@/types"; +import type { FuseItemT, SearchHitT, SearchResultsT } from "@/types"; import { createSearchResult } from "../utils"; describe("createSearchResult", () => { From 78b7bc9a60f6b53da71cac3dca095d9ce2bdc0d9 Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 27 May 2024 09:33:31 +0200 Subject: [PATCH 4/7] refactor: Reverted change to typed for-loops in dialog-polyfill --- @navikt/core/react/src/modal/dialog-polyfill.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/@navikt/core/react/src/modal/dialog-polyfill.ts b/@navikt/core/react/src/modal/dialog-polyfill.ts index 355c9ef917..1b4e35cab4 100644 --- a/@navikt/core/react/src/modal/dialog-polyfill.ts +++ b/@navikt/core/react/src/modal/dialog-polyfill.ts @@ -676,7 +676,8 @@ dialogPolyfill.DialogManager.prototype.updateStacking = function () { var zIndex = this.zIndexHigh_; for ( - var i = 0, dpi: { updateZIndex: (arg0: number, arg1: number) => void }; + // biome-ignore lint/suspicious/noImplicitAnyLet: + var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i ) { From 248013507225bf90ecb811eec9bd3fae33106eb3 Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 27 May 2024 09:34:29 +0200 Subject: [PATCH 5/7] refactor: Reverted change to typed for-loops in dialog-polyfill --- @navikt/core/react/src/modal/dialog-polyfill.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/@navikt/core/react/src/modal/dialog-polyfill.ts b/@navikt/core/react/src/modal/dialog-polyfill.ts index 1b4e35cab4..68648b45e8 100644 --- a/@navikt/core/react/src/modal/dialog-polyfill.ts +++ b/@navikt/core/react/src/modal/dialog-polyfill.ts @@ -631,7 +631,8 @@ dialogPolyfill.DialogManager = function () { this.mo_ = new MutationObserver(function (records) { var removed = []; records.forEach(function (rec) { - for (var i = 0, c: Node; (c = rec.removedNodes[i]); ++i) { + // biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type c in this scenario + for (var i = 0, c; (c = rec.removedNodes[i]); ++i) { if (!(c instanceof Element)) { continue; } else if (c.localName === "dialog") { @@ -676,7 +677,7 @@ dialogPolyfill.DialogManager.prototype.updateStacking = function () { var zIndex = this.zIndexHigh_; for ( - // biome-ignore lint/suspicious/noImplicitAnyLet: + // biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type dpi in this scenario var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i From 6ecdf519179ef410775d2f444d7da09d10b49c8a Mon Sep 17 00:00:00 2001 From: Ken <26967723+KenAJoh@users.noreply.github.com> Date: Mon, 27 May 2024 13:35:31 +0200 Subject: [PATCH 6/7] Update @navikt/core/react/src/modal/dialog-polyfill.ts Co-authored-by: Halvor Haugan <83693529+HalvorHaugan@users.noreply.github.com> --- @navikt/core/react/src/modal/dialog-polyfill.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/@navikt/core/react/src/modal/dialog-polyfill.ts b/@navikt/core/react/src/modal/dialog-polyfill.ts index 68648b45e8..f03896eac7 100644 --- a/@navikt/core/react/src/modal/dialog-polyfill.ts +++ b/@navikt/core/react/src/modal/dialog-polyfill.ts @@ -676,12 +676,8 @@ dialogPolyfill.DialogManager.prototype.unblockDocument = function () { dialogPolyfill.DialogManager.prototype.updateStacking = function () { var zIndex = this.zIndexHigh_; - for ( - // biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type dpi in this scenario - var i = 0, dpi; - (dpi = this.pendingDialogStack[i]); - ++i - ) { + // biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type dpi in this scenario + for (var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i) { dpi.updateZIndex(--zIndex, --zIndex); if (i === 0) { this.overlay.style.zIndex = --zIndex; From 7590e500f2d063e4d633cd7d89dace909544f86c Mon Sep 17 00:00:00 2001 From: Ken Date: Mon, 27 May 2024 13:36:38 +0200 Subject: [PATCH 7/7] refactor: biome-ignored inline-typing for-loop --- @navikt/core/react/src/modal/dialog-polyfill.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/@navikt/core/react/src/modal/dialog-polyfill.ts b/@navikt/core/react/src/modal/dialog-polyfill.ts index f03896eac7..1f1842b12f 100644 --- a/@navikt/core/react/src/modal/dialog-polyfill.ts +++ b/@navikt/core/react/src/modal/dialog-polyfill.ts @@ -702,11 +702,8 @@ dialogPolyfill.DialogManager.prototype.containedByTopDialog_ = function ( candidate, ) { while ((candidate = findNearestDialog(candidate))) { - for ( - var i = 0, dpi: { dialog: any }; - (dpi = this.pendingDialogStack[i]); - ++i - ) { + // biome-ignore lint/suspicious/noImplicitAnyLet: Reduntant to type dpi in this scenario + for (var i = 0, dpi; (dpi = this.pendingDialogStack[i]); ++i) { if (dpi.dialog === candidate) { return i === 0; // only valid if top-most }