diff --git a/.eslintrc.js b/.eslintrc.js index 798635b..695bae4 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,6 +17,7 @@ module.exports = { 'plugins': [ 'react', '@typescript-eslint', + 'eslint-plugin-tsdoc', 'import' ], 'rules': { @@ -56,5 +57,11 @@ module.exports = { 'import/no-self-import': 'error', 'import/no-default-export': 'error', } + }, { + // Enable TSDoc rules for TypeScript files, allowing the use of JSDoc in JS files. + 'files': ['**/*.ts'], + 'rules': { + 'tsdoc/syntax': 'warn' + } }], }; diff --git a/CHANGES.txt b/CHANGES.txt index df021d3..828749e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -62,7 +62,7 @@ - Updated linter dependencies and rules. The deprecated TSLint package was replaced by ESLint. - Updated some transitive dependencies for vulnerability fixes. - Updated @splitsoftware/splitio package to version 10.22.4 that includes minor improvements. - - Bugfixing - Fixed error when using the SDK in localhost mode for testing with NodeJS test runners such as Jest (See https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#localhost-mode). + - Bugfixing - Fixed error when using the SDK in localhost mode for testing with Node.js test runners such as Jest (See https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#localhost-mode). 1.7.1 (November 15, 2022) - Updated React Redux peer dependency range to include React-redux@8.x.x and React@18.x.x. diff --git a/README.md b/README.md index 9041027..78d0a7c 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Split has built and maintains SDKs for: * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK) * JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK) * JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK) -* Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK) +* Node.js [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK) * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK) * PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK) * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK) diff --git a/package-lock.json b/package-lock.json index 6a18447..66643ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "eslint-plugin-compat": "^4.1.2", "eslint-plugin-import": "^2.27.5", "eslint-plugin-react": "^7.32.2", + "eslint-plugin-tsdoc": "^0.3.0", "husky": "^3.1.0", "jest": "^27.2.3", "react": "^18.0.0", @@ -1448,6 +1449,46 @@ "integrity": "sha512-vC+UDAsQti7Cv2oBahPfgnTXT7n0XZk8e7UFucNMmkauszdiiEsNFI0elmMMrh2u+IaMOvAAHo3DDzMx7y80Cw==", "dev": true }, + "node_modules/@microsoft/tsdoc": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.0.tgz", + "integrity": "sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==", + "dev": true + }, + "node_modules/@microsoft/tsdoc-config": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.17.0.tgz", + "integrity": "sha512-v/EYRXnCAIHxOHW+Plb6OWuUoMotxTN0GLatnpOb1xq0KuTNw/WI3pamJx/UbsoJP5k9MCw1QxvvhPcF9pH3Zg==", + "dev": true, + "dependencies": { + "@microsoft/tsdoc": "0.15.0", + "ajv": "~8.12.0", + "jju": "~1.4.0", + "resolve": "~1.22.2" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/@microsoft/tsdoc-config/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -3788,6 +3829,16 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-tsdoc": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.3.0.tgz", + "integrity": "sha512-0MuFdBrrJVBjT/gyhkP2BqpD0np1NxNLfQ38xXDlSs/KVVpKI2A6vN7jx2Rve/CyUsvOsMGwp9KKrinv7q9g3A==", + "dev": true, + "dependencies": { + "@microsoft/tsdoc": "0.15.0", + "@microsoft/tsdoc-config": "0.17.0" + } + }, "node_modules/eslint-scope": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", @@ -4436,10 +4487,13 @@ } }, "node_modules/function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } }, "node_modules/function.prototype.name": { "version": "1.1.5", @@ -4727,6 +4781,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -5088,12 +5154,15 @@ "dev": true }, "node_modules/is-core-module": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", - "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", "dev": true, "dependencies": { - "has": "^1.0.3" + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { "url": "https://github.com/sponsors/ljharb" @@ -7405,6 +7474,12 @@ "node": ">=8" } }, + "node_modules/jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", + "dev": true + }, "node_modules/js-sdsl": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", @@ -8674,6 +8749,15 @@ "node": ">=0.10.0" } }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -8687,12 +8771,12 @@ "dev": true }, "node_modules/resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dev": true, "dependencies": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -10991,6 +11075,44 @@ "integrity": "sha512-vC+UDAsQti7Cv2oBahPfgnTXT7n0XZk8e7UFucNMmkauszdiiEsNFI0elmMMrh2u+IaMOvAAHo3DDzMx7y80Cw==", "dev": true }, + "@microsoft/tsdoc": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.0.tgz", + "integrity": "sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==", + "dev": true + }, + "@microsoft/tsdoc-config": { + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc-config/-/tsdoc-config-0.17.0.tgz", + "integrity": "sha512-v/EYRXnCAIHxOHW+Plb6OWuUoMotxTN0GLatnpOb1xq0KuTNw/WI3pamJx/UbsoJP5k9MCw1QxvvhPcF9pH3Zg==", + "dev": true, + "requires": { + "@microsoft/tsdoc": "0.15.0", + "ajv": "~8.12.0", + "jju": "~1.4.0", + "resolve": "~1.22.2" + }, + "dependencies": { + "ajv": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", + "integrity": "sha512-sRu1kpcO9yLtYxBKvqfTeh9KzZEwO3STyX1HT+4CaDzC6HpTGYhIhPIzj9XuKU7KYDwnaeh5hcOwjy1QuJzBPA==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + } + } + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -13019,6 +13141,16 @@ } } }, + "eslint-plugin-tsdoc": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.3.0.tgz", + "integrity": "sha512-0MuFdBrrJVBjT/gyhkP2BqpD0np1NxNLfQ38xXDlSs/KVVpKI2A6vN7jx2Rve/CyUsvOsMGwp9KKrinv7q9g3A==", + "dev": true, + "requires": { + "@microsoft/tsdoc": "0.15.0", + "@microsoft/tsdoc-config": "0.17.0" + } + }, "eslint-scope": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", @@ -13262,9 +13394,9 @@ "optional": true }, "function-bind": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", "dev": true }, "function.prototype.name": { @@ -13463,6 +13595,15 @@ "has-symbols": "^1.0.2" } }, + "hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "requires": { + "function-bind": "^1.1.2" + } + }, "hosted-git-info": { "version": "2.8.9", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", @@ -13723,12 +13864,12 @@ } }, "is-core-module": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.11.0.tgz", - "integrity": "sha512-RRjxlvLDkD1YJwDbroBHMb+cukurkDWNyHx7D3oNB5x9rb5ogcksMC5wHCadcXoo67gVr/+3GFySh3134zi6rw==", + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.1.tgz", + "integrity": "sha512-z0vtXSwucUJtANQWldhbtbt7BnL0vxiFjIdDLAatwhDYty2bad6s+rijD6Ri4YuYJubLzIJLUidCh09e1djEVQ==", "dev": true, "requires": { - "has": "^1.0.3" + "hasown": "^2.0.2" } }, "is-date-object": { @@ -15429,6 +15570,12 @@ } } }, + "jju": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", + "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", + "dev": true + }, "js-sdsl": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.3.0.tgz", @@ -16389,6 +16536,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true + }, "require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -16402,12 +16555,12 @@ "dev": true }, "resolve": { - "version": "1.22.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", - "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "version": "1.22.8", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", + "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==", "dev": true, "requires": { - "is-core-module": "^2.9.0", + "is-core-module": "^2.13.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" } diff --git a/package.json b/package.json index a6d12b5..1f3bba0 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "eslint-plugin-compat": "^4.1.2", "eslint-plugin-import": "^2.27.5", "eslint-plugin-react": "^7.32.2", + "eslint-plugin-tsdoc": "^0.3.0", "husky": "^3.1.0", "jest": "^27.2.3", "react": "^18.0.0", diff --git a/src/__tests__/utils/mockNodeSplitSdk.ts b/src/__tests__/utils/mockNodeSplitSdk.ts index 4c4a8f7..97f4ec1 100644 --- a/src/__tests__/utils/mockNodeSplitSdk.ts +++ b/src/__tests__/utils/mockNodeSplitSdk.ts @@ -90,7 +90,7 @@ export function mockSdk() { const splits: jest.Mock = jest.fn().mockReturnValue([]); const manager: jest.Mock = jest.fn().mockReturnValue({ names, split, splits }); - // Client (only one client on Node SDK) + // Client (only one client on Node.js) const __client__ = mockClient(); const client = jest.fn(() => { return __client__; diff --git a/src/__tests__/utils/promiseWrapper.ts b/src/__tests__/utils/promiseWrapper.ts index ee36a2f..3c4a3da 100644 --- a/src/__tests__/utils/promiseWrapper.ts +++ b/src/__tests__/utils/promiseWrapper.ts @@ -8,8 +8,8 @@ * - setting an `onFinally` handler as the first handler (e.g. `promiseWrapper(Promise.reject()).finally(...)`) * - setting more than one handler with at least one of them being an onRejected handler * - * @param customPromise promise to wrap - * @param defaultOnRejected default onRejected function + * @param customPromise - Promise to wrap + * @param defaultOnRejected - Default onRejected function * @returns a promise that doesn't need to be handled for rejection (except when using async/await syntax). */ export default function promiseWrapper(customPromise: Promise, defaultOnRejected: (_: any) => any): Promise { diff --git a/src/asyncActions.ts b/src/asyncActions.ts index d89f42d..84268c0 100644 --- a/src/asyncActions.ts +++ b/src/asyncActions.ts @@ -32,14 +32,14 @@ export const splitSdk: ISplitSdk = { /** * This action creator initializes the Split SDK. It dispatches a Thunk (async) action. * - * @param {IInitSplitSdkParams} params + * @param params - Parameter object to initialize the SDK. */ export function initSplitSdk(params: IInitSplitSdkParams): (dispatch: Dispatch) => Promise { splitSdk.config = params.config; splitSdk.splitio = params.splitio || - // For client-side localhost mode, we need to use the client-side SDK, to support test runners that execute in NodeJS + // For client-side localhost mode, we need to use the client-side SDK, to support test runners that execute in Node.js (splitSdk.config?.core?.authorizationKey === 'localhost' && typeof splitSdk.config?.features === 'object' ? SplitFactoryForLocalhost : SplitFactory) as ISplitFactoryBuilder; @@ -86,8 +86,8 @@ export function initSplitSdk(params: IInitSplitSdkParams): (dispatch: Dispatch { @@ -102,9 +102,9 @@ function __getTreatments(client: IClientNotDetached, evalParams: IGetTreatmentsP } /** - * This action creator performs a treatment evaluation, i.e., it invokes the actual `client.getTreatment*` methods. + * This action creator performs a feature flag evaluation, i.e., it invokes the actual `client.getTreatment*` methods. * - * @param {IGetTreatmentsParams} params + * @param params - Parameter object to evaluate feature flags. */ export function getTreatments(params: IGetTreatmentsParams): Action | (() => void) { @@ -170,7 +170,7 @@ export function getTreatments(params: IGetTreatmentsParams): Action | (() => voi return addTreatments(params.key || (splitSdk.config as SplitIO.IBrowserSettings).core.key, splitNames ? getControlTreatmentsWithConfig(splitNames) : {}); } - } else { // Split SDK running in Node + } else { // Split SDK running in Node.js // Evaluate Split and return redux action. const client = splitSdk.factory.client() as SplitIO.IClient; @@ -208,8 +208,8 @@ interface IClientNotDetached extends SplitIO.IBrowserClient { * These lists are used by `getTreatments` action creator to schedule evaluation of feature flags on SDK_UPDATE, SDK_READY and SDK_READY_FROM_CACHE events. * It is exported for testing purposes only. * - * @param splitSdk it contains the Split factory, the store dispatch function, and other internal properties - * @param key optional user key + * @param splitSdk - It contains the Split factory, the store dispatch function, and other internal properties + * @param key - Optional user key * @returns SDK client with `evalOnUpdate`, `evalOnReady` and `evalOnReadyFromCache` action lists. */ export function getClient(splitSdk: ISplitSdk, key?: SplitIO.SplitKey): IClientNotDetached { diff --git a/src/helpers.ts b/src/helpers.ts index 405438f..d9a1c09 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -8,7 +8,7 @@ import { initialStatus } from './reducer'; * This function track events, i.e., it invokes the actual `client.track*` methods. * This function is not an action creator, but rather a simple access to `client.track()`. * - * @param {ITrackParams} params + * @param params - Parameter object to track an event. * * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#track} */ @@ -20,8 +20,8 @@ export function track(params: ITrackParams): boolean { const { key, trafficType, eventType, value, properties } = params; - if (splitSdk.isDetached) { // Node - // In node, user must always provide key and TT as params + if (splitSdk.isDetached) { // Node.js + // In Node.js, user must always provide key and TT as params const client = splitSdk.factory.client() as SplitIO.IClient; return client.track(key, trafficType, eventType, value, properties); @@ -36,7 +36,7 @@ export function track(params: ITrackParams): boolean { /** * Gets the array of feature flag names. * - * @returns {string[]} The list of feature flag names. The list might be empty if the SDK was not initialized or if it's not ready yet. + * @returns The list of feature flag names. The list might be empty if the SDK was not initialized or if it's not ready yet. * * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#manager} */ @@ -52,8 +52,8 @@ export function getSplitNames(): string[] { /** * Gets the data of a split in SplitView format. * - * @param {string} featureFlagName The name of the split we wan't to get info of. - * @returns {SplitView} The SplitIO.SplitView of the given split, or null if split does not exist or the SDK was not initialized or is not ready. + * @param featureFlagName - The name of the feature flag we wan't to get info of. + * @returns The SplitIO.SplitView of the given split, or null if split does not exist or the SDK was not initialized or is not ready. * * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#manager} */ @@ -69,7 +69,7 @@ export function getSplit(featureFlagName: string): SplitIO.SplitView { /** * Gets the array of feature flags data in SplitView format. * - * @returns {SplitViews} The list of SplitIO.SplitView. The list might be empty if the SDK was not initialized or if it's not ready yet + * @returns The list of SplitIO.SplitView. The list might be empty if the SDK was not initialized or if it's not ready yet * * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#manager} */ @@ -88,10 +88,10 @@ export function getSplits(): SplitIO.SplitViews { * This function is similar to the `selectStatus` selector, but it does not require the Split state as a parameter since it uses the global `splitSdk` object. * Consider using the `selectStatus` selector instead for a more Redux-friendly approach. * - * @param {SplitIO.SplitKey} key To use only on client-side. Ignored in server-side. If a key is provided and a client associated to that key has been used, the status of that client is returned. + * @param key - To use only on client-side. Ignored in server-side. If a key is provided and a client associated to that key has been used, the status of that client is returned. * If no key is provided, the status of the main client and manager is returned (the main client shares the status with the manager). * - * @returns {IStatus} The status of the SDK client or manager. + * @returns The status of the SDK client or manager. * * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#subscribe-to-events} */ diff --git a/src/react-redux/connectSplit.ts b/src/react-redux/connectSplit.ts index b0d48e1..3398c1a 100644 --- a/src/react-redux/connectSplit.ts +++ b/src/react-redux/connectSplit.ts @@ -8,7 +8,7 @@ import { defaultGetSplitState } from '../selectors'; * - The Split state at Redux, under the prop key `split`. * - The action creator `getTreatments`, bound to the `dispatch` of your store. * - * @param {IGetSplitState} getSplitState optional function that takes the entire Redux state and returns + * @param getSplitState - Optional function that takes the entire Redux state and returns * the state slice which corresponds to where the Split reducer was mounted. This functionality is rarely * needed, and defaults to assuming that the reducer is mounted under the `splitio` key. */ diff --git a/src/react-redux/connectToggler.ts b/src/react-redux/connectToggler.ts index e0997ab..c5421f3 100644 --- a/src/react-redux/connectToggler.ts +++ b/src/react-redux/connectToggler.ts @@ -9,10 +9,6 @@ const NullRenderComponent: React.ComponentType = () => null; /** * To avoid passing down dispatch property, merge props override default * behaviour from connect. Here dispatchProps are not passing down. - * - * @param {any} stateProps - * @param {any} dispatchProps - * @param {any} ownProps */ const mergeProps = (stateProps: any, dispatchProps: any, ownProps: any) => ({ ...stateProps, @@ -20,11 +16,8 @@ const mergeProps = (stateProps: any, dispatchProps: any, ownProps: any) => ({ }); /** - * This toggler just returns a react component that decides which component to render + * This toggler just returns a react component that decides which component to render * regarding it props. - * - * @param {React.ComponentType} ComponentOn - * @param {React.ComponentType} ComponentDefault */ const toggler = (ComponentOn: React.ComponentType, ComponentDefault: React.ComponentType = NullRenderComponent) => ({ isFeatureOn, ...props }: { isFeatureOn: boolean }) => @@ -34,9 +27,9 @@ const toggler = (ComponentOn: React.ComponentType, ComponentDefault: React.Compo * Looks on the features of the Split piece of state, and maps to isFeatureOn * depending if this feature is ON or not * - * @param {string} featureFlagName feature flag name - * @param {SplitIO.SplitKey} key user key - * @param {IGetSplitState} getSplitState function that extract the Split piece of state from the Redux state. + * @param featureFlagName - The feature flag name. + * @param key - The user key. + * @param getSplitState - Function that extract the Split piece of state from the Redux state. */ export function mapIsFeatureOnToProps(featureFlagName: string, key?: SplitIO.SplitKey, getSplitState: IGetSplitState = defaultGetSplitState) { return (state: any) => { @@ -51,9 +44,9 @@ export function mapIsFeatureOnToProps(featureFlagName: string, key?: SplitIO.Spl * Looks on the features of the Split piece of state, and maps to feature * the value of this feature * - * @param {string} featureFlagName feature flag name - * @param {SplitIO.SplitKey} key user key - * @param {IGetSplitState} getSplitState function that extract the Split piece of state from the Redux state. + * @param featureFlagName - The feature flag name. + * @param key - The user key. + * @param getSplitState - Function that extract the Split piece of state from the Redux state. */ export function mapTreatmentToProps(featureFlagName: string, key?: SplitIO.SplitKey, getSplitState: IGetSplitState = defaultGetSplitState): (state: any) => { feature: string } { return (state: any) => { @@ -71,9 +64,9 @@ export function mapTreatmentToProps(featureFlagName: string, key?: SplitIO.Split * * So connect send the global state and the toggler decide which to render * - * @param {string} featureFlagtName feature flag name - * @param {SplitIO.SplitKey} key user key - * @param {IGetSplitState} getSplitState function that extract the Split piece of state from the Redux state. + * @param featureFlagtName - The feature flag name. + * @param key - The user key. + * @param getSplitState - Function that extract the Split piece of state from the Redux state. */ export function connectToggler(featureFlagName: string, key?: SplitIO.SplitKey, getSplitState: IGetSplitState = defaultGetSplitState) { return (ComponentOn: React.ComponentType, ComponentDefault?: React.ComponentType) => diff --git a/src/selectors.ts b/src/selectors.ts index ed1411e..1f19da6 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -12,10 +12,10 @@ export const defaultGetSplitState = getStateSlice(DEFAULT_SPLIT_STATE_SLICE); * If a treatment is not found, it returns the default value, which is `'control'` if not specified. * A treatment is not found if an invalid Split state is passed or if a `getTreatments` action has not been dispatched for the provided feature flag name and key. * - * @param {ISplitState} splitState - * @param {string} featureFlagName - * @param {SplitIO.SplitKey} key - * @param {string} defaultValue + * @param splitState - The Split piece of state. + * @param featureFlagName - The feature flag name. + * @param key - The user key. + * @param defaultValue - The default value to return if the treatment is not found. */ export function selectTreatmentValue(splitState: ISplitState, featureFlagName: string, key?: SplitIO.SplitKey, defaultValue: string = CONTROL): string { return selectTreatmentWithConfig(splitState, featureFlagName, key, { treatment: defaultValue, config: null }).treatment; @@ -26,10 +26,10 @@ export function selectTreatmentValue(splitState: ISplitState, featureFlagName: s * If a treatment is not found, it returns the default value, which is `{ treatment: 'control', configuration: null }` if not specified. * A treatment is not found if an invalid Split state is passed or if a `getTreatments` action has not been dispatched for the provided feature flag name and key. * - * @param {ISplitState} splitState - * @param {string} featureFlagName - * @param {SplitIO.SplitKey} key - * @param {SplitIO.TreatmentWithConfig} defaultValue + * @param splitState - The Split piece of state. + * @param featureFlagName - The feature flag name. + * @param key - The user key. + * @param defaultValue - The default value to return if the treatment is not found. */ export function selectTreatmentWithConfig(splitState: ISplitState, featureFlagName: string, key?: SplitIO.SplitKey, defaultValue: SplitIO.TreatmentWithConfig = CONTROL_WITH_CONFIG): SplitIO.TreatmentWithConfig { const splitTreatments = splitState && splitState.treatments ? splitState.treatments[featureFlagName] : console.error(ERROR_SELECTOR_NO_SPLITSTATE); @@ -48,10 +48,10 @@ export function selectTreatmentWithConfig(splitState: ISplitState, featureFlagNa * If a treatment is not found, it returns the default value, which is `'control'` if not specified. * A treatment is not found if an invalid Split state is passed or if a `getTreatments` action has not been dispatched for the provided feature flag name and key. * - * @param {ISplitState} splitState - * @param {string} featureFlagName - * @param {SplitIO.SplitKey} key - * @param {string} defaultValue + * @param splitState - The Split piece of state. + * @param featureFlagName - The feature flag name. + * @param key - The user key. + * @param defaultValue - The default value to return if the treatment is not found. */ export function selectTreatmentAndStatus(splitState: ISplitState, featureFlagName: string, key?: SplitIO.SplitKey, defaultValue: string = CONTROL): { treatment: string @@ -66,10 +66,10 @@ export function selectTreatmentAndStatus(splitState: ISplitState, featureFlagNam * If a treatment is not found, it returns the default value as treatment, which is `{ treatment: 'control', configuration: null }` if not specified. * A treatment is not found if an invalid Split state is passed or if a `getTreatments` action has not been dispatched for the provided feature flag name and key. * - * @param {ISplitState} splitState - * @param {string} featureFlagName - * @param {SplitIO.SplitKey} key - * @param {SplitIO.TreatmentWithConfig} defaultValue + * @param splitState - The Split piece of state. + * @param featureFlagName - The feature flag name. + * @param key - The user key. + * @param defaultValue - The default value to return if the treatment is not found. */ export function selectTreatmentWithConfigAndStatus(splitState: ISplitState, featureFlagName: string, key?: SplitIO.SplitKey, defaultValue: SplitIO.TreatmentWithConfig = CONTROL_WITH_CONFIG): { treatment: SplitIO.TreatmentWithConfig @@ -87,11 +87,11 @@ export function selectTreatmentWithConfigAndStatus(splitState: ISplitState, feat /** * Extracts an object with the status properties of the SDK client or manager from the Split state. * - * @param {ISplitState} splitState - * @param {SplitIO.SplitKey} key To use only on client-side. Ignored in server-side. If a key is provided and a client associated to that key has been used, the status of that client is returned. + * @param splitState - The Split piece of state. + * @param key - To use only on client-side. Ignored in server-side. If a key is provided and a client associated to that key has been used, the status of that client is returned. * If no key is provided, the status of the main client and manager is returned (the main client shares the status with the manager). * - * @returns {IStatus} The status of the SDK client or manager. + * @returns The status of the SDK client or manager. * * @see {@link https://help.split.io/hc/en-us/articles/360038851551-Redux-SDK#subscribe-to-events} */ diff --git a/src/types.ts b/src/types.ts index c2733ad..d4db8d2 100644 --- a/src/types.ts +++ b/src/types.ts @@ -77,7 +77,7 @@ export interface IInitSplitSdkParams { config: SplitIO.IBrowserSettings | SplitIO.INodeSettings; /** - * Optional param to provide a Split factory initializer to use instead of SplitFactory from '@splitsoftware/splitio'. + * Optional param to provide a Split factory initializer to use instead of SplitFactory from `'@splitsoftware/splitio'`. * It can be useful when the Split factory is imported from the UMD bundle in a HTML script. */ splitio?: ISplitFactoryBuilder; @@ -125,14 +125,16 @@ export type IGetTreatmentsParams = { * the desired behaviour for permission toggles or operation toggles, such as a kill switch, that you want to * inmediately reflect in your app. A `false` value might be useful for experiment or release toggles, where * you want to keep the treatment unchanged during the sesion of the user. - * @default false + * + * @defaultValue `false` */ evalOnUpdate?: boolean; /** * This param indicates to evaluate the feature flags if the SDK is ready from cache (i.e., it emits SDK_READY_FROM_CACHE event). * This params is only relevant when using 'LOCALSTORAGE' as storage type, since otherwise the event is never emitted. - * @default false + * + * @defaultValue `false` */ evalOnReadyFromCache?: boolean; } & ({