Browse Source

refactor: removes type definitions

e22m4u 4 days ago
parent
commit
f1f172db8f

+ 14 - 1
eslint.config.js

@@ -1,6 +1,8 @@
 import globals from 'globals';
 import eslintJs from '@eslint/js';
+import eslintJsdocPlugin from 'eslint-plugin-jsdoc';
 import eslintMochaPlugin from 'eslint-plugin-mocha';
+import eslintImportPlugin from 'eslint-plugin-import';
 import eslintPrettierConfig from 'eslint-config-prettier';
 import eslintChaiExpectPlugin from 'eslint-plugin-chai-expect';
 
@@ -13,14 +15,25 @@ export default [{
     },
   },
   plugins: {
+    'jsdoc': eslintJsdocPlugin,
     'mocha': eslintMochaPlugin,
+    'import': eslintImportPlugin,
     'chai-expect': eslintChaiExpectPlugin,
   },
   rules: {
     ...eslintJs.configs.recommended.rules,
     ...eslintPrettierConfig.rules,
-     ...eslintMochaPlugin.configs.recommended.rules,
+    ...eslintImportPlugin.flatConfigs.recommended.rules,
+    ...eslintMochaPlugin.configs.recommended.rules,
     ...eslintChaiExpectPlugin.configs['recommended-flat'].rules,
+    ...eslintJsdocPlugin.configs['flat/recommended-error'].rules,
+    'no-duplicate-imports': 'error',
+    'jsdoc/reject-any-type': 0,
+    'jsdoc/reject-function-type': 0,
+    'jsdoc/require-param-description': 0,
+    'jsdoc/require-returns-description': 0,
+    'jsdoc/require-property-description': 0,
+    'jsdoc/tag-lines': ['error', 'any', {startLines: 1}],
   },
   files: ['src/**/*.js'],
 }];

+ 7 - 0
jsconfig.json

@@ -0,0 +1,7 @@
+{
+  "compilerOptions": {
+    "target": "es2022",
+    "module": "NodeNext",
+    "moduleResolution": "NodeNext"
+  }
+}

+ 8 - 11
package.json

@@ -5,22 +5,19 @@
   "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
   "license": "MIT",
   "keywords": [
-    "null",
     "empty",
     "value",
-    "undefined"
+    "payload"
   ],
-  "homepage": "https://github.com/e22m4u/js-empty-values",
+  "homepage": "https://gitrepos.ru/e22m4u/js-empty-values",
   "repository": {
     "type": "git",
-    "url": "git+https://github.com/e22m4u/js-empty-values.git"
+    "url": "git+https://gitrepos.ru/e22m4u/js-empty-values.git"
   },
   "type": "module",
-  "types": "./src/index.d.ts",
   "module": "./src/index.js",
   "main": "./dist/cjs/index.cjs",
   "exports": {
-    "types": "./src/index.d.ts",
     "import": "./src/index.js",
     "require": "./dist/cjs/index.cjs"
   },
@@ -28,8 +25,8 @@
     "node": ">=12"
   },
   "scripts": {
-    "lint": "tsc && eslint ./src",
-    "lint:fix": "tsc && eslint ./src --fix",
+    "lint": "eslint ./src",
+    "lint:fix": "eslint ./src --fix",
     "format": "prettier --write \"./src/**/*.js\"",
     "test": "npm run lint && c8 --reporter=text-summary mocha",
     "test:coverage": "npm run lint && c8 --reporter=text mocha",
@@ -44,19 +41,19 @@
     "@commitlint/cli": "~20.1.0",
     "@commitlint/config-conventional": "~20.0.0",
     "@eslint/js": "~9.39.1",
-    "@types/mocha": "~10.0.10",
     "c8": "~10.1.3",
     "chai": "~6.2.1",
     "esbuild": "~0.27.0",
     "eslint": "~9.39.1",
     "eslint-config-prettier": "~10.1.8",
     "eslint-plugin-chai-expect": "~3.1.0",
+    "eslint-plugin-import": "^2.32.0",
+    "eslint-plugin-jsdoc": "^61.4.1",
     "eslint-plugin-mocha": "~11.2.0",
     "globals": "~16.5.0",
     "husky": "~9.1.7",
     "mocha": "~11.7.5",
     "prettier": "~3.7.2",
-    "rimraf": "~6.1.2",
-    "typescript": "~5.9.3"
+    "rimraf": "~6.1.2"
   }
 }

+ 0 - 16
src/data-type.d.ts

@@ -1,16 +0,0 @@
-/**
- * Data type.
- */
-export declare const DataType: {
-  ANY: 'any';
-  STRING: 'string';
-  NUMBER: 'number';
-  BOOLEAN: 'boolean';
-  ARRAY: 'array';
-  OBJECT: 'object';
-};
-
-/**
- * Type of DataType.
- */
-export type DataType = (typeof DataType)[keyof typeof DataType];

+ 0 - 30
src/empty-values-service.d.ts

@@ -1,30 +0,0 @@
-import {DataType} from './data-type.js';
-import {Service} from '@e22m4u/js-service';
-
-/**
- * Empty values service.
- */
-export class EmptyValuesService extends Service {
-  /**
-   * Set empty values of.
-   *
-   * @param dataType
-   * @param emptyValues
-   */
-  setEmptyValuesOf(dataType: DataType, emptyValues: unknown[]): this;
-
-  /**
-   * Is empty.
-   *
-   * @param value
-   */
-  isEmpty(value: unknown): boolean;
-
-  /**
-   * Is empty for type.
-   *
-   * @param dataType
-   * @param value
-   */
-  isEmptyByType(dataType: DataType, value: unknown): boolean;
-}

+ 1 - 2
src/empty-values-service.js

@@ -1,8 +1,7 @@
 import {DataType} from './data-type.js';
 import {Errorf} from '@e22m4u/js-format';
 import {Service} from '@e22m4u/js-service';
-import {isDeepEqual} from './utils/index.js';
-import {getDataTypeOf} from './utils/index.js';
+import {isDeepEqual, getDataTypeOf} from './utils/index.js';
 
 /**
  * Empty values service.

+ 0 - 1
src/index.d.ts

@@ -1 +0,0 @@
-export * from './empty-values-service.js';

+ 0 - 8
src/utils/get-data-type-of.d.ts

@@ -1,8 +0,0 @@
-import {DataType} from '../data-type.js';
-
-/**
- * Get data type of.
- *
- * @param value
- */
-export declare function getDataTypeOf(value: unknown): DataType;

+ 0 - 2
src/utils/index.d.ts

@@ -1,2 +0,0 @@
-export * from './is-deep-equal.js';
-export * from './get-data-type-of.js';

+ 0 - 10
src/utils/is-deep-equal.d.ts

@@ -1,10 +0,0 @@
-/**
- * Is deep equal.
- *
- * @param firstValue
- * @param secondValue
- */
-export declare function isDeepEqual(
-  firstValue: unknown,
-  secondValue: unknown,
-): boolean;

+ 0 - 14
tsconfig.json

@@ -1,14 +0,0 @@
-{
-  "compilerOptions": {
-    "noEmit": true,
-    "target": "es2022",
-    "module": "NodeNext",
-    "moduleResolution": "NodeNext",
-    "allowJs": true,
-    "checkJs": true
-  },
-  "include": [
-    "./src/**/*.ts",
-    "./src/**/*.js"
-  ]
-}