Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure defineElement is used instead of customElement #685

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ module.exports = {
'lit/prefer-nothing': 'error',
'local-rules/uui-class-prefix': 'warn',
'local-rules/prefer-static-styles-last': 'warn',
'no-restricted-syntax': [
'warn',
{
message:
'Elements should not be defined with customElement, use defineElement instead.',
selector:
'ClassDeclaration > Decorator[expression.callee.name="customElement"]',
},
],
},
parserOptions: {
project: './tsconfig.json',
Expand Down
5 changes: 3 additions & 2 deletions packages/uui-combobox/lib/uui-combobox-async-example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
import { css, html, LitElement, nothing } from 'lit';
import { customElement, state } from 'lit/decorators.js';
import { state } from 'lit/decorators.js';

interface Fruit {
name: string;
Expand All @@ -26,7 +27,7 @@ const data: Array<Fruit> = [
{ name: 'Lime', value: 'lime' },
];

@customElement('uui-combobox-async-example')
@defineElement('uui-combobox-async-example')
export class UUIComboboxAsyncExampleElement extends LitElement {
@state()
_options: any[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';
import { html, LitElement } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { property, state } from 'lit/decorators.js';

interface Fruit {
name: string;
Expand Down Expand Up @@ -30,7 +31,7 @@ async function getFruits() {
return Promise.resolve(data);
}

@customElement('uui-combobox-async-options-example')
@defineElement('uui-combobox-async-options-example')
export class UUIComboboxAsyncOptionsExampleElement extends LitElement {
@state()
_options: any[] = [];
Expand Down
5 changes: 3 additions & 2 deletions packages/uui-modal/lib/modal-example.element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { LitElement, css, html, TemplateResult } from 'lit';
import { customElement, state } from 'lit/decorators.js';
import { state } from 'lit/decorators.js';
import './uui-modal-container';
import { ref, createRef } from 'lit/directives/ref.js';
import { UUIModalElement } from './uui-modal.element';
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';

@customElement('modal-example')
@defineElement('modal-example')
export class ModalExampleElement extends LitElement {
@state()
private _modals: TemplateResult<1>[] = [];
Expand Down
6 changes: 4 additions & 2 deletions packages/uui-modal/lib/uui-modal-container.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { LitElement, PropertyValueMap, css, html } from 'lit';
import { customElement, property, query, state } from 'lit/decorators.js';
import { property, query, state } from 'lit/decorators.js';
import { UUIModalSidebarElement } from './uui-modal-sidebar.element';
import { UUIModalElement } from './uui-modal.element';
@customElement('uui-modal-container')
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';

@defineElement('uui-modal-container')
export class UUIModalContainerElement extends LitElement {
@query('slot')
modalSlot?: HTMLSlotElement;
Expand Down
4 changes: 2 additions & 2 deletions packages/uui-modal/lib/uui-modal-dialog.element.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { css, html } from 'lit';
import { customElement } from 'lit/decorators.js';
import { UUIModalElement } from './uui-modal.element';
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';

@customElement('uui-modal-dialog')
@defineElement('uui-modal-dialog')
export class UUIModalDialogElement extends UUIModalElement {
render() {
return html`
Expand Down
5 changes: 3 additions & 2 deletions packages/uui-modal/lib/uui-modal-sidebar.element.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { css, html, PropertyValueMap } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { property } from 'lit/decorators.js';
import { UUIModalElement } from './uui-modal.element';
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';

export type UUIModalSidebarSize = 'small' | 'medium' | 'large' | 'full';

@customElement('uui-modal-sidebar')
@defineElement('uui-modal-sidebar')
export class UUIModalSidebarElement extends UUIModalElement {
/**
* @attr
Expand Down
5 changes: 3 additions & 2 deletions packages/uui-table/lib/uui-table-advanced-example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import '@umbraco-ui/uui-tag/lib';

import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
import { css, html, LitElement } from 'lit';
import { customElement, state } from 'lit/decorators.js';
import { state } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import { defineElement } from '@umbraco-ui/uui-base/lib/registration';

interface TableColumn {
name: string;
Expand All @@ -25,7 +26,7 @@ interface TableItem {
newsletter: boolean;
}

@customElement('uui-table-with-selection-example')
@defineElement('uui-table-with-selection-example')
export class UUITableWithSelectionExampleElement extends LitElement {
@state()
private _columns: Array<TableColumn> = [];
Expand Down
Loading