diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cd79f9..43ff270 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,51 @@ +# 0.11.0 + +![Release Date: 2021-04-14](https://img.shields.io/static/v1.svg?style=flat-square&label=Release%20Date&message=2021-04-14&colorA=4c566a&colorB=88c0d0) [![Project Board](https://img.shields.io/static/v1.svg?style=flat-square&label=Project%20Board&message=0.11.0&logo=github&logoColor=eceff4&colorA=4c566a&colorB=88c0d0)](https://github.com/arcticicestudio/styleguide-javascript/projects/9) [![Milestone](https://img.shields.io/static/v1.svg?style=flat-square&label=Milestone&message=0.11.0&logo=github&logoColor=eceff4&colorA=4c566a&colorB=88c0d0)](https://github.com/arcticicestudio/styleguide-javascript/milestone/6) + +⇅ [Show all commits][gh-compare-tag-v0.10.0_v0.11.0] + +## Improvements + +
+Allow void operator as a statement for React Hooks — #55 ⇄ #56 (⊶ af9c38b8) + +↠ To run `async` code in a React [`useEffect` Hook][react-docs-hooks-ref] the [official React Hook FAQ section about how to fetch data][react-docs-hooks-faq#fetch_data] recommends and [shows in a demo][csb-jvvkoo8pq3] how to define a scoped fat arrow function and run it immediately. Unfortunately this collided with the [`@typescript/no-floating-promises`][gh-typescript-eslint/typescript-eslint-blob-rules-no-floating-promises] rule because the returned `Promise` of the called function must not be handled anymore. + +```tsx +useEffect(() => { + const init = async () => { + try { + const data = await fetchData(); + setInitialized(isInit); + if (data) initStores(data); + } catch (err) { + handleError(err); + } + }; + // This will trigger the "@typescript/no-floating-promises" rule because the returned "Promise" is not handled. + init(); +}, [fetchData, handleError, initStores, setInitialized]); +``` + +Explicitly disabling the rule for these specific code lines would have been an option, but it is recommended to [use the `void` operator instead][mdn-js-ops-void]. + +```tsx +// ... +// This will trigger the "no-void" rule because the "void" operator is currently not allowed as a statement. +void init(); +// ... +``` + +However, the [`no-void`][eslint-docs-rules-no-void] rule did not allow the `void` operator to be used as statement which resulted in this rule to also throw an error. +To resolve both problems, the [`allowAsStatement` option][eslint-docs-rules-no-void#allowasstatement] of the `no-void` rule has been enabled. + +Also see [typescript-eslint/typescript-eslint#1184][gh-typescript-eslint/typescript-eslint#1184] where this solution is also recommended by one of the `@typescript-eslint` package maintainers. + +
+ # 0.10.0 ![Release Date: 2021-04-08](https://img.shields.io/static/v1.svg?style=flat-square&label=Release%20Date&message=2021-04-08&colorA=4c566a&colorB=88c0d0) [![Project Board](https://img.shields.io/static/v1.svg?style=flat-square&label=Project%20Board&message=0.10.0&logo=github&logoColor=eceff4&colorA=4c566a&colorB=88c0d0)](https://github.com/arcticicestudio/styleguide-javascript/projects/8) [![Milestone](https://img.shields.io/static/v1.svg?style=flat-square&label=Milestone&message=0.10.0&logo=github&logoColor=eceff4&colorA=4c566a&colorB=88c0d0)](https://github.com/arcticicestudio/styleguide-javascript/milestone/5) @@ -1298,3 +1343,15 @@ otherwise Markdown elements are not parsed and rendered! [gh#10]: https://github.com/arcticicestudio/styleguide-markdown/issues/10 [gh#28]: https://github.com/arcticicestudio/styleguide-markdown/issues/28 [typescript-docs-triple_slash_directives]: https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html + + + +[csb-jvvkoo8pq3]: https://codesandbox.io/s/jvvkoo8pq3 +[eslint-docs-rules-no-void]: https://eslint.org/docs/rules/no-void +[eslint-docs-rules-no-void#allowasstatement]: https://eslint.org/docs/rules/no-void#allowasstatement +[gh-compare-tag-v0.10.0_v0.11.0]: https://github.com/arcticicestudio/styleguide-javascript/compare/v0.10.0...v0.11.0 +[gh-typescript-eslint/typescript-eslint-blob-rules-no-floating-promises]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-floating-promises.md +[gh-typescript-eslint/typescript-eslint#1184]: https://github.com/typescript-eslint/typescript-eslint/issues/1184 +[mdn-js-ops-void]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void +[react-docs-hooks-faq#fetch_data]: https://reactjs.org/docs/hooks-faq.html#how-can-i-do-data-fetching-with-hooks +[react-docs-hooks-ref]: https://reactjs.org/docs/hooks-reference.html#useeffect diff --git a/package.json b/package.json index 12824c5..339b563 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "styleguide-javascript", - "version": "0.10.0", + "version": "0.11.0", "description": "The Arctic Ice Studio JavaScript code style", "author": "Arctic Ice Studio (https://www.arcticicestudio.com)", "contributors": [ diff --git a/packages/@arcticicestudio/eslint-config-base/index.js b/packages/@arcticicestudio/eslint-config-base/index.js index c541ba4..11f321e 100644 --- a/packages/@arcticicestudio/eslint-config-base/index.js +++ b/packages/@arcticicestudio/eslint-config-base/index.js @@ -8,7 +8,7 @@ * Arctic Ice Studio JavaScript style guide rules as an extensible remark-lint rule preset. * Imports all rule definitions and sets the default parser options. * - * @version 0.10.0 + * @version 0.11.0 * @license MIT * @author Arctic Ice Studio * @author Sven Greb diff --git a/packages/@arcticicestudio/eslint-config-base/package.json b/packages/@arcticicestudio/eslint-config-base/package.json index 354de68..ee38e3c 100644 --- a/packages/@arcticicestudio/eslint-config-base/package.json +++ b/packages/@arcticicestudio/eslint-config-base/package.json @@ -1,6 +1,6 @@ { "name": "@arcticicestudio/eslint-config-base", - "version": "0.10.0", + "version": "0.11.0", "description": "The Arctic Ice Studio JavaScript Style Guide base rules as an extensible shared ESLint configuration", "author": "Arctic Ice Studio (https://www.arcticicestudio.com)", "contributors": [ diff --git a/packages/@arcticicestudio/eslint-config-typescript/index.js b/packages/@arcticicestudio/eslint-config-typescript/index.js index e726ab2..f9993d4 100644 --- a/packages/@arcticicestudio/eslint-config-typescript/index.js +++ b/packages/@arcticicestudio/eslint-config-typescript/index.js @@ -8,7 +8,7 @@ * Arctic Ice Studio JavaScript style guide rules as an extensible remark-lint rule preset. * Imports all rule definitions and sets the default parser options. * - * @version 0.10.0 + * @version 0.11.0 * @license MIT * @author Arctic Ice Studio * @author Sven Greb diff --git a/packages/@arcticicestudio/eslint-config-typescript/package.json b/packages/@arcticicestudio/eslint-config-typescript/package.json index d7f883c..939bfeb 100644 --- a/packages/@arcticicestudio/eslint-config-typescript/package.json +++ b/packages/@arcticicestudio/eslint-config-typescript/package.json @@ -1,6 +1,6 @@ { "name": "@arcticicestudio/eslint-config-typescript", - "version": "0.10.0", + "version": "0.11.0", "description": "The Arctic Ice Studio JavaScript Style Guide rules with TypeScript support as an extensible shared ESLint configuration", "author": "Arctic Ice Studio (https://www.arcticicestudio.com)", "contributors": [ diff --git a/packages/@arcticicestudio/eslint-config/index.js b/packages/@arcticicestudio/eslint-config/index.js index a87f684..417a7c2 100644 --- a/packages/@arcticicestudio/eslint-config/index.js +++ b/packages/@arcticicestudio/eslint-config/index.js @@ -8,7 +8,7 @@ * Arctic Ice Studio JavaScript style guide rules as an extensible remark-lint rule preset. * Imports all rule definitions and sets the default parser options. * - * @version 0.10.0 + * @version 0.11.0 * @license MIT * @author Arctic Ice Studio * @author Sven Greb diff --git a/packages/@arcticicestudio/eslint-config/package.json b/packages/@arcticicestudio/eslint-config/package.json index 3422040..cfe7717 100644 --- a/packages/@arcticicestudio/eslint-config/package.json +++ b/packages/@arcticicestudio/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@arcticicestudio/eslint-config", - "version": "0.10.0", + "version": "0.11.0", "description": "The Arctic Ice Studio JavaScript Style Guide rules with React support as an extensible shared ESLint configuration", "author": "Arctic Ice Studio (https://www.arcticicestudio.com)", "contributors": [