@frontity/error
Advanced tools
Comparing version 0.1.1 to 0.1.2
# @frontity/error | ||
## 0.1.2 | ||
### Patch Changes | ||
- [`5f329dab`](https://github.com/frontity/frontity/commit/5f329dabe9d67d0b3664938865491674ef798433) [#655](https://github.com/frontity/frontity/pull/655) Thanks [@mburridge](https://github.com/mburridge)! - Fix broken links in README files. | ||
## 0.1.1 | ||
@@ -4,0 +10,0 @@ |
43
index.ts
const suffix = "\nVisit https://community.frontity.org for help! 🙂\n"; | ||
interface FrontityError { | ||
( | ||
message: string, | ||
options?: { | ||
throw?: boolean; | ||
} | ||
): void; | ||
/** | ||
* The options for the {@link error} function. | ||
*/ | ||
interface ErrorOptions { | ||
/** | ||
* Indicate if the function should throw or just log the error in the console | ||
* using `console.error`. | ||
* | ||
* @example | ||
* ```js | ||
* error("Something wrong happaned.", { throw: false }); | ||
* ``` | ||
* | ||
* @defaultValue true | ||
*/ | ||
throw?: boolean; | ||
} | ||
export const error: FrontityError = (message, options = {}) => { | ||
/** | ||
* Throws an error. In development, it adds a message that encourage users to | ||
* visit the Frontity community if they need help. | ||
* | ||
* @example error("Something wrong happened.") | ||
* | ||
* @param message - The message that describes the error. | ||
* @param options - The options, described in {@link ErrorOptions}. | ||
*/ | ||
export const error = (message: string, options: ErrorOptions = {}): void => { | ||
const doThrow = typeof options.throw !== "undefined" ? options.throw : true; | ||
@@ -23,2 +41,11 @@ if (process.env.NODE_ENV !== "production") { | ||
/** | ||
* Logs a warning in the console, adding a message that indicates users to | ||
* visit the Frontity community if they need help. It's intended to be used | ||
* by Frontity packages. | ||
* | ||
* @example warn("You should do/change something.") | ||
* | ||
* @param message - The message that describes the warning. | ||
*/ | ||
export const warn = (message: string) => { | ||
@@ -25,0 +52,0 @@ if (process.env.NODE_ENV !== "production") { |
{ | ||
"name": "@frontity/error", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Frontity errors and warnings", | ||
@@ -18,2 +18,3 @@ "keywords": [ | ||
"scripts": { | ||
"preinstall": "node -e \"console.error('Please run \\'npm install\\' in the root.\\n'); process.exit(1);\"", | ||
"test:ci": "../../node_modules/.bin/jest --ci --coverage", | ||
@@ -20,0 +21,0 @@ "test": "../../node_modules/.bin/jest --watch", |
@@ -15,4 +15,4 @@ # `@frontity/error` | ||
- [Open Source Community](#open-source-community) | ||
* [Channels](#channels) | ||
* [Get involved](#get-involved) | ||
- [Channels](#channels) | ||
- [Get involved](#get-involved) | ||
@@ -35,3 +35,2 @@ <!-- tocstop --> | ||
``` | ||
@@ -46,5 +45,5 @@ ## Feature Discussions | ||
Have a look at the latest updates of this package in the [CHANGELOG](https://github.com/frontity/frontity/blob/dev/packages/error/CHANGELOG.md) | ||
Have a look at the latest updates of this package in the [CHANGELOG](CHANGELOG.md) | ||
*** | ||
--- | ||
@@ -59,8 +58,9 @@ ## Open Source Community | ||
- **📖 [Docs](https://docs.frontity.org/):** Frontity's primary documentation resource - this is the place to learn how to build amazing sites with Frontity. | ||
* **👨👩👧👦 [Community forum](https://community.frontity.org/):** join Frontity's forum and ask questions, share your knowledge, give feedback and meet other cool Frontity people. We'd love to know about what you're building with Frontity, so please do swing by the [forum](https://community.frontity.org/) and tell us about your projects. | ||
* **🐞 Contribute:** Frontity uses [GitHub](https://github.com/frontity/frontity) for bugs and pull requests. Check out the [Contributing](../contributing/) section to find out how you can help develop Frontity, or improve this documentation. | ||
* **🗣 Social media**: interact with other Frontity users. Reach out to the Frontity team on [Twitter](https://twitter.com/frontity). Mention us in your tweets about Frontity and what you're building by using **`@frontity`**. | ||
* 💌 **Newsletter:** do you want to receive the latest news about Frontity and find out as soon as there's an update to the framework? Subscribe to our [newsletter](https://frontity.org/#newsletter). | ||
- **📖 [Docs](https://docs.frontity.org/):** Frontity's primary documentation resource - this is the place to learn how to build amazing sites with Frontity. | ||
* **👨👩👧👦 [Community forum](https://community.frontity.org/):** join Frontity's forum and ask questions, share your knowledge, give feedback and meet other cool Frontity people. We'd love to know about what you're building with Frontity, so please do swing by the [forum](https://community.frontity.org/) and tell us about your projects. | ||
* **🐞 Contribute:** Frontity uses [GitHub](https://github.com/frontity/frontity) for bugs and pull requests. Check out the [Contributing](../../CONTRIBUTING.md/) section to find out how you can help develop Frontity, or improve this documentation. | ||
* **🗣 Social media**: interact with other Frontity users. Reach out to the Frontity team on [Twitter](https://twitter.com/frontity). Mention us in your tweets about Frontity and what you're building by using **`@frontity`**. | ||
* 💌 **Newsletter:** do you want to receive the latest news about Frontity and find out as soon as there's an update to the framework? Subscribe to our [newsletter](https://frontity.org/newsletter). | ||
### Get involved | ||
@@ -74,2 +74,2 @@ | ||
If you would like to start contributing to the code please open a pull request to address one of our [*good first issues*](https://github.com/frontity/frontity/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). | ||
If you would like to start contributing to the code please open a pull request to address one of our [_good first issues_](https://github.com/frontity/frontity/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22). |
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
9215
101
71
1