From f73aa77bde083fc95d7f89e29849908ab9cc5fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 4 Dec 2023 23:53:28 +0100 Subject: [PATCH 1/6] Link TypeScript using CI --- .eslintrc.js | 7 +++++++ package.json | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 133dcb1a60..222a0b0a96 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -120,4 +120,11 @@ module.exports = { globals: { jQuery: true, }, + overrides: [{ + files: ['**/*.ts'], + parser: '@typescript-eslint/parser', + extends: [ + 'plugin:@typescript-eslint/recommended', + ], + }], }; diff --git a/package.json b/package.json index b97153c4f7..b36c3925ab 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,8 @@ "scripts": { "build": "gulp build", "changelog": "auto-changelog -p", - "lint": "eslint --ext .js . && stylelint \"**/*.{css,less,overrides,variables}\"", - "lint-fix": "eslint --ext .js . --fix && stylelint \"**/*.{css,less,overrides,variables}\" --fix" + "lint": "eslint --ext .js,.ts . && stylelint \"**/*.{css,less,overrides,variables}\"", + "lint-fix": "eslint --ext .js,.ts . --fix && stylelint \"**/*.{css,less,overrides,variables}\" --fix" }, "dependencies": { "@actions/core": "^1.6.0", From fab48a852881fe2b469623f74a3f992e86221a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 4 Dec 2023 23:56:37 +0100 Subject: [PATCH 2/6] run eslint with `--fix` --- types/fomantic-ui-accordion.d.ts | 2 +- types/fomantic-ui-api.d.ts | 2 +- types/fomantic-ui-calendar.d.ts | 8 +- types/fomantic-ui-dimmer.d.ts | 2 +- types/fomantic-ui-dropdown.d.ts | 36 ++--- types/fomantic-ui-embed.d.ts | 2 +- types/fomantic-ui-flyout.d.ts | 6 +- types/fomantic-ui-form.d.ts | 2 +- types/fomantic-ui-modal.d.ts | 6 +- types/fomantic-ui-nag.d.ts | 6 +- types/fomantic-ui-popup.d.ts | 6 +- types/fomantic-ui-progress.d.ts | 12 +- types/fomantic-ui-rating.d.ts | 2 +- types/fomantic-ui-search.d.ts | 2 +- types/fomantic-ui-shape.d.ts | 4 +- types/fomantic-ui-sidebar.d.ts | 8 +- types/fomantic-ui-slider.d.ts | 2 +- types/fomantic-ui-sticky.d.ts | 2 +- types/fomantic-ui-tab.d.ts | 8 +- types/fomantic-ui-tests.ts | 249 +++++++++++++++--------------- types/fomantic-ui-toast.d.ts | 2 +- types/fomantic-ui-transition.d.ts | 2 +- types/fomantic-ui-visibility.d.ts | 2 +- types/index.d.ts | 50 +++--- 24 files changed, 212 insertions(+), 211 deletions(-) diff --git a/types/fomantic-ui-accordion.d.ts b/types/fomantic-ui-accordion.d.ts index 5db11c9a62..939e32298a 100644 --- a/types/fomantic-ui-accordion.d.ts +++ b/types/fomantic-ui-accordion.d.ts @@ -28,7 +28,7 @@ declare namespace FomanticUI { (behavior: 'toggle', index: number): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: AccordionSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-api.d.ts b/types/fomantic-ui-api.d.ts index 37171236ab..1a8ee6de73 100644 --- a/types/fomantic-ui-api.d.ts +++ b/types/fomantic-ui-api.d.ts @@ -107,7 +107,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial> | Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial> | Partial>; (behavior: 'setting', name: K, value: APISettings[K]): JQuery; (behavior: 'setting', value: Partial> | Partial>): JQuery; (settings?: Partial> | Partial>): JQuery; diff --git a/types/fomantic-ui-calendar.d.ts b/types/fomantic-ui-calendar.d.ts index 9eaa351a6e..e486026c36 100644 --- a/types/fomantic-ui-calendar.d.ts +++ b/types/fomantic-ui-calendar.d.ts @@ -522,7 +522,7 @@ declare namespace FomanticUI { interface Formatters { /** - * + * */ yearHeader(date: Date, settings?: CalendarSettings): string; @@ -580,14 +580,14 @@ declare namespace FomanticUI { * @default 'YYYY' */ year: string; - + /** - * + * */ today(settings: CalendarSettings): string; /** - * + * */ cell(cell: string, date: Date, cellOptions: any): any } diff --git a/types/fomantic-ui-dimmer.d.ts b/types/fomantic-ui-dimmer.d.ts index c42a6a5be2..db4b0cb3eb 100644 --- a/types/fomantic-ui-dimmer.d.ts +++ b/types/fomantic-ui-dimmer.d.ts @@ -113,7 +113,7 @@ declare namespace FomanticUI { (behavior: 'set disabled'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: DimmerSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-dropdown.d.ts b/types/fomantic-ui-dropdown.d.ts index 7df6b05451..08cb813d14 100644 --- a/types/fomantic-ui-dropdown.d.ts +++ b/types/fomantic-ui-dropdown.d.ts @@ -210,7 +210,7 @@ declare namespace FomanticUI { (behavior: 'get placeholder text'): string; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: DropdownSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -345,7 +345,7 @@ declare namespace FomanticUI { * * @default 'auto' */ - placeholder: 'auto' | String | false; + placeholder: 'auto' | string | false; /** * Whether HTML included in dropdown values should be preserved. @@ -577,22 +577,22 @@ declare namespace FomanticUI { message: Dropdown.MessageSettings; /** - * + * */ regExp: Dropdown.RegExpSettings; /** - * + * */ metadata: Dropdown.MetadataSettings; /** - * + * */ fields: Dropdown.FieldsSettings; /** - * + * */ keys: Dropdown.KeysSettings; @@ -738,7 +738,7 @@ declare namespace FomanticUI { */ clearIcon: string; } - + interface ClassNames { /** * @default 'active' @@ -915,7 +915,7 @@ declare namespace FomanticUI { */ actionable: string; } - + interface Messages { /** * @default 'Add {term}' @@ -947,9 +947,9 @@ declare namespace FomanticUI { /** * @default '/[-[\]{}()*+?.,\\^$|#\s]/g' */ - escape: string; + escape: string; } - + interface Metadatas { /** * @default 'defaultText' @@ -959,24 +959,24 @@ declare namespace FomanticUI { /** * @default 'defaultValue' */ - defaultValue: string; + defaultValue: string; /** * @default 'placeholderText' */ - placeholderText: string; + placeholderText: string; /** * @default 'text' */ - text: string; + text: string; /** * @default 'value' */ - value: string; + value: string; } - + interface Fields { /** * Grouping for api results @@ -988,13 +988,13 @@ declare namespace FomanticUI { * Grouping for all dropdown values * @default 'values' */ - values: string; + values: string; /** * Whether value should be disabled * @default 'disabled' */ - disabled: string; + disabled: string; /** * Displayed dropdown text @@ -1074,7 +1074,7 @@ declare namespace FomanticUI { */ actionable: string; } - + interface Keys { /** * @default 8 diff --git a/types/fomantic-ui-embed.d.ts b/types/fomantic-ui-embed.d.ts index b45d2da128..b2a6553ad2 100644 --- a/types/fomantic-ui-embed.d.ts +++ b/types/fomantic-ui-embed.d.ts @@ -57,7 +57,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: EmbedSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-flyout.d.ts b/types/fomantic-ui-flyout.d.ts index b99f15a180..30f5ebc568 100644 --- a/types/fomantic-ui-flyout.d.ts +++ b/types/fomantic-ui-flyout.d.ts @@ -54,7 +54,7 @@ declare namespace FomanticUI { (behavior: keyof Flyout.TemplatesSettings, ...args: any): Partial>; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: FlyoutSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -372,7 +372,7 @@ declare namespace FomanticUI { */ deny: string; } - + interface ClassNames { /** * @default 'ui flyout' @@ -489,7 +489,7 @@ declare namespace FomanticUI { */ prompt: string; } - + interface RegExps { /** * @default /(iPad|iPhone|iPod)/g diff --git a/types/fomantic-ui-form.d.ts b/types/fomantic-ui-form.d.ts index 8d0b245465..ffb4425fe0 100644 --- a/types/fomantic-ui-form.d.ts +++ b/types/fomantic-ui-form.d.ts @@ -158,7 +158,7 @@ declare namespace FomanticUI { * Destroys instance and removes all events. */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: FormSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-modal.d.ts b/types/fomantic-ui-modal.d.ts index bd23805c71..545a23730d 100644 --- a/types/fomantic-ui-modal.d.ts +++ b/types/fomantic-ui-modal.d.ts @@ -68,7 +68,7 @@ declare namespace FomanticUI { (behavior: keyof Modal.TemplatesSettings, ...args: any): Partial>; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: ModalSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -244,13 +244,13 @@ declare namespace FomanticUI { closeIcon: boolean; /** - * + * * @default false */ actions: any; /** - * + * * @default true */ preserveHTML: boolean; diff --git a/types/fomantic-ui-nag.d.ts b/types/fomantic-ui-nag.d.ts index 55123a0fda..d7fffdbd08 100644 --- a/types/fomantic-ui-nag.d.ts +++ b/types/fomantic-ui-nag.d.ts @@ -23,7 +23,7 @@ declare namespace FomanticUI { (behavior: 'clear'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: NagSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -231,7 +231,7 @@ declare namespace FomanticUI { */ close: string; } - + interface ClassNames { /** * @default 'bottom' @@ -243,7 +243,7 @@ declare namespace FomanticUI { */ fixed: string; } - + interface Errors { /** * @default 'Unsupported storage method' diff --git a/types/fomantic-ui-popup.d.ts b/types/fomantic-ui-popup.d.ts index 0f924a1690..825d972fab 100644 --- a/types/fomantic-ui-popup.d.ts +++ b/types/fomantic-ui-popup.d.ts @@ -67,7 +67,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: PopupSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -402,7 +402,7 @@ declare namespace FomanticUI { */ popup: string; } - + interface Metadatas { /** * @default 'activator' @@ -439,7 +439,7 @@ declare namespace FomanticUI { */ variation: string; } - + interface ClassNames { /** * @default 'active' diff --git a/types/fomantic-ui-progress.d.ts b/types/fomantic-ui-progress.d.ts index 567cba5f4f..809a1707eb 100644 --- a/types/fomantic-ui-progress.d.ts +++ b/types/fomantic-ui-progress.d.ts @@ -158,7 +158,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: ProgressSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -355,7 +355,7 @@ declare namespace FomanticUI { */ progress: string; } - + interface ClassNames { /** * @default 'active' @@ -377,7 +377,7 @@ declare namespace FomanticUI { */ warning: string; } - + interface Texts { /** * @default false @@ -414,14 +414,14 @@ declare namespace FomanticUI { */ bars: string[]; } - + interface RegExps { /** * @default /\{\$*[A-z0-9]+\}/g */ variable: RegExp; } - + interface Metadatas { /** * @default 'percent' @@ -438,7 +438,7 @@ declare namespace FomanticUI { */ value: string; } - + interface Errors { /** * @default 'The method you called is not defined.' diff --git a/types/fomantic-ui-rating.d.ts b/types/fomantic-ui-rating.d.ts index ee458ddb4a..953632caaa 100644 --- a/types/fomantic-ui-rating.d.ts +++ b/types/fomantic-ui-rating.d.ts @@ -28,7 +28,7 @@ declare namespace FomanticUI { (behavior: 'clear rating'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: RatingSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-search.d.ts b/types/fomantic-ui-search.d.ts index 7c44066a97..a5f218fc63 100644 --- a/types/fomantic-ui-search.d.ts +++ b/types/fomantic-ui-search.d.ts @@ -107,7 +107,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: SearchSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-shape.d.ts b/types/fomantic-ui-shape.d.ts index 93f44a385a..fe136f9efe 100644 --- a/types/fomantic-ui-shape.d.ts +++ b/types/fomantic-ui-shape.d.ts @@ -102,7 +102,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: ShapeSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -257,7 +257,7 @@ declare namespace FomanticUI { */ active: string; } - + interface Errors { /** * @default 'You tried to switch to a side that does not exist.' diff --git a/types/fomantic-ui-sidebar.d.ts b/types/fomantic-ui-sidebar.d.ts index fd5b8d2382..67b500f2f3 100644 --- a/types/fomantic-ui-sidebar.d.ts +++ b/types/fomantic-ui-sidebar.d.ts @@ -68,7 +68,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: SidebarSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -281,7 +281,7 @@ declare namespace FomanticUI { */ sidebar: string; } - + interface RegExps { /** * @default /(iPad|iPhone|iPod)/g @@ -298,7 +298,7 @@ declare namespace FomanticUI { */ mobile: RegExp; } - + interface ClassNames { /** * @default 'active' @@ -370,7 +370,7 @@ declare namespace FomanticUI { */ visible: string; } - + interface Errors { /** * @default 'The method you called is not defined.' diff --git a/types/fomantic-ui-slider.d.ts b/types/fomantic-ui-slider.d.ts index d9ebd98d69..1d272c78a4 100644 --- a/types/fomantic-ui-slider.d.ts +++ b/types/fomantic-ui-slider.d.ts @@ -35,7 +35,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: SliderSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-sticky.d.ts b/types/fomantic-ui-sticky.d.ts index 0fd5febb0b..f4d39b8d4c 100644 --- a/types/fomantic-ui-sticky.d.ts +++ b/types/fomantic-ui-sticky.d.ts @@ -3,7 +3,7 @@ declare namespace FomanticUI { settings: StickySettings; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: StickySettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-tab.d.ts b/types/fomantic-ui-tab.d.ts index 01a6d94197..5f93af2199 100644 --- a/types/fomantic-ui-tab.d.ts +++ b/types/fomantic-ui-tab.d.ts @@ -48,7 +48,7 @@ declare namespace FomanticUI { */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: TabSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; @@ -278,7 +278,7 @@ declare namespace FomanticUI { */ determineTitle: Function; } - + interface Selectors { /** * @default '.ui.tab' @@ -290,7 +290,7 @@ declare namespace FomanticUI { */ parent: string; } - + interface Metadatas { /** * @default 'tab' @@ -319,7 +319,7 @@ declare namespace FomanticUI { */ active: string; } - + interface Errors { /** * @default 'You attempted to load content without API module' diff --git a/types/fomantic-ui-tests.ts b/types/fomantic-ui-tests.ts index 750cb88448..f5ce699bff 100644 --- a/types/fomantic-ui-tests.ts +++ b/types/fomantic-ui-tests.ts @@ -26,162 +26,163 @@ $().visibility(); // $ExpectType JQuery /* Define API endpoints once globally */ $.fn.api.settings.api = { - 'get followers' : '/followers/{id}?results={count}', - 'create user' : '/create', - 'add user' : '/add/{id}', - 'follow user' : '/follow/{id}', - 'search' : '/search/?query={value}' + 'get followers': '/followers/{id}?results={count}', + 'create user': '/create', + 'add user': '/add/{id}', + 'follow user': '/follow/{id}', + search: '/search/?query={value}', }; $().calendar({ - today: true, - initialDate: null, - endCalendar: $() + today: true, + initialDate: null, + endCalendar: $(), }); // $ExpectType JQuery -$.flyout('alert','hello'); // $ExpectType JQuery -$.flyout('confirm','Are you sure?',function(){}); // $ExpectType JQuery -$.flyout('prompt','Enter Code', function(){}); // $ExpectType JQuery - -$.fn.flyout.settings.templates.greet = function(username) { - return { - title: 'Greetings to ' + username + '!', - content: ''+ username.toUpperCase() + 'is the best!', - closeIcon: true, - class: 'inverted', - classContent: 'centered' - } -} +$.flyout('alert', 'hello'); // $ExpectType JQuery +$.flyout('confirm', 'Are you sure?', function () {}); // $ExpectType JQuery +$.flyout('prompt', 'Enter Code', function () {}); // $ExpectType JQuery + +$.fn.flyout.settings.templates.greet = function (username) { + return { + title: 'Greetings to ' + username + '!', + content: '' + username.toUpperCase() + 'is the best!', + closeIcon: true, + class: 'inverted', + classContent: 'centered', + }; +}; $().form({ - fields: { - field1: { - rules: [ - { - type : 'empty' - } - ] - }, - field2: { - rules: [ - { - type : 'isExactly[dog]', - prompt : '{name} is set to "{value}" that is totally wrong. It should be {ruleValue}' - } - ] - }, - field3: { - rules: [ - { - type : 'isExactly[cat]', - prompt : function(value) { - if(value == 'dog') { - return 'I told you to put cat, not dog!'; - } - return 'That is not cat'; - } - } - ] - }, - color: { - identifier: 'color', - rules: [{ - type: 'regExp', - value: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/i, - }] - }, - yearsPracticed: { - identifier : 'yearsPracticed', - depends : 'isDoctor', - rules : [ - { - type : 'empty', - prompt : 'Please enter the number of years you have been a doctor' - } - ] + fields: { + field1: { + rules: [ + { + type: 'empty', + }, + ], + }, + field2: { + rules: [ + { + type: 'isExactly[dog]', + prompt: '{name} is set to "{value}" that is totally wrong. It should be {ruleValue}', + }, + ], + }, + field3: { + rules: [ + { + type: 'isExactly[cat]', + prompt: function (value) { + if (value == 'dog') { + return 'I told you to put cat, not dog!'; + } + + return 'That is not cat'; + }, + }, + ], + }, + color: { + identifier: 'color', + rules: [{ + type: 'regExp', + value: /rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)/i, + }], + }, + yearsPracticed: { + identifier: 'yearsPracticed', + depends: 'isDoctor', + rules: [ + { + type: 'empty', + prompt: 'Please enter the number of years you have been a doctor', + }, + ], + }, + ccEmail: { + identifier: 'cc-email', + optional: true, + rules: [ + { + type: 'email', + prompt: 'Please enter a valid second e-mail', + }, + ], + }, }, - ccEmail: { - identifier : 'cc-email', - optional : true, - rules: [ - { - type : 'email', - prompt : 'Please enter a valid second e-mail' - } - ] - } - } }); // $ExpectType JQuery $().form({ - fields: { - gender: 'empty', - name: 'empty', - password : ['minLength[6]', 'empty'] - } + fields: { + gender: 'empty', + name: 'empty', + password: ['minLength[6]', 'empty'], + }, }); // $ExpectType JQuery -$.fn.form.settings.rules.date = function(str_date: string) { - return true; +$.fn.form.settings.rules.date = function (str_date: string) { + return true; }; $.modal('alert', { - title: 'Listen to me', - content: 'I love Fomantic-UI', - handler: function() { - $.toast({message:'Great!'}); - } + title: 'Listen to me', + content: 'I love Fomantic-UI', + handler: function () { + $.toast({ message: 'Great!' }); + }, }); -$.fn.modal.settings.templates.greet = function(username: string) { - // do something according to modals settings and/or given parameters - return { - title: 'Greetings to ' + username + '!', - content: ''+ username.toUpperCase() + 'is the best!', - class: 'inverted', - classContent: 'centered', - dimmerSettings: { - variation: 'inverted' - } - } -} +$.fn.modal.settings.templates.greet = function (username: string) { + // do something according to modals settings and/or given parameters + return { + title: 'Greetings to ' + username + '!', + content: '' + username.toUpperCase() + 'is the best!', + class: 'inverted', + classContent: 'centered', + dimmerSettings: { + variation: 'inverted', + }, + }; +}; $.modal('greet', 'mom'); $().nag({ - persist: true + persist: true, }); // $ExpectType JQuery -$().search("display message", "Hello, world !"); // $ExpectType JQuery +$().search('display message', 'Hello, world !'); // $ExpectType JQuery // To change the defaults for all toast at once override the module as follows $.fn.toast.settings.progressUp = true; $.fn.toast.settings.class = 'info'; $.fn.toast.settings.showIcon = true; -$.fn.toast.settings.className.box = 'toast-box'; //removes shadow -$.fn.toast.settings.className.title = 'header'; // smaller font size -$.fn.toast.settings.className.icon = 'icon'; // top position again +$.fn.toast.settings.className.box = 'toast-box'; // removes shadow +$.fn.toast.settings.className.title = 'header'; // smaller font size +$.fn.toast.settings.className.icon = 'icon'; // top position again $.fn.toast.settings.transition.closeEasing = 'easeOutBounce'; // Or apply the old defaults directly to the toast $.toast({ - title: 'LOOK', - message: 'Turned back time to 2.7.0 defaults', - showProgress: 'bottom', - //make it look like 2.7.0 - showIcon: true, - progressUp: true, - class: 'info', - className: { - box:'toast-box', - title:'header', - icon: 'icon' - }, - transition: { - closeEasing: 'easeOutBounce' - } + title: 'LOOK', + message: 'Turned back time to 2.7.0 defaults', + showProgress: 'bottom', + // make it look like 2.7.0 + showIcon: true, + progressUp: true, + class: 'info', + className: { + box: 'toast-box', + title: 'header', + icon: 'icon', + }, + transition: { + closeEasing: 'easeOutBounce', + }, }); -$().transition("shake", "200ms"); -$().transition("horizontal flip", 500, function() { alert('done!'); }); -$().transition("fade up"); \ No newline at end of file +$().transition('shake', '200ms'); +$().transition('horizontal flip', 500, function () { alert('done!'); }); +$().transition('fade up'); diff --git a/types/fomantic-ui-toast.d.ts b/types/fomantic-ui-toast.d.ts index 3730506435..4992dd1e87 100644 --- a/types/fomantic-ui-toast.d.ts +++ b/types/fomantic-ui-toast.d.ts @@ -33,7 +33,7 @@ declare namespace FomanticUI { (behavior: 'get remainingTime'): number; (behavior: 'refresh' | 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: ToastSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-transition.d.ts b/types/fomantic-ui-transition.d.ts index d08a8a4dea..014d056519 100644 --- a/types/fomantic-ui-transition.d.ts +++ b/types/fomantic-ui-transition.d.ts @@ -144,7 +144,7 @@ declare namespace FomanticUI { * Destroys instance and removes all events. */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: TransitionSettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/fomantic-ui-visibility.d.ts b/types/fomantic-ui-visibility.d.ts index aa8b9db0d1..42259ffa87 100644 --- a/types/fomantic-ui-visibility.d.ts +++ b/types/fomantic-ui-visibility.d.ts @@ -44,7 +44,7 @@ declare namespace FomanticUI { (behavior: 'get screen size'): object; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined, ): Partial>; + (behavior: 'setting', name: K, value?: undefined,): Partial>; (behavior: 'setting', name: K, value: VisibilitySettings[K]): JQuery; (behavior: 'setting', value: Partial>): JQuery; (settings?: Partial>): JQuery; diff --git a/types/index.d.ts b/types/index.d.ts index ba004a5f68..8b57b9d6c3 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -30,34 +30,34 @@ /// interface JQuery { - accordion: FomanticUI.Accordion; - api: FomanticUI.API; - calendar: FomanticUI.Calendar; - checkbox: FomanticUI.Checkbox; - dimmer: FomanticUI.Dimmer; - dropdown: FomanticUI.Dropdown; - embed: FomanticUI.Embed; - flyout: FomanticUI.Flyout; - form: FomanticUI.Form; - modal: FomanticUI.Modal; - nag: FomanticUI.Nag; - popup: FomanticUI.Popup; - progress: FomanticUI.Progress; - rating: FomanticUI.Rating; - search: FomanticUI.Search; - shape: FomanticUI.Shape; - sidebar: FomanticUI.Sidebar; - slider: FomanticUI.Slider; - sticky: FomanticUI.Sticky; - tab: FomanticUI.Tab; - toast: FomanticUI.Toast; + accordion: FomanticUI.Accordion; + api: FomanticUI.API; + calendar: FomanticUI.Calendar; + checkbox: FomanticUI.Checkbox; + dimmer: FomanticUI.Dimmer; + dropdown: FomanticUI.Dropdown; + embed: FomanticUI.Embed; + flyout: FomanticUI.Flyout; + form: FomanticUI.Form; + modal: FomanticUI.Modal; + nag: FomanticUI.Nag; + popup: FomanticUI.Popup; + progress: FomanticUI.Progress; + rating: FomanticUI.Rating; + search: FomanticUI.Search; + shape: FomanticUI.Shape; + sidebar: FomanticUI.Sidebar; + slider: FomanticUI.Slider; + sticky: FomanticUI.Sticky; + tab: FomanticUI.Tab; + toast: FomanticUI.Toast; transition: FomanticUI.Transition; visibility: FomanticUI.Visibility; } interface JQueryStatic { - api: FomanticUI.API; - flyout: FomanticUI.Flyout; - modal: FomanticUI.Modal; - toast: FomanticUI.Toast; + api: FomanticUI.API; + flyout: FomanticUI.Flyout; + modal: FomanticUI.Modal; + toast: FomanticUI.Toast; } From 3beb3773ea3327a68ca861b58007c893a6dd9c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 19 Dec 2023 12:49:33 +0100 Subject: [PATCH 3/6] disable all failing rules with todo --- .eslintrc.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 222a0b0a96..5203ae4c34 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -126,5 +126,19 @@ module.exports = { extends: [ 'plugin:@typescript-eslint/recommended', ], + rules: { + // TODO rules with a lot of errors to be fixed manually, fix in a separate PR + '@typescript-eslint/no-explicit-any': 'off', + '@typescript-eslint/triple-slash-reference': 'off', + + // TODO + 'camelcase': 'off', + 'no-alert': 'off', + 'no-use-before-define': 'off', + '@internal/eqeqeq': 'off', + '@typescript-eslint/ban-types': 'off', + '@typescript-eslint/no-empty-function': 'off', + '@typescript-eslint/no-unused-vars': 'off', + } }], }; From 07ff12217e92ef32f44c680de39d47be4608f547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 19 Dec 2023 13:06:50 +0100 Subject: [PATCH 4/6] fix eslint errors --- .eslintrc.js | 15 +++++---------- types/fomantic-ui-tests.ts | 12 ++++++------ 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5203ae4c34..555555964c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -127,18 +127,13 @@ module.exports = { 'plugin:@typescript-eslint/recommended', ], rules: { + // https://typescript-eslint.io/rules/no-use-before-define#how-to-use + 'no-use-before-define': 'off', + // TODO rules with a lot of errors to be fixed manually, fix in a separate PR + '@typescript-eslint/ban-types': 'off', // 16 eslint errors only, help wanted! '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/triple-slash-reference': 'off', - - // TODO - 'camelcase': 'off', - 'no-alert': 'off', - 'no-use-before-define': 'off', - '@internal/eqeqeq': 'off', - '@typescript-eslint/ban-types': 'off', - '@typescript-eslint/no-empty-function': 'off', - '@typescript-eslint/no-unused-vars': 'off', - } + }, }], }; diff --git a/types/fomantic-ui-tests.ts b/types/fomantic-ui-tests.ts index f5ce699bff..2986cc6b10 100644 --- a/types/fomantic-ui-tests.ts +++ b/types/fomantic-ui-tests.ts @@ -40,8 +40,8 @@ $().calendar({ }); // $ExpectType JQuery $.flyout('alert', 'hello'); // $ExpectType JQuery -$.flyout('confirm', 'Are you sure?', function () {}); // $ExpectType JQuery -$.flyout('prompt', 'Enter Code', function () {}); // $ExpectType JQuery +$.flyout('confirm', 'Are you sure?', function () { /* make eslint happy */ }); // $ExpectType JQuery +$.flyout('prompt', 'Enter Code', function () { /* make eslint happy */ }); // $ExpectType JQuery $.fn.flyout.settings.templates.greet = function (username) { return { @@ -75,7 +75,7 @@ $().form({ { type: 'isExactly[cat]', prompt: function (value) { - if (value == 'dog') { + if (value === 'dog') { return 'I told you to put cat, not dog!'; } @@ -122,8 +122,8 @@ $().form({ }, }); // $ExpectType JQuery -$.fn.form.settings.rules.date = function (str_date: string) { - return true; +$.fn.form.settings.rules.date = function (dateStr: string) { + return dateStr !== ''; }; $.modal('alert', { @@ -184,5 +184,5 @@ $.toast({ }); $().transition('shake', '200ms'); -$().transition('horizontal flip', 500, function () { alert('done!'); }); +$().transition('horizontal flip', 500, function () { /* make eslint happy */ }); $().transition('fade up'); From b3a60e301efc6c7c826cab2df897d49476361b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 19 Dec 2023 13:17:31 +0100 Subject: [PATCH 5/6] rename fomantic-ui-tests.ts to tests.ts --- types/{fomantic-ui-tests.ts => tests.ts} | 0 types/tsconfig.json | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename types/{fomantic-ui-tests.ts => tests.ts} (100%) diff --git a/types/fomantic-ui-tests.ts b/types/tests.ts similarity index 100% rename from types/fomantic-ui-tests.ts rename to types/tests.ts diff --git a/types/tsconfig.json b/types/tsconfig.json index 4e47de98c3..890aa8966a 100644 --- a/types/tsconfig.json +++ b/types/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "fomantic-ui-tests.ts" + "tests.ts" ] } From cdcf1a031c8f7f5bd12f009a43ba774b9f95bbf2 Mon Sep 17 00:00:00 2001 From: Marco 'Lubber' Wienkoop Date: Tue, 19 Dec 2023 16:58:51 +0100 Subject: [PATCH 6/6] feat(types): use new notEmpty form rule for tests --- types/tests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/types/tests.ts b/types/tests.ts index 2986cc6b10..bae2db2667 100644 --- a/types/tests.ts +++ b/types/tests.ts @@ -58,7 +58,7 @@ $().form({ field1: { rules: [ { - type: 'empty', + type: 'notEmpty', }, ], }, @@ -96,7 +96,7 @@ $().form({ depends: 'isDoctor', rules: [ { - type: 'empty', + type: 'notEmpty', prompt: 'Please enter the number of years you have been a doctor', }, ], @@ -116,9 +116,9 @@ $().form({ $().form({ fields: { - gender: 'empty', - name: 'empty', - password: ['minLength[6]', 'empty'], + gender: 'notEmpty', + name: 'notEmpty', + password: ['minLength[6]', 'notEmpty'], }, }); // $ExpectType JQuery