diff --git a/change/@fluentui-eslint-plugin-c622c77c-61e2-4433-b4cf-da2ad0984040.json b/change/@fluentui-eslint-plugin-c622c77c-61e2-4433-b4cf-da2ad0984040.json new file mode 100644 index 00000000000000..01fe1dbcec343a --- /dev/null +++ b/change/@fluentui-eslint-plugin-c622c77c-61e2-4433-b4cf-da2ad0984040.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "chore: removes type dependency on @fluentui/react-utilities internals in ban-instanceof-html-element", + "packageName": "@fluentui/eslint-plugin", + "email": "bernardo.sunderhus@gmail.com", + "dependentChangeType": "patch" +} diff --git a/change/@fluentui-react-utilities-8376a788-0cd7-4976-b302-c88844a11938.json b/change/@fluentui-react-utilities-8376a788-0cd7-4976-b302-c88844a11938.json new file mode 100644 index 00000000000000..a8dc827ee25448 --- /dev/null +++ b/change/@fluentui-react-utilities-8376a788-0cd7-4976-b302-c88844a11938.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "chore: stops leaking HTMLElementConstructorName type", + "packageName": "@fluentui/react-utilities", + "email": "bernardo.sunderhus@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js b/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js index b94857077afd62..91d60320518cf7 100644 --- a/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js +++ b/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js @@ -3,7 +3,7 @@ const { AST_NODE_TYPES } = require('@typescript-eslint/utils'); const createRule = require('../../utils/createRule'); /** - * @typedef {import("@fluentui/react-utilities/src/utils/isHTMLElement").HTMLElementConstructorName} HTMLElementConstructorName + * @typedef {import('./types').HTMLElementConstructorName} HTMLElementConstructorName * */ @@ -56,7 +56,6 @@ const constructorNames = [ 'HTMLDataElement', 'HTMLDataListElement', 'HTMLDetailsElement', - // @ts-expect-error - NOTE: dialog is not supported in safari 14, also it was removed from lib-dom starting typescript 4.4 'HTMLDialogElement', 'HTMLDivElement', 'HTMLDListElement', diff --git a/packages/eslint-plugin/src/rules/ban-instanceof-html-element/types.d.ts b/packages/eslint-plugin/src/rules/ban-instanceof-html-element/types.d.ts new file mode 100644 index 00000000000000..9f2378c8b8bcd3 --- /dev/null +++ b/packages/eslint-plugin/src/rules/ban-instanceof-html-element/types.d.ts @@ -0,0 +1,64 @@ +/** + * All the possible HTML element constructor names. + */ +export type HTMLElementConstructorName = + | 'HTMLElement' + | 'HTMLAnchorElement' + | 'HTMLAreaElement' + | 'HTMLAudioElement' + | 'HTMLBaseElement' + | 'HTMLBodyElement' + | 'HTMLBRElement' + | 'HTMLButtonElement' + | 'HTMLCanvasElement' + | 'HTMLDataElement' + | 'HTMLDataListElement' + | 'HTMLDetailsElement' + | 'HTMLDialogElement' + | 'HTMLDivElement' + | 'HTMLDListElement' + | 'HTMLEmbedElement' + | 'HTMLFieldSetElement' + | 'HTMLFormElement' + | 'HTMLHeadingElement' + | 'HTMLHeadElement' + | 'HTMLHRElement' + | 'HTMLHtmlElement' + | 'HTMLIFrameElement' + | 'HTMLImageElement' + | 'HTMLInputElement' + | 'HTMLModElement' + | 'HTMLLabelElement' + | 'HTMLLegendElement' + | 'HTMLLIElement' + | 'HTMLLinkElement' + | 'HTMLMapElement' + | 'HTMLMetaElement' + | 'HTMLMeterElement' + | 'HTMLObjectElement' + | 'HTMLOListElement' + | 'HTMLOptGroupElement' + | 'HTMLOptionElement' + | 'HTMLOutputElement' + | 'HTMLParagraphElement' + | 'HTMLParamElement' + | 'HTMLPreElement' + | 'HTMLProgressElement' + | 'HTMLQuoteElement' + | 'HTMLSlotElement' + | 'HTMLScriptElement' + | 'HTMLSelectElement' + | 'HTMLSourceElement' + | 'HTMLSpanElement' + | 'HTMLStyleElement' + | 'HTMLTableElement' + | 'HTMLTableColElement' + | 'HTMLTableRowElement' + | 'HTMLTableSectionElement' + | 'HTMLTemplateElement' + | 'HTMLTextAreaElement' + | 'HTMLTimeElement' + | 'HTMLTitleElement' + | 'HTMLTrackElement' + | 'HTMLUListElement' + | 'HTMLVideoElement'; diff --git a/packages/react-components/react-utilities/src/utils/isHTMLElement.ts b/packages/react-components/react-utilities/src/utils/isHTMLElement.ts index 74969ccffb3f65..a9573ae66ec455 100644 --- a/packages/react-components/react-utilities/src/utils/isHTMLElement.ts +++ b/packages/react-components/react-utilities/src/utils/isHTMLElement.ts @@ -29,10 +29,7 @@ export function isHTMLElement