diff --git a/packages/ui-library/.eslintrc.js b/packages/ui-library/.eslintrc.js index 7983fcea6..a95c52f38 100644 --- a/packages/ui-library/.eslintrc.js +++ b/packages/ui-library/.eslintrc.js @@ -11,4 +11,26 @@ module.exports = { plugins: ['@typescript-eslint'], extends: ['../eslint-config-boiler'], ignorePatterns: ['types/', '*.svg', '*.scss', '*.css', '*.md', '*.config.mjs', '.*', 'webpack*.js'], + rules: { + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['lit'], + importNamePattern: 'LitElement', + message: `Don't use the default LitElement class. Import from /utils/lit-element-custom instead`, + }, + ], + }, + ], + }, + overrides: [ + { + files: ['src/utils/lit-element-custom.ts'], + rules: { + 'no-restricted-imports': 'off', + }, + }, + ], }; diff --git a/packages/ui-library/src/components/button-group/index.ts b/packages/ui-library/src/components/button-group/index.ts index 13a5f0012..3083e82ee 100644 --- a/packages/ui-library/src/components/button-group/index.ts +++ b/packages/ui-library/src/components/button-group/index.ts @@ -1,12 +1,13 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { styleCustom } from './index.css'; import { ButtonGroupAlignmentType, ButtonGroupSizesType } from '../../globals/types'; import { TAG_NAME } from './renderFunction'; +import { LitElementCustom } from '../../utils/lit-element-custom'; -export class BlrButtonGroup extends LitElement { +export class BlrButtonGroup extends LitElementCustom { static styles = [styleCustom]; @property() sizeVariant: ButtonGroupSizesType = 'md'; @@ -31,4 +32,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrButtonGroup); } -export type BlrButtonGroupType = Omit; +export type BlrButtonGroupType = Omit; diff --git a/packages/ui-library/src/components/button-icon/index.ts b/packages/ui-library/src/components/button-icon/index.ts index 2d0ffd6cc..9fc8c78f8 100644 --- a/packages/ui-library/src/components/button-icon/index.ts +++ b/packages/ui-library/src/components/button-icon/index.ts @@ -1,5 +1,5 @@ /* eslint-disable no-console */ -import { LitElement, html, nothing } from 'lit'; +import { html, nothing } from 'lit'; import { classMap } from 'lit/directives/class-map.js'; import { property, state } from 'lit/decorators.js'; import { SizelessIconType } from '@boiler/icons'; @@ -21,6 +21,7 @@ import { createBlrClickEvent, createBlrFocusEvent, } from '../../globals/events'; +import { LitElementCustom } from '../../utils/lit-element-custom'; export type BlrButtonIconEventHandlers = { blrFocus?: (event: BlrFocusEvent) => void; @@ -33,7 +34,7 @@ export type BlrButtonIconEventHandlers = { * @fires blrBlur Button lost focus * @fires blrClick Button was clicked */ -export class BlrButtonIcon extends LitElement { +export class BlrButtonIcon extends LitElementCustom { static styles = [styleCustom]; @property() arialabel!: string; @@ -150,4 +151,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrButtonIcon); } -export type BlrButtonIconType = Omit & BlrButtonIconEventHandlers; +export type BlrButtonIconType = Omit & BlrButtonIconEventHandlers; diff --git a/packages/ui-library/src/components/button-text/index.ts b/packages/ui-library/src/components/button-text/index.ts index 6b5d59f55..b2628a19f 100644 --- a/packages/ui-library/src/components/button-text/index.ts +++ b/packages/ui-library/src/components/button-text/index.ts @@ -1,4 +1,4 @@ -import { LitElement, html, nothing } from 'lit'; +import { html, nothing } from 'lit'; import { classMap } from 'lit/directives/class-map.js'; import { property, state } from 'lit/decorators.js'; import { SizelessIconType } from '@boiler/icons'; @@ -27,6 +27,7 @@ import { createBlrClickEvent, createBlrFocusEvent, } from '../../globals/events'; +import { LitElementCustom } from '../../utils/lit-element-custom'; export type BlrButtonTextEventHandlers = { blrFocus?: (event: BlrFocusEvent) => void; @@ -39,7 +40,7 @@ export type BlrButtonTextEventHandlers = { * @fires blrBlur Button lost focus * @fires blrClick Button was clicked */ -export class BlrButtonText extends LitElement { +export class BlrButtonText extends LitElementCustom { static styles = [styleCustom]; @property() label = 'Button Label'; @@ -188,4 +189,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrButtonText); } -export type BlrButtonTextType = Omit & BlrButtonTextEventHandlers; +export type BlrButtonTextType = Omit & BlrButtonTextEventHandlers; diff --git a/packages/ui-library/src/components/checkbox/index.ts b/packages/ui-library/src/components/checkbox/index.ts index 5551e92c7..e8429685b 100644 --- a/packages/ui-library/src/components/checkbox/index.ts +++ b/packages/ui-library/src/components/checkbox/index.ts @@ -1,4 +1,4 @@ -import { LitElement, html, nothing } from 'lit'; +import { html, nothing } from 'lit'; import { property, query, state } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { TAG_NAME } from './renderFunction'; @@ -21,6 +21,7 @@ import { createBlrBlurEvent, createBlrFocusEvent, } from '../../globals/events'; +import { LitElementCustom } from '../../utils/lit-element-custom'; export type BlrCheckboxEventHandlers = { blrFocus?: (event: BlrFocusEvent) => void; @@ -33,7 +34,7 @@ export type BlrCheckboxEventHandlers = { * @fires blrBlur Checkbox lost focus * @fires blrCheckedChange Checkbox state changed (event.checkState) */ -export class BlrCheckbox extends LitElement { +export class BlrCheckbox extends LitElementCustom { static styles = []; @query('input') @@ -316,4 +317,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrCheckbox); } -export type BlrCheckboxType = Omit & BlrCheckboxEventHandlers; +export type BlrCheckboxType = Omit & BlrCheckboxEventHandlers; diff --git a/packages/ui-library/src/components/counter/index.ts b/packages/ui-library/src/components/counter/index.ts index c791a25a4..96e98a2db 100644 --- a/packages/ui-library/src/components/counter/index.ts +++ b/packages/ui-library/src/components/counter/index.ts @@ -1,12 +1,13 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { CounterVariantType, FormSizesType } from '../../globals/types'; import { ThemeType } from '../../foundation/_tokens-generated/index.themes'; import { counterLight, counterDark } from './index.css'; import { TAG_NAME } from './renderFunction'; +import { LitElementCustom } from '../../utils/lit-element-custom'; -export class BlrCounter extends LitElement { +export class BlrCounter extends LitElementCustom { static styles = []; @property() variant: CounterVariantType = 'neutral'; @@ -39,4 +40,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrCounter); } -export type BlrCounterType = Omit; +export type BlrCounterType = Omit; diff --git a/packages/ui-library/src/components/divider/index.ts b/packages/ui-library/src/components/divider/index.ts index 1f33d41b8..b4bc22a33 100644 --- a/packages/ui-library/src/components/divider/index.ts +++ b/packages/ui-library/src/components/divider/index.ts @@ -1,12 +1,13 @@ -import { LitElement, html } from 'lit'; +import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { dividerDark, dividerLight } from './index.css'; import { TAG_NAME } from './renderFunction'; import { ThemeType } from '../../foundation/_tokens-generated/index.themes'; import { DividerVariationTypes } from '../../globals/types'; +import { LitElementCustom } from '../../utils/lit-element-custom'; -export class BlrDivider extends LitElement { +export class BlrDivider extends LitElementCustom { @property() direction: DividerVariationTypes = 'vertical'; @property() theme: ThemeType = 'Light'; @@ -31,4 +32,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrDivider); } -export type BlrDividerType = Omit; +export type BlrDividerType = Omit; diff --git a/packages/ui-library/src/components/form-caption-group/index.ts b/packages/ui-library/src/components/form-caption-group/index.ts index 02fac6e78..f84a4f238 100644 --- a/packages/ui-library/src/components/form-caption-group/index.ts +++ b/packages/ui-library/src/components/form-caption-group/index.ts @@ -1,4 +1,4 @@ -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { FormSizesType } from '../../globals/types'; @@ -6,8 +6,9 @@ import { classMap } from 'lit/directives/class-map.js'; import { formCaptionGroupStyle } from './index.css'; import { TAG_NAME } from './renderFunction'; +import { LitElementCustom } from '../../utils/lit-element-custom'; -export class BlrFormCaptionGroup extends LitElement { +export class BlrFormCaptionGroup extends LitElementCustom { static styles = [formCaptionGroupStyle]; @property() sizeVariant: FormSizesType = 'md'; @@ -30,4 +31,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrFormCaptionGroup); } -export type BlrFormCaptionGroupType = Omit; +export type BlrFormCaptionGroupType = Omit; diff --git a/packages/ui-library/src/components/form-caption/index.ts b/packages/ui-library/src/components/form-caption/index.ts index 389cf79b6..7c5faad6d 100644 --- a/packages/ui-library/src/components/form-caption/index.ts +++ b/packages/ui-library/src/components/form-caption/index.ts @@ -1,4 +1,4 @@ -import { LitElement, TemplateResult, html, nothing } from 'lit'; +import { TemplateResult, html, nothing } from 'lit'; import { property } from 'lit/decorators.js'; import { classMap } from 'lit/directives/class-map.js'; import { TAG_NAME } from './renderFunction'; @@ -9,8 +9,9 @@ import { CaptionVariantType, FormSizesType, SizesType } from '../../globals/type import { calculateIconName } from '../../utils/calculate-icon-name'; import { getComponentConfigToken } from '../../utils/get-component-config-token'; import { BlrIconRenderFunction } from '../icon/renderFunction'; +import { LitElementCustom } from '../../utils/lit-element-custom'; -export class BlrFormCaption extends LitElement { +export class BlrFormCaption extends LitElementCustom { static styles = []; @property() message?: string; @@ -75,4 +76,4 @@ if (!customElements.get(TAG_NAME)) { customElements.define(TAG_NAME, BlrFormCaption); } -export type BlrFormCaptionType = Omit; +export type BlrFormCaptionType = Omit; diff --git a/packages/ui-library/src/components/form-label/index.stories.ts b/packages/ui-library/src/components/form-label/index.stories.ts index c2a4386ee..e0e251901 100644 --- a/packages/ui-library/src/components/form-label/index.stories.ts +++ b/packages/ui-library/src/components/form-label/index.stories.ts @@ -4,9 +4,9 @@ import { FormSizes } from '../../globals/constants'; import { BlrFormLabelType } from './index'; import { BlrFormLabelRenderFunction } from './renderFunction'; import { html } from 'lit-html'; -import { LitElement } from 'lit'; import { genericBlrComponentRenderer } from '../../utils/typesafe-generic-component-renderer'; import '../../index'; +import { LitElementCustom } from '../../utils/lit-element-custom'; const sharedStyles = html`