{"id":15692511,"url":"https://github.com/amilajack/babel-plugin-fail-explicit","last_synced_at":"2025-06-18T13:41:53.150Z","repository":{"id":45869480,"uuid":"85452588","full_name":"amilajack/babel-plugin-fail-explicit","owner":"amilajack","description":"A babel plugin that prevents coercion and silent failure in JavaScript","archived":false,"fork":false,"pushed_at":"2022-03-26T14:13:01.000Z","size":872,"stargazers_count":7,"open_issues_count":17,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-14T17:44:44.078Z","etag":null,"topics":["babel","coercion","explicit","fail","failure","plugin","safe","silent"],"latest_commit_sha":null,"homepage":"","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/amilajack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"amilajack","patreon":"amilajack","custom":["https://paypal.me/amilajack","https://venmo.com/amilajack"]}},"created_at":"2017-03-19T05:12:05.000Z","updated_at":"2023-08-10T01:16:34.000Z","dependencies_parsed_at":"2022-09-05T05:20:40.111Z","dependency_job_id":null,"html_url":"https://github.com/amilajack/babel-plugin-fail-explicit","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/amilajack/babel-plugin-fail-explicit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amilajack%2Fbabel-plugin-fail-explicit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amilajack%2Fbabel-plugin-fail-explicit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amilajack%2Fbabel-plugin-fail-explicit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amilajack%2Fbabel-plugin-fail-explicit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amilajack","download_url":"https://codeload.github.com/amilajack/babel-plugin-fail-explicit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amilajack%2Fbabel-plugin-fail-explicit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260563328,"owners_count":23028536,"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":["babel","coercion","explicit","fail","failure","plugin","safe","silent"],"created_at":"2024-10-03T18:34:31.517Z","updated_at":"2025-06-18T13:41:48.113Z","avatar_url":"https://github.com/amilajack.png","language":"JavaScript","funding_links":["https://github.com/sponsors/amilajack","https://patreon.com/amilajack","https://paypal.me/amilajack","https://venmo.com/amilajack"],"categories":[],"sub_categories":[],"readme":"babel-plugin-fail-explicit\n==========================\n[![Build Status](https://travis-ci.org/amilajack/babel-plugin-fail-explicit.svg?branch=master\u0026maxAge=2592)](https://travis-ci.org/amilajack/babel-plugin-fail-explicit)\n[![NPM version](https://badge.fury.io/js/babel-plugin-fail-explicit.svg?maxAge=2592)](http://badge.fury.io/js/babel-plugin-fail-explicit)\n[![Dependency Status](https://img.shields.io/david/amilajack/babel-plugin-fail-explicit.svg?maxAge=2592)](https://david-dm.org/amilajack/babel-plugin-fail-explicit)\n[![npm](https://img.shields.io/npm/dm/babel-plugin-fail-explicit.svg?maxAge=2592)](https://npm-stat.com/charts.html?package=babel-plugin-fail-explicit)\n\n**A babel plugin that prevents coercion and silent failure in JavaScript**\n\n![demo](https://raw.githubusercontent.com/amilajack/babel-plugin-fail-explicit-demo/7ed9a29ec61d505f2b3ce6be18145c74eb3bc5f5/demo.gif)\n\n## Roadmap\n- [x] Fail on unsafe coercion\n- [x] Fail on unsafe property access\n- [x] Do not fail inside conditional expressions or default statements (`||`), on by default\n- [ ] Allow unsafe access in if statement by default\n- [ ] Allow for configuration of strictness\n\n## Installation\n```bash\nnpm install --save-dev babel-plugin-fail-explicit\n```\n\n## Setup\n```json\n// .babelrc\n{\n  \"plugins\": [\n    \"fail-explicit\"\n  ]\n}\n```\n\n### Demo:\nTo experiment with `babel-plugin-fail-explicit`, see [this demo repo](https://github.com/amilajack/babel-plugin-fail-explicit-demo)\n\n### Examples\n```js\n// ------------------------------------------------\n// Coercion safeguard\n// ------------------------------------------------\n[] + {}\n// TypeError: 'Unexpected coercion of type \"Array\" and\n// type \"Object\" using \"+\" operator'\n\nNaN + undefined\n// TypeError: Unexpected coercion of type \"NaN\" and type\n// \"undefined\" using \"+\" operator\n\n1 + 'some'\n// '1some'\n\n\n// ------------------------------------------------\n// Safe Comparison\n// ------------------------------------------------\nnew String('12') \u003e 12\n// TypeError: Unexpected comparison of type \"String\" and type\n// \"number\" using \"\u003e\" operator\n\nnull \u003e undefined\n// TypeError: Unexpected comparison of type \"null\" and type\n// \"undefined\" using \"\u003e\" operator\n\n\n// ------------------------------------------------\n// Usage for better undefined propagation errors\n// ------------------------------------------------\nconst obj = {\n  foo: {\n    bar: {}\n  }\n}\n\nobj.foo.bar.baz;\n// TypeError: Property \"baz\" does not exist in \"Object.foo.bar\"\n\n\n// ------------------------------------------------\n// Usage as out of bounds check\n// ------------------------------------------------\nconst some = new Array(3)\nsome[10]\n// TypeError: '\"Array[10]\" is out of bounds'\n\nconst bar = []\nsome[100]\n// TypeError: '\"Array[100]\" is out of bounds'\n\n// TypeError: '\"woo[1]\" is out of bounds'\nconst obj = {\n  woo: ['']\n}\n\nobj.woo[1]\n// TypeError: '\"woo[1]\" is out of bounds'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Familajack%2Fbabel-plugin-fail-explicit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Familajack%2Fbabel-plugin-fail-explicit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Familajack%2Fbabel-plugin-fail-explicit/lists"}