e22m4u 3 дней назад
Родитель
Сommit
2b9f0fa6d7

+ 4 - 0
.mocharc.cjs

@@ -0,0 +1,4 @@
+module.exports = {
+  extension: ['js'],
+  spec: 'src/**/*.spec.js',
+}

+ 0 - 4
.mocharc.json

@@ -1,4 +0,0 @@
-{
-  "extension": ["js"],
-  "spec": "src/**/*.spec.js"
-}

+ 1 - 14
eslint.config.js

@@ -1,8 +1,6 @@
 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';
 
@@ -15,25 +13,14 @@ export default [{
     },
   },
   plugins: {
-    'jsdoc': eslintJsdocPlugin,
     'mocha': eslintMochaPlugin,
-    'import': eslintImportPlugin,
     'chai-expect': eslintChaiExpectPlugin,
   },
   rules: {
     ...eslintJs.configs.recommended.rules,
     ...eslintPrettierConfig.rules,
-    ...eslintImportPlugin.flatConfigs.recommended.rules,
-    ...eslintMochaPlugin.configs.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'],
 }];

+ 0 - 7
jsconfig.json

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

+ 13 - 10
package.json

@@ -1,23 +1,26 @@
 {
   "name": "@e22m4u/js-empty-values",
-  "version": "0.2.0",
+  "version": "0.1.3",
   "description": "Сервис централизованного управления пустыми значениями для JavaScript",
   "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
   "license": "MIT",
   "keywords": [
+    "null",
     "empty",
     "value",
-    "payload"
+    "undefined"
   ],
-  "homepage": "https://gitrepos.ru/e22m4u/js-empty-values",
+  "homepage": "https://github.com/e22m4u/js-empty-values",
   "repository": {
     "type": "git",
-    "url": "git+https://gitrepos.ru/e22m4u/js-empty-values.git"
+    "url": "git+https://github.com/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"
   },
@@ -25,12 +28,12 @@
     "node": ">=12"
   },
   "scripts": {
-    "lint": "eslint ./src",
-    "lint:fix": "eslint ./src --fix",
+    "lint": "tsc && eslint ./src",
+    "lint:fix": "tsc && 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",
-    "build:cjs": "rimraf ./dist/cjs && node build-cjs.js",
+    "build:cjs": "rimraf ./dist/cjs && node --no-warnings=ExperimentalWarning build-cjs.js",
     "prepare": "husky"
   },
   "dependencies": {
@@ -41,19 +44,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"
+    "rimraf": "~6.1.2",
+    "typescript": "~5.9.3"
   }
 }

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

@@ -0,0 +1,16 @@
+/**
+ * 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];

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

@@ -0,0 +1,30 @@
+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;
+}

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

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

+ 1 - 0
src/index.d.ts

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

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

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

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

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

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

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

+ 14 - 0
tsconfig.json

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