{"id":13739872,"url":"https://github.com/azu/babel-plugin-jsdoc-to-assert","last_synced_at":"2025-04-15T01:05:55.502Z","repository":{"id":66143205,"uuid":"54364930","full_name":"azu/babel-plugin-jsdoc-to-assert","owner":"azu","description":"Runtime type checking for JSDoc","archived":false,"fork":false,"pushed_at":"2019-11-06T19:14:21.000Z","size":111,"stargazers_count":55,"open_issues_count":5,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T13:01:46.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/azu/jsdoc-to-assert","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/azu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"azu"}},"created_at":"2016-03-21T06:24:40.000Z","updated_at":"2024-07-16T15:29:54.000Z","dependencies_parsed_at":"2023-07-25T21:15:44.477Z","dependency_job_id":null,"html_url":"https://github.com/azu/babel-plugin-jsdoc-to-assert","commit_stats":{"total_commits":67,"total_committers":3,"mean_commits":"22.333333333333332","dds":"0.11940298507462688","last_synced_commit":"1b001e993a6086ec01305fc310283ddf3273c92b"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fbabel-plugin-jsdoc-to-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fbabel-plugin-jsdoc-to-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fbabel-plugin-jsdoc-to-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/azu%2Fbabel-plugin-jsdoc-to-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/azu","download_url":"https://codeload.github.com/azu/babel-plugin-jsdoc-to-assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248578857,"owners_count":21127713,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T04:00:38.646Z","updated_at":"2025-04-15T01:05:55.470Z","avatar_url":"https://github.com/azu.png","language":"JavaScript","funding_links":["https://github.com/sponsors/azu"],"categories":["Plugins"],"sub_categories":["Types"],"readme":"# babel-plugin-jsdoc-to-assert [![Build Status](https://travis-ci.org/azu/babel-plugin-jsdoc-to-assert.svg?branch=master)](https://travis-ci.org/azu/babel-plugin-jsdoc-to-assert)\n\nBabel plugin for [jsdoc-to-assert](https://github.com/azu/jsdoc-to-assert \"jsdoc-to-assert\").\n\nPreset version: [babel-preset-jsdoc-to-assert: Babel preset for jsdoc-to-assert](https://github.com/azu/babel-preset-jsdoc-to-assert)\n\nThis plugin JSDoc(`@param` and `@type`) to assertion method for runtime testing.\n\n## `@param`\n\n```js\n/**\n * @param {number} param - this is a param.\n * @param {string} b - this is a param.\n * @param {string[]} [c] - this is a param.\n */\nfunction myFunc(param, b, c) {\n}\n```\n\nto\n\n```js\n/**\n * @param {number} param - this is a param.\n * @param {string} b - this is a param.\n * @param {string[]} [c] - this is a param.\n */\nfunction myFunc(param, b, c) {\n  console.assert(typeof param === 'number');\n  console.assert(typeof b === 'string');\n}\n```\n\n### `@type`\n\n```js\n/**\n * @type {string}\n */\nconst value = \"s\";\n```\n\nto \n\n```js\n/**\n * @type {string}\n */\nconst value = \"s\";\nconsole.assert(typeof value === \"string\");\n```\n\n## Installation\n\n    npm install babel-plugin-jsdoc-to-assert\n\n## Usage\n\nVia `.babelrc`\n\n```json\n{\n  \"plugins\": [\n    \"jsdoc-to-assert\"\n  ]\n}\n```\n\nIn development only:\n\n```json\n{\n  \"presets\": [\n    \"es2015\"\n  ],\n  \"env\": {\n    \"development\": {\n      \"plugins\": [\n        \"jsdoc-to-assert\"\n      ]\n    }\n  }\n}\n```\n\nIf build files with `NODE_ENV=production`, don't convert JSDoc to assert.\n\n    \"build\": \"NODE_ENV=production babel src --out-dir lib --source-maps\",\n\n## Options\n\n- `checkAtParam`: boolean\n    - Default: `true`\n    - Check typing of `@param`\n- `checkAtType`: boolean\n    - Default: `false`\n    - Check typing of `@type` \n\n## FAQ\n\nQ. Try to use this, but throw parsing error:\n\n```\nERROR in ./src/js/framework/Context.js\nModule build failed: SyntaxError: Unterminated string constant (3:16)\n    at Parser.pp.raise (/Users/azu/.ghq/github.com/azu/svg-feeling/node_modules/babylon/index.js:1378:13)\n    at Parser.readString (/Users/azu/.ghq/github.com/azu/svg-feeling/node_modules/babylon/index.js:5402:49)\n    at Parser.getTokenFromCode (/Users/azu/.ghq/github.com/azu/svg-feeling/node_modules/babylon/index.js:52\n    ....\n @ ./src/index.js 24:15-48\n```\n\nA. It seem to be a bug of `babel-plugin-jsdoc-to-assert`.\nPlease file issue with your code :bow:\n\nQ. Why `checkAtType` is default disable?\n\nIt is a problem of babel transform order.\n\nES2015 -\u003e jsdoc-to-assert cause following problem.\n\n```\nAssertionError: Invalid JSDoc: typeof _this === \"string\"\n+ expected - actual\n```\n\n## Tests\n\n    npm test\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Fbabel-plugin-jsdoc-to-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fazu%2Fbabel-plugin-jsdoc-to-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fazu%2Fbabel-plugin-jsdoc-to-assert/lists"}