{"_id":"eslint-plugin-no-floating-promise","_rev":"4-072c7a2c69f7509627be952168e56556","name":"eslint-plugin-no-floating-promise","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"eslint-plugin-no-floating-promise","version":"1.0.0","description":"Detects missing await on async function calls","keywords":["eslint","eslintplugin","eslint-plugin","Flow","async"],"author":{"name":"Sebastien Guillemot"},"main":"lib/index.js","scripts":{"test":"mocha tests --recursive"},"dependencies":{"requireindex":"1.2.0"},"devDependencies":{"eslint":"~7.6.0","mocha":"~8.1.1"},"engines":{"node":">=0.10.0"},"license":"MIT","gitHead":"474c28c28b8a55c256006ab9f80b274326bc090f","_id":"eslint-plugin-no-floating-promise@1.0.0","_nodeVersion":"12.11.1","_npmVersion":"6.14.3","dist":{"integrity":"sha512-OcbohT0qzYpe0Fg87I8zvoObnF0m2SRxvGH+u9IxlqVCQBbDLNB/plo4vUSLrb5GKi8EWK6n2ykTGwhkSFw3mg==","shasum":"0245996a11649d837ca342817623cf3c01056a25","tarball":"https://registry.npmjs.org/eslint-plugin-no-floating-promise/-/eslint-plugin-no-floating-promise-1.0.0.tgz","fileCount":11,"unpackedSize":150002,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMRdqCRA9TVsSAnZWagAAVCMP/1L2MyEyRfewyl+ZYck5\ngwYD7/R7qQg5Mw0QHXPA290pjtivoWcA+mTvIiShkpbBTf3gGTYDj65qcxNi\n91KjIHIXbizo5PbqECb/uoxLpnlozho9Tg0mqEhE3Q0dmbjS9EAJEt6TQQI+\n1NcE/DQwyuiVor6iat4jQh50emNEipieyZ6rAykSBI5wezJ6/S4VSkpjOG5p\nGLmDVKgKMyVaTVXMuGyd0WH7l6EtXPNLtHnw1nWeBEfYdvyY+OjmDJ3fCpOl\noVA4U+6eCymyDFdxGScpYkWeI4CLXbNZhIbFy9ZfYKaEJdIdhxyrTpXblxdw\nn8cHSwTln3NcQDrE8lbCX536VVnEGcO23I7Y7ydWoUnzu7feUELpxhEuR8Bh\n3I9NTfpXFKa9cRrs+PsoiDf+rz6iXc/MT+DEJmZy6jpavgeGeOKPvRvf+jKv\nCzJbfCTb2T4KATAmtuKYzs/8VCJzbgclrxUhIfdt0kcijPheK82ODWLjcSki\nr7pCJPBUAOS64vvYjFGWlG/JIebFh8RN+7ke9o+6SOmECq4TpFx+JGH4LILU\nmKnkOkwlNkD5rsPUTkNyiATAMawSLHdzVfAH/1ms6HjOYMY/8HQfdd+hUAYQ\naVgRp6fIoXHxioeY7L1zaTex3kqNpnewiUktWHw4dtw5mf6sGd0/C3EIbSDO\ngyhD\r\n=1BRV\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDrbxRmJOjac2WdRPw0x8e2jOrKLXkLNxhTROgTPJzq3QIhAM+0i9IZSSe9qsziY8OWn7fkCMmsP/V0yeTej6BGMC43"}]},"maintainers":[{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"}],"_npmUser":{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-no-floating-promise_1.0.0_1597052778085_0.27954796098395973"},"_hasShrinkwrap":false},"1.0.1":{"name":"eslint-plugin-no-floating-promise","version":"1.0.1","description":"Detects missing await on async function calls","keywords":["eslint","eslintplugin","eslint-plugin","Flow","async"],"author":{"name":"Sebastien Guillemot"},"main":"lib/index.js","scripts":{"test":"mocha tests --recursive"},"dependencies":{"requireindex":"1.2.0"},"devDependencies":{"eslint":"~7.6.0","mocha":"~8.1.1"},"engines":{"node":">=0.10.0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise.git"},"gitHead":"f3eb6aaf1c8e3da262118244a006674c450601b9","bugs":{"url":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise/issues"},"homepage":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise#readme","_id":"eslint-plugin-no-floating-promise@1.0.1","_nodeVersion":"12.11.1","_npmVersion":"6.14.3","dist":{"integrity":"sha512-5MJGIme12iF20d7RnCK+IUOuglSW7lHz0PidXtkTPFe3ANtu/tdLvwQFq9Q6x+oKDWd5Mm/g+fRNydHz/v68sw==","shasum":"09be0d5dce68c3cc3dd29b87af68b952c0aede16","tarball":"https://registry.npmjs.org/eslint-plugin-no-floating-promise/-/eslint-plugin-no-floating-promise-1.0.1.tgz","fileCount":4,"unpackedSize":11724,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMRiOCRA9TVsSAnZWagAAmG0P/Re2CwFCezvkQplk9o1O\nxiXU12xx3spJd4dEnxkHwAedmv/45/Ad6j1XrhOAE4xJBBRTribvUHfx+JXt\ngVhDBoOyxrqJfrVB5PKyPrGHVfLr2XKQPKdIInoIYba1i/f3HI/neti/bgCD\n5ueTcxRrD+i4gbTZO1WHj5TH+QYQHK2Yq0o4fI1VC01fITsNSbgStXgZWg1h\nI0Qc7yHNqpCwl3gc3qr6y28+cuOkX0bdNFgCAraoVE9C7p1ZDvqlC5u9zjZL\nP2I7J1VWpkWlr5mwawC3BwqEuvDMX2IHY5zhB2WDsmvMY5PkbsiSp0N6Nh4Z\nYTorRiIppMVHuLhXE4lnP0GfmtWW/YZKQpzd3h2EjyPNzI4qqg08EeOZo1Nq\n+UlvoGkEucga7n/O2GRelCmyNk26ASW29bYZpjglTln2UQ7NfO6pfyHSCtnZ\nr6j/qnxPIAb2O0MpA6/NyfSHOJgQJ3K+yx6OqbDI92rLrXb/qsF1CQupdLDQ\n+A1RyGu72MATmchEi0i0uver0W0NMyyNQEcIJ182NZVWNFEcUcLymb/81wYC\nwQlE5LcFJWbkm5aZZG7ZfbpSdvenS6iTb8TrZlYo8+UL2zDYLyZQGX99S09k\naZeXjA2NG5fqdA3vnmXqdB9xlOPCDeu3jVkAFE8AFF6rpInpw0Plc0SQLkOA\nhKJm\r\n=mQSj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEGwDTHFa9ySOArggM6p4WXh9iJFrIqy9ky1zrR+o8zUAiB6bqpN2kbzrLyGSUaOBHYTPqklvSfCVsXyX2Y2S52ebw=="}]},"maintainers":[{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"}],"_npmUser":{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-no-floating-promise_1.0.1_1597053069643_0.2765212266091368"},"_hasShrinkwrap":false},"1.0.2":{"name":"eslint-plugin-no-floating-promise","version":"1.0.2","description":"Detects missing await on async function calls","keywords":["eslint","eslintplugin","eslint-plugin","Flow","async"],"author":{"name":"Sebastien Guillemot"},"main":"lib/index.js","scripts":{"test":"mocha tests --recursive"},"dependencies":{"requireindex":"1.2.0"},"devDependencies":{"eslint":"~7.6.0","mocha":"~8.1.1"},"engines":{"node":">=0.10.0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise.git"},"gitHead":"f0465a83daece977933dfcf636ddf88e141813e1","bugs":{"url":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise/issues"},"homepage":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise#readme","_id":"eslint-plugin-no-floating-promise@1.0.2","_nodeVersion":"12.11.1","_npmVersion":"6.14.3","dist":{"integrity":"sha512-ccbyIlvDuKJOrwypw9NWn6CIxTK+/CYARhsqMyP6cXYgIFcNFs01sGXOqq8XzOJFw02Umkj6hCnffaV6nSiqyw==","shasum":"5176e89cc84682a2ee7e9a523019552a751de82c","tarball":"https://registry.npmjs.org/eslint-plugin-no-floating-promise/-/eslint-plugin-no-floating-promise-1.0.2.tgz","fileCount":4,"unpackedSize":11742,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuIdeCRA9TVsSAnZWagAAQkcP/Rc1fP0LXsJG3eoGy8jF\nV6VeFXTO7mBZ4aYfQo12GdvbVVNCZ3+xNzcfi9mzyFYhErfxre0Ftb0Gr1Ai\nraD3zSbg4s3eewU9BIPCoWhgtZR2TJJ4qvZAYBJORJj+bTeKsdkhxutcwntr\nEdOV7m66NLwpXRrEzrxDxBXSSa64Q8IsUtwlIE6S0C6j61Zs2TIfFNngA6QI\nr0jZ7k/EBYbsKSxTEvoElkq6Yj81fMR5vJrQtX+nC8dl7NPUgLlU2D37juA8\npE0pzMYaK8wNHWhLJXYWKzY2zH9wcqliQDptghu46hVlGDD4qARco4kK37ep\nlUTkyfbxYvYOD4CMOpDQ05JZhtWuBRMVwfP+ygZzcpbl1SWMazU9o+5prE5B\nXzKTUQ1lKj/R78zWA2UeuN3dZqQu/RPIS+uXlYHo4C1g3amGDGDD5+cPKqNE\nQugtbgLayExZoV57MvR2mYApci6Gq9zdVaLIf6nu9FMAXBum/AbfcI96mwjO\nQHQ2C5grfqLuegf3gDe+cPw+V7GHnvlutA1M/qDGpte35VMrcXUtDtQNCGgG\nicTLP5vBMxdVGlkGtn2ZtiK/lQNoaZGEntS0kJnVvxbuJwkQ3ENzZPBcaum0\nivtCr/4xPcRGSKRVqt8XvWi4Nx8KKhbniGQpZuc6+KUZkPUe77Nt58cRGv3B\nfIE3\r\n=saXJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAw0WNtVOcpYjVPlNErCv+qkCc/LncOuFKaYMmmB0ZhIAiAbmnt1BOUoIIhAeRvormDAhXpOyOlM5bfBqOrhBYSOMg=="}]},"_npmUser":{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"},"directories":{},"maintainers":[{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-no-floating-promise_1.0.2_1605928798388_0.548497894937765"},"_hasShrinkwrap":false},"2.0.0":{"name":"eslint-plugin-no-floating-promise","version":"2.0.0","description":"Detects missing await on async function calls","keywords":["eslint","eslintplugin","eslint-plugin","Flow","async"],"author":{"name":"Sebastien Guillemot"},"main":"lib/index.js","scripts":{"test":"mocha tests --recursive"},"dependencies":{"requireindex":"1.2.0"},"devDependencies":{"eslint":"~9.0.0","mocha":"~8.1.1"},"engines":{"node":">=0.10.0"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise.git"},"_id":"eslint-plugin-no-floating-promise@2.0.0","gitHead":"c74354034f9e722fa36b1427afe6b5840ede2e22","bugs":{"url":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise/issues"},"homepage":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise#readme","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-XVAk+a1Qq3fsfY8tLT64Ky4sdJjZSjx0BsDxjdWbyceU0yWwg1ZKHiWgaOZ0hDYNzrl3qx5MEGrRlTceGzd0ow==","shasum":"454a651f47a61be6b257fe5e67cfc2b295cf469f","tarball":"https://registry.npmjs.org/eslint-plugin-no-floating-promise/-/eslint-plugin-no-floating-promise-2.0.0.tgz","fileCount":4,"unpackedSize":12115,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCb2ZVrMWSKTZIEY61e8FNVhFOXW4MQYHOA8SwIy4OKdwIgZALBUm38Dpi2juBB2i4l7SOHBKf9fTV/KV9UtafFYDQ="}]},"_npmUser":{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"},"directories":{},"maintainers":[{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-plugin-no-floating-promise_2.0.0_1713460150955_0.7234142326229507"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-10T09:46:18.085Z","1.0.0":"2020-08-10T09:46:18.203Z","modified":"2024-04-18T17:09:11.300Z","1.0.1":"2020-08-10T09:51:09.767Z","1.0.2":"2020-11-21T03:19:58.526Z","2.0.0":"2024-04-18T17:09:11.132Z"},"maintainers":[{"name":"sebastiengllmt","email":"sebastiengllmt@gmail.com"}],"description":"Detects missing await on async function calls","keywords":["eslint","eslintplugin","eslint-plugin","Flow","async"],"author":{"name":"Sebastien Guillemot"},"license":"MIT","readme":"# eslint-plugin-no-floating-promise\n\nDetects missing await on async function calls\n\n**STOP**: Are you a Flow or a Typescript user?\nPrefer these:\n- Flow: [link](https://github.com/facebook/flow/pull/8482)\n- Typescript: [link](https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md)\n\n\n## Installation\n\nYou'll first need to install [ESLint](http://eslint.org):\n\n```\n$ npm i eslint --save-dev\n```\n\nNext, install `eslint-plugin-no-floating-promise`:\n\n```\n$ npm install eslint-plugin-no-floating-promise --save-dev\n```\n\n**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-no-floating-promise` globally.\n\n## Usage\n\nAdd `no-floating-promise` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:\n\n```json\n{\n    \"plugins\": [\n        \"no-floating-promise\"\n    ]\n}\n```\n\n\nThen configure the rules you want to use under the rules section.\n\n```json\n{\n    \"rules\": {\n        \"no-floating-promise/no-floating-promise\": 2\n    }\n}\n```\n\nIf you're using flat config (`eslint.config.js`), which is default configuration format for eslint since `v.9.0.0`:\n\n```js\nconst noFloatingPromise = require(\"eslint-plugin-no-floating-promise\");\n\nmodule.exports = [\n  {\n    plugins: {\n      \"no-floating-promise\": noFloatingPromise,\n    },\n    rules: {\n      \"no-floating-promise/no-floating-promise\": 2\n    }\n  }\n];\n```\n\n# Rule definition\n\n_The `--fix` option on the command line automatically fixes problems reported by this rule._\n\nPromises that are never awaited can cause unexpected behavior because they may be scheduled to execute at an unexpected time.\n\nIt's easy to accidentally make this mistake. For example, suppose we have the code\n\n```js\nfunction writeToDb() {\n  // synchronously write to DB\n}\nwriteToDb();\n```\n\nbut the code gets refactored so that writing to the database is asynchronous.\n\n```js\nasync function writeToDb() {\n  // asynchronously write to DB\n}\nwriteToDb(); // <- note we have no await here but probably the user intended to await on this!\n```\n\n## Rule Details\n\nThis rule will fire for any call to an `async` function that both\n\n* not used (not assigned to a variable, not the return type of a function, etc.)\n* not awaited on\n\nExamples of **incorrect** code for this rule:\n\n```js\n/*eslint no-floating-promise: \"error\"*/\n\nasync function foo() {}\nfoo();\n\n(async () => 5)();\n\n// note: function is not async but a Promise return type is specified\nfunction foo(): Promise<void> { return Promise.resolve(); };\nfoo();\n```\n\nExamples of **correct** code for this rule:\n\n```js\n/*eslint no-floating-promise: \"error\"*/\n\nasync function foo() {}\nawait foo();\n\nawait (async () => 5)();\n\n// note: function is not async but a Promise return type is specified\nfunction foo(): Promise<void> { return Promise.resolve(); };\nawait foo();\n\n// note: promise is not awaited, but it is chained with a 'then'\nasync function foo() {}\nfoo().then(() => {});\n```\n\nYou may catch additional errors by combining this rule with `no-unused-expression`.\n\nFor example the following will not be considered an error by this plugin, but `no-unused-expression` will complain that `fooResult` is never used.\n\n```js\nasync function foo() {}\nconst fooResult = foo();\n```\n\n## When Not To Use It\n\nIf you often make use of asynchronous functions were you explicitly do not want to await on them.\n\n# Notable design decisions\n\n## Promises returned by non-async functions\n\nIt's possible for a function to return a promise and not be async (as seen in test cases for this rule). My rule can leverage type annotations to detect these cases but if no type annotation  is present, then no error is reported. We could modify this rule to traverse into the AST to see if the return is a promise or not but this sounds more expensive and would still not catch all cases so I didn't include this logic.\n\nAdditionally, TypeAnnotations are only generated for explicit Flow types so this rule can't take advantage of Flow inference. You could argue this rule would be more effective if implemented directly in Flow but this rule can still catch cases for vanilla Javascript so it didn't feel right to make Flow a dependency for this kind of linting.\n\n## Scope of the rule\n\nCurrently using `then`  or `catch` silences this rule\n```js\nasync function foo() {}\nfoo().then(() => {});\n```\n\nYou could argue this is desired since it avoids false-positive where developers explicitly do not want to await. I'm open to feedback about whether or not people want this behavior.\n\n## Missing `await` in non-async context\n\nRight now my rule reports an error in the following case\n```js\nasync function foo() {}\nfunction bar() {\n    foo();\n}\n```\n\nHowever, adding an `await` here is not  possible because `bar` is not an async function. In fact, my auto-fix rule would add an `await` in front of `foo` which would result in a compiler error.\n\nHowever, likely this actually is an error and the user actually should make `bar` an async function. However, I am open to disabling this rule in this context if that's what people want.\n\n# Limitations\n\n1) It cannot make use of Flow inference (you need to explicitly specify types)\n2) It does not work across file boundaries (if import a function from a different file, you don't have any information)\n3) It doesn't work on member function calls (`foo.bar()` will not detect  an error  even if  `bar` is an async function)\n","readmeFilename":"README.md","homepage":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise#readme","repository":{"type":"git","url":"git+https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise.git"},"bugs":{"url":"https://github.com/SebastienGllmt/eslint-plugin-no-floating-promise/issues"}}