This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: docs * chore: description * chore: badge * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix * chore: fix
- Loading branch information
1 parent
25abb77
commit 053704b
Showing
13 changed files
with
170 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# No Error (no-error) | ||
|
||
We use our `ErrorHandler` to handle warnings, errors and fatal errors, | ||
which reacts appropriately and unified to the severity. | ||
Therefore, this handler should always be used instead of throwing an error yourself. | ||
|
||
## Rule Details | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```ts | ||
new Error('foo'); | ||
new EvalError('foo'); | ||
new InternalError('foo'); | ||
new RangeError('foo'); | ||
new ReferenceError('foo'); | ||
new SyntaxError('foo'); | ||
new TypeError('foo'); | ||
new URIError('foo'); | ||
throw new Error('foo'); | ||
throw new EvalError('foo'); | ||
throw new InternalError('foo'); | ||
throw new RangeError('foo'); | ||
throw new ReferenceError('foo'); | ||
throw new SyntaxError('foo'); | ||
throw new TypeError('foo'); | ||
throw new URIError('foo'); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```ts | ||
new FooClass(); | ||
const Error = 'foo'; | ||
ErrorHandler.error({ code: FrontendErrorCodeEnum.BAD_HEX_COLOR, filename: 'ColorUtil.ts' }); | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
For parts of the start-up process, for example our config. | ||
The `ErrorHandler` uses the config, and the config uses the `ErrorHandler`. | ||
This would create a recursive cycle. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# No Logger Error Method (no-logger-error-method) | ||
|
||
The logger methods `warn`, `error` and `fatal` should not be used directly. | ||
Instead, one should call the `ErrorHandler`, which reacts appropriately to the status and calls the `Logger`. | ||
|
||
## Rule Details | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```ts | ||
Logger.warn('Logger.ts', 'message'); | ||
Logger.error('Logger.ts', 'message'); | ||
Logger.fatal('Logger.ts', 'message'); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```ts | ||
Logger.debug('Logger.ts', 'message'); | ||
Logger.info('Logger.ts', 'message'); | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
For parts of the start-up process, for example our config. | ||
The `Logger` uses the config, and the config uses the `Logger`. | ||
This would create a recursive cycle. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,34 @@ | ||
# No Text component (no-text-component) | ||
|
||
We use our Typography component to display text, which for example preconfigures the font family and other properties. | ||
We use our Typography component to display text, | ||
which for example preconfigures the font family and other properties. | ||
Therefore, this component should always be used instead of the text component. | ||
|
||
The ESLint rule `no-restricted-imports` would make this rule only partially redundant, | ||
as it would only prohibit the `Text` component, but not `Animated.Text`. | ||
This is in the nature of this rule, as only the entire React Native `Animated` module can be imported. | ||
|
||
```yml | ||
no-restricted-imports: | ||
- 2 | ||
- name: react-native | ||
importNames: | ||
- Text | ||
message: The react-native <Text /> component is not allowed. Please use the custom <Typography /> component. | ||
``` | ||
## Rule Details | ||
Examples of **incorrect** code for this rule: | ||
```ts | ||
const MyComponent = () => <Text>Some text</Text>; | ||
const MyComponent = () => <Animated.Text>Some text</Animated.Text>; | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```ts | ||
const MyComponent = () => <Typography>Some text</Typography>; | ||
const MyComponent = () => <Typography.Animated>Some text</Typography.Animated>; | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
Give a short description of when it would be appropriate to turn off this rule. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# No Throw (no-throw) | ||
|
||
We use our `ErrorHandler` to handle warnings, errors and fatal errors, | ||
which reacts appropriately and unified to the severity. | ||
Therefore, this handler should always be used instead of throwing an error yourself. | ||
|
||
## Rule Details | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```ts | ||
throw new Error('foo'); | ||
throw error; | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```ts | ||
ErrorHandler.error({ code: FrontendErrorCodeEnum.BAD_HEX_COLOR, filename: 'ColorUtil.ts' }); | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
For parts of the start-up process, for example our config. | ||
The `ErrorHandler` uses the config, and the config uses the `ErrorHandler`. | ||
This would create a recursive cycle. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** | ||
* @fileoverview | ||
* We use the ErrorHandler to handle warnings, errors and fatal errors, | ||
* We use our `ErrorHandler` to handle warnings, errors and fatal errors, | ||
* which reacts appropriately and unified to the severity. | ||
* Therefore, this should always be used instead of throwing an error yourself. | ||
* Therefore, this handler should always be used instead of throwing an error yourself. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @fileoverview | ||
* The logger methods "warn", "error" and "fatal" should not be used directly. | ||
* Instead, one should call the ErrorHandler, which reacts appropriately to the status and calls the logger. | ||
* The logger methods `warn`, `error` and `fatal` should not be used directly. | ||
* Instead, one should call the `ErrorHandler`, which reacts appropriately to the status and calls the `Logger`. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
/** | ||
* @fileoverview We use our Typography component to display text, which for example preconfigures the font family and other properties. Therefore, this component should always be used instead of the text component. | ||
* @fileoverview | ||
* We use our Typography component to display text, | ||
* which for example preconfigures the font family and other properties. | ||
* Therefore, this component should always be used instead of the text component. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
import type { Rule } from 'eslint'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** | ||
* @fileoverview | ||
* We use the ErrorHandler to handle warnings, errors and fatal errors, | ||
* We use our `ErrorHandler` to handle warnings, errors and fatal errors, | ||
* which reacts appropriately and unified to the severity. | ||
* Therefore, this should always be used instead of throwing an error yourself. | ||
* Therefore, this handler should always be used instead of throwing an error yourself. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** | ||
* @fileoverview | ||
* We use the ErrorHandler to handle warnings, errors and fatal errors, | ||
* We use our `ErrorHandler` to handle warnings, errors and fatal errors, | ||
* which reacts appropriately and unified to the severity. | ||
* Therefore, this should always be used instead of throwing an error yourself. | ||
* Therefore, this handler should always be used instead of throwing an error yourself. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
|
@@ -46,5 +46,9 @@ ruleTester.run('no-error', noError, { | |
{ code: "throw new TypeError('foo');", errors: [error] }, | ||
{ code: "throw new URIError('foo');", errors: [error] }, | ||
], | ||
valid: ['new FooClass()', "const Error = 'foo'"], | ||
valid: [ | ||
'new FooClass()', | ||
"const Error = 'foo'", | ||
"ErrorHandler.error({ code: FrontendErrorCodeEnum.BAD_HEX_COLOR, filename: 'ColorUtil.ts' });", | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @fileoverview | ||
* The logger methods "warn", "error" and "fatal" should not be used directly. | ||
* Instead, one should call the ErrorHandler, which reacts appropriately to the status and calls the logger. | ||
* The logger methods `warn`, `error` and `fatal` should not be used directly. | ||
* Instead, one should call the `ErrorHandler`, which reacts appropriately to the status and calls the `Logger`. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/** | ||
* @fileoverview | ||
* We use the ErrorHandler to handle warnings, errors and fatal errors, | ||
* We use our `ErrorHandler` to handle warnings, errors and fatal errors, | ||
* which reacts appropriately and unified to the severity. | ||
* Therefore, this should always be used instead of throwing an error yourself. | ||
* Therefore, this handler should always be used instead of throwing an error yourself. | ||
* | ||
* @author Daniel Reichhart <[email protected]> | ||
*/ | ||
|
@@ -32,5 +32,5 @@ ruleTester.run('no-throw', noThrow, { | |
{ code: "throw new Error('foo');", errors: [error] }, | ||
{ code: 'throw error;', errors: [error] }, | ||
], | ||
valid: [], | ||
valid: ["ErrorHandler.error({ code: FrontendErrorCodeEnum.BAD_HEX_COLOR, filename: 'ColorUtil.ts' });"], | ||
}); |