From 018815cf9d6d191d9ee9c764e7b897b3818b6836 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Wed, 7 Feb 2024 17:09:11 -0500 Subject: [PATCH] Clean up type validation --- netbox/project-static/dist/netbox.js.map | Bin 339681 -> 339681 bytes netbox/project-static/package.json | 1 + netbox/project-static/src/select/dynamic.ts | 19 ++++++++--------- netbox/project-static/src/select/index.ts | 1 - netbox/project-static/src/select/static.ts | 22 +++++++++----------- netbox/project-static/tsconfig.json | 2 +- netbox/project-static/yarn.lock | 12 +++++++++++ 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index f65842504da818652727004918b070bfedf5794a..b750759cc5e1f78c610b7d37552fc6b21866783c 100644 GIT binary patch delta 233 zcmaEOSLESck%kt=7N!>FEi5~A3`?A|oOJvh9gCfGf*rlnbP^pMbDedZ9i1zjLBioW zzK)KeI-ZWsc}_YO&W^5*(_ibbDD(J+fK+CKRZf@EWpNY=)p2)p%ya^gCQcv&%%|t- zvS=|DZJ(jb(!|eLG+o-3MMc`Zz)2?(Y#pj{*DTlRk+v);yq+aaAfxjkMxU}}S*2SD nHc#IPuyBsEj<=(;Bb0D<-@ed}#o+@0kc&ex delta 239 zcmaEOSLESck%kt=7N!>FEi5~A^opFboOJvh9gCfGf*n26bP^pMbDedZ9bGG&LBioW zzK)KeI-ZV>+DB~=>#IP zoq*;z=SU-X%^T z^Yg*xPd{bLvPw4}WSpZb$U*)(zRsr3Ko AZvX%Q diff --git a/netbox/project-static/package.json b/netbox/project-static/package.json index d99434544..e29d639fe 100644 --- a/netbox/project-static/package.json +++ b/netbox/project-static/package.json @@ -40,6 +40,7 @@ "devDependencies": { "@types/bootstrap": "5.2.10", "@types/cookie": "^0.5.1", + "@types/node": "^20.11.16", "@typescript-eslint/eslint-plugin": "^5.39.0", "@typescript-eslint/parser": "^5.39.0", "esbuild": "^0.13.15", diff --git a/netbox/project-static/src/select/dynamic.ts b/netbox/project-static/src/select/dynamic.ts index 360077c11..3b210d411 100644 --- a/netbox/project-static/src/select/dynamic.ts +++ b/netbox/project-static/src/select/dynamic.ts @@ -1,14 +1,14 @@ +import { TomOption } from 'tom-select/src/types'; +import { escape_html } from 'tom-select/src/utils'; +import { DynamicTomSelect } from './classes/dynamicTomSelect'; import { getElements } from '../util'; -import { DynamicTomSelect } from './classes/dynamicTomSelect' const VALUE_FIELD = 'id'; const LABEL_FIELD = 'display'; const MAX_OPTIONS = 100; - // Render the HTML for a dropdown option -function renderOption(data: any, escape: Function) { - +function renderOption(data: TomOption, escape: typeof escape_html) { // If the option has a `_depth` property, indent its label if (typeof data._depth === 'number' && data._depth > 0) { return `
${'─'.repeat(data._depth)} ${escape(data[LABEL_FIELD])}
`; @@ -17,10 +17,8 @@ function renderOption(data: any, escape: Function) { return `
${escape(data[LABEL_FIELD])}
`; } - // Initialize elements with statically-defined options export function initStaticSelects(): void { - - for (const select of getElements('select:not(.api-select):not(.color-select)')) { + for (const select of getElements( + 'select:not(.api-select):not(.color-select)', + )) { new TomSelect(select, { - plugins: ['clear_button'] + plugins: ['clear_button'], }); } - } // Initialize color selection fields export function initColorSelects(): void { - for (const select of getElements('select.color-select')) { new TomSelect(select, { render: { - option: function(item: TomOption, escape: Function) { + option: function (item: TomOption, escape: typeof escape_html) { return `
${escape(item.text)}
`; - } - } + }, + }, }); } - -} \ No newline at end of file +} diff --git a/netbox/project-static/tsconfig.json b/netbox/project-static/tsconfig.json index 69b4bb664..aed225c35 100644 --- a/netbox/project-static/tsconfig.json +++ b/netbox/project-static/tsconfig.json @@ -3,7 +3,7 @@ "forceConsistentCasingInFileNames": true, "allowSyntheticDefaultImports": true, "moduleResolution": "node", - "noUnusedParameters": true, + "noUnusedParameters": false, "esModuleInterop": true, "isolatedModules": true, "noUnusedLocals": true, diff --git a/netbox/project-static/yarn.lock b/netbox/project-static/yarn.lock index 97a82ce96..9aa66d10c 100644 --- a/netbox/project-static/yarn.lock +++ b/netbox/project-static/yarn.lock @@ -150,6 +150,13 @@ resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/node@^20.11.16": + version "20.11.16" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.16.tgz#4411f79411514eb8e2926f036c86c9f0e4ec6708" + integrity sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ== + dependencies: + undici-types "~5.26.4" + "@typescript-eslint/eslint-plugin@^5.39.0": version "5.39.0" resolved "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.39.0.tgz" @@ -2233,6 +2240,11 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + uri-js@^4.2.2: version "4.4.1" resolved "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz"