Skip to content

Commit

Permalink
style: replace-jsdoc-typedef-with-let-type fp-134
Browse files Browse the repository at this point in the history
  • Loading branch information
what1s1ove committed Dec 28, 2023
1 parent 8afa11c commit 30ca6e5
Show file tree
Hide file tree
Showing 20 changed files with 48 additions and 60 deletions.
4 changes: 1 addition & 3 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { RuleConfigSeverity } from '@commitlint/types';

/** @typedef {import('@commitlint/types').UserConfig} UserConfig */

const PROJECT_PREFIXES = /** @type {const} */ (['fp', 'release']);

/** @type {UserConfig} */
/** @type {import('@commitlint/types').UserConfig} */
const configuration = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
Expand Down
7 changes: 5 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import sonarjs from 'eslint-plugin-sonarjs';
import unicorn from 'eslint-plugin-unicorn';
import globals from 'globals';

/** @typedef {import('eslint').Linter.FlatConfig} FlatConfig */
/** @typedef {import('eslint').Linter.ParserModule} ParserModule */
/** @typedef {import('eslint').Linter.FlatConfig} */
let FlatConfig;
/** @typedef {import('eslint').Linter.ParserModule} */
let ParserModule;

/** @type {FlatConfig} */
const ignoresConfig = {
Expand Down Expand Up @@ -65,6 +67,7 @@ const jsdocConfig = {
},
rules: {
...jsdoc.configs['recommended-typescript-flavor-error'].rules,
'jsdoc/no-undefined-types': ['error'],
'jsdoc/require-jsdoc': [
'error',
{
Expand Down
4 changes: 1 addition & 3 deletions knip.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/** @typedef {import('knip/dist').KnipConfig} KnipConfig */

/** @type {KnipConfig} */
/** @type {import('knip').KnipConfig} */
const config = {
entry: ['src/index.js'],
};
Expand Down
4 changes: 1 addition & 3 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/** @typedef {import('lint-staged').Config} Config */

/** @type {Config} */
/** @type {import('lint-staged').Config} */
const config = {
'*': [
'npm run ci:lint:fs',
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,17 @@
},
"scripts": {
"postinstall": "npx simple-git-hooks",
"_prettier": "prettier \"**/*.{json,md,yml,js}\"",
"ci:lint:commit": "npx @commitlint/cli --edit",
"ci:lint:fs": "ls-lint",
"ci:lint:editor": "editorconfig-checker",
"ci:lint:trash": "knip --config knip.config.js",
"ci:lint:format": "npm run ci:format -- --check",
"ci:lint:format": "npm run _prettier -- --check",
"ci:lint:js": "eslint \"**/*.js\"",
"ci:lint:type": "tsc --noEmit",
"ci:lint": "npm run ci:lint:fs && npm run ci:lint:editor && npm run ci:lint:trash && npm run ci:lint:format && npm run ci:lint:js && npm run ci:lint:type",
"ci:test": "node --import jsdom-global/register.js --test",
"ci:format": "prettier --write \"**/*.{json,md,yml,js}\"",
"ci:format": "npm run _prettier -- --write",
"build:clean": "rm -rf dist",
"build:dist": "tsc -p tsconfig.build.json",
"build:cp": "cp -r src readme.md package.json LICENSE dist",
Expand Down
4 changes: 1 addition & 3 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/** @typedef {import('prettier').Config} Config */

/** @type {Config} */
/** @type {import('prettier').Config} */
const config = {
arrowParens: 'always',
bracketSpacing: true,
Expand Down
9 changes: 5 additions & 4 deletions src/libs/types/html-form-control-element.type.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/** @typedef {import('./html-form-non-operational-control-element.type.js').HTMLFormNonOperationalControlElement} HTMLFormNonOperationalControlElement */
/** @typedef {import('./html-form-operational-control-element.type.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
import { HTMLFormNonOperationalControlElement } from './html-form-non-operational-control-element.type.js';
import { HTMLFormOperationalControlElement } from './html-form-operational-control-element.type.js';

/**
* @typedef {HTMLFormNonOperationalControlElement
* | HTMLFormOperationalControlElement} HTMLFormControlElement
* | HTMLFormOperationalControlElement}
*/
let HTMLFormControlElement;

export {};
export { HTMLFormControlElement };
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @typedef {HTMLButtonElement | HTMLObjectElement} HTMLFormNonOperationalControlElement */
/** @typedef {HTMLButtonElement | HTMLObjectElement} */
let HTMLFormNonOperationalControlElement;

export {};
export { HTMLFormNonOperationalControlElement };
5 changes: 3 additions & 2 deletions src/libs/types/html-form-operational-control-element.type.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* | HTMLSelectElement
* | HTMLOutputElement
* | HTMLFieldSetElement
* | HTMLTextAreaElement} HTMLFormOperationalControlElement
* | HTMLTextAreaElement}
*/
let HTMLFormOperationalControlElement;

export {};
export { HTMLFormOperationalControlElement };
7 changes: 2 additions & 5 deletions src/libs/types/types.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
/** @typedef {import('./html-form-non-operational-control-element.type.js').HTMLFormNonOperationalControlElement} HTMLFormNonOperationalControlElement */
/** @typedef {import('./html-form-operational-control-element.type.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
/** @typedef {import('./html-form-control-element.type.js').HTMLFormControlElement} HTMLFormControlElement */

export {};
export { HTMLFormControlElement } from './html-form-control-element.type.js';
export { HTMLFormOperationalControlElement } from './html-form-operational-control-element.type.js';
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ControlElementType } from '../../libs/enums/enums.js';
import { FormPayloadError } from '../../libs/exceptions/exceptions.js';
import { HTMLFormOperationalControlElement } from '../../libs/types/types.js';
import {
getCheckboxControlElementValue,
getControlElementValue,
Expand All @@ -13,8 +14,6 @@ import {
getRadioControlElementValue,
} from './libs/helpers/helpers.js';

/** @typedef {import('../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */

/**
* @template {unknown} T
* @param {HTMLFormOperationalControlElement} controlElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {
VALUE_AS_ARRAY_CUSTOM_CONTROL_ELEMENT_TYPES,
VALUE_AS_ARRAY_IDENTIFIER,
} from '../../../../../libs/constants/constants.js';

/** @typedef {import('../../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
import { HTMLFormOperationalControlElement } from '../../../../../libs/types/types.js';

/**
* @param {HTMLFormOperationalControlElement} element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @typedef {import('../../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
import { HTMLFormOperationalControlElement } from '../../../../../libs/types/types.js';

/**
* @param {HTMLFormOperationalControlElement} currentElement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { VALUE_AS_ARRAY_IDENTIFIER } from '../../../../../libs/constants/constants.js';
import { HTMLFormOperationalControlElement } from '../../../../../libs/types/types.js';
import { getFormControlElementsPayload } from '../get-form-control-elements-payload/get-form-control-elements-payload.js';

/** @typedef {import('../../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */

/**
* @template {Record<string, unknown>} T
* @param {<T extends unknown>(
* element: HTMLFormOperationalControlElement,
* ) => T} getFormControlElementPayloadCallback
* @param {(element: HTMLFormOperationalControlElement) => unknown} getFormControlElementPayloadCallback
* @param {HTMLFieldSetElement} element
* @returns {T | [T]}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { ControlElementType } from '../../../../../libs/enums/enums.js';
import { checkIsOnOf } from '../../../../../libs/helpers/helpers.js';
import {
HTMLFormControlElement,
HTMLFormOperationalControlElement,
} from '../../../../../libs/types/types.js';
import { checkHasValueAsArray } from '../check-has-value-as-array/check-has-value-as-array.helper.js';
import { checkIsReferToAnotherElement } from '../check-is-refer-to-another-element/check-is-refer-to-another-element.helper.js';
import { getControlElementValue } from '../get-control-element-value/get-control-element-value.helper.js';
import { getOperationalControlElements } from '../get-operational-control-elements/get-operational-control-elements.helper.js';
import { normalizeValueAsArrayControlElementName } from '../normalize-value-as-array-control-element-name/normalize-value-as-array-control-element-name.helper.js';

/** @typedef {import('../../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
/** @typedef {import('../../../../../libs/types/types.js').HTMLFormControlElement} HTMLFormControlElement */

/**
* @template {Record<string, unknown>} T
* @param {<T extends unknown>(
* element: HTMLFormOperationalControlElement,
* ) => T} getFormControlElementPayloadCallback
* @param {(element: HTMLFormOperationalControlElement) => unknown} getFormControlElementPayloadCallback
* @param {HTMLFormControlsCollection} elements
* @returns {T}
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {
HTMLFormControlElement,
HTMLFormOperationalControlElement,
} from '../../../../../libs/types/types.js';
import {
checkHasControlElementName,
checkIsAllowedControlElement,
checkIsAllowedControlElementType,
} from './helpers/helpers.js';

/** @typedef {import('../../../../../libs/types/types.js').HTMLFormControlElement} HTMLFormControlElement */
/** @typedef {import('../../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */

const OPERATIONAL_CONTROL_ELEMENT_CHECKERS = /** @type {const} */ ([
checkHasControlElementName,
checkIsAllowedControlElement,
Expand All @@ -20,11 +21,11 @@ const OPERATIONAL_CONTROL_ELEMENT_CHECKERS = /** @type {const} */ ([
const getOperationalControlElements = (elements) => {
return elements.filter(
/**
* @type {(
* element: HTMLFormControlElement,
* ) => element is HTMLFormOperationalControlElement}
*/ (element) => {
return Object.values(OPERATIONAL_CONTROL_ELEMENT_CHECKERS).every(
* @param {HTMLFormControlElement} element
* @returns {element is HTMLFormOperationalControlElement}
*/
(element) => {
return OPERATIONAL_CONTROL_ELEMENT_CHECKERS.every(
(checkFunction) => {
return checkFunction(element);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** @typedef {import('../../../../../../../libs/types/types.js').HTMLFormControlElement} HTMLFormControlElement */
import { HTMLFormControlElement } from '../../../../../../../libs/types/types.js';

/**
* @param {HTMLFormControlElement} element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BANNED_CONTROL_ELEMENT_TYPES } from '../../../../../../../libs/constants/constants.js';

/** @typedef {import('../../../../../../../libs/types/types.js').HTMLFormControlElement} HTMLFormControlElement */
import { HTMLFormControlElement } from '../../../../../../../libs/types/types.js';

/**
* @param {HTMLFormControlElement} element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { bannedElementNameToElementInstance } from '../../../../../../../libs/maps/maps.js';

/** @typedef {import('../../../../../../../libs/types/types.js').HTMLFormControlElement} HTMLFormControlElement */
import { HTMLFormControlElement } from '../../../../../../../libs/types/types.js';

/**
* @param {HTMLFormControlElement} element
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { VALUE_AS_ARRAY_IDENTIFIER } from '../../../../../libs/constants/constants.js';

/** @typedef {import('../../../../../libs/types/types.js').HTMLFormOperationalControlElement} HTMLFormOperationalControlElement */
import { HTMLFormOperationalControlElement } from '../../../../../libs/types/types.js';

/**
* @param {HTMLFormOperationalControlElement} element
Expand Down

0 comments on commit 30ca6e5

Please sign in to comment.