-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,267 additions
and
1,024 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "2.6.1", | ||
"version": "2.7.0", | ||
"npmClient": "yarn", | ||
"useWorkspaces": true, | ||
"stream": true | ||
|
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
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
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,49 @@ | ||
# Disallow the delete operator with computed key expressions (no-dynamic-delete) | ||
|
||
Deleting dynamically computed keys can be dangerous and in some cases not well optimized. | ||
|
||
## Rule Details | ||
|
||
Using the `delete` operator on keys that aren't runtime constants could be a sign that you're using the wrong data structures. | ||
Using `Object`s with added and removed keys can cause occasional edge case bugs, such as if a key is named `"hasOwnProperty"`. | ||
Consider using a `Map` or `Set` if you’re storing collections of objects. | ||
|
||
Examples of **correct** code wth this rule: | ||
|
||
```ts | ||
const container: { [i: string]: number } = { | ||
/* ... */ | ||
}; | ||
|
||
// Constant runtime lookups by string index | ||
delete container.aaa; | ||
|
||
// Constants that must be accessed by [] | ||
delete container[7]; | ||
delete container['-Infinity']; | ||
``` | ||
|
||
Examples of **incorrect** code with this rule: | ||
|
||
```ts | ||
// Can be replaced with the constant equivalents, such as container.aaa | ||
delete container['aaa']; | ||
delete container['Infinity']; | ||
|
||
// Dynamic, difficult-to-reason-about lookups | ||
const name = 'name'; | ||
delete container[name]; | ||
delete container[name.toUpperCase()]; | ||
``` | ||
|
||
## When Not To Use It | ||
|
||
When you know your keys are safe to delete, this rule can be unnecessary. | ||
Some environments such as older browsers might not support `Map` and `Set`. | ||
|
||
Do not consider this rule as performance advice before profiling your code's bottlenecks. | ||
Even repeated minor performance slowdowns likely do not significantly affect your application's general perceived speed. | ||
|
||
## Related to | ||
|
||
- TSLint: [no-dynamic-delete](https://palantir.github.io/tslint/rules/no-dynamic-delete) |
25 changes: 25 additions & 0 deletions
25
packages/eslint-plugin/docs/rules/no-unused-expressions.md
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,25 @@ | ||
# require or disallow semicolons instead of ASI (semi) | ||
|
||
This rule aims to eliminate unused expressions which have no effect on the state of the program. | ||
|
||
## Rule Details | ||
|
||
This rule extends the base [eslint/no-unused-expressions](https://eslint.org/docs/rules/no-unused-expressions) rule. | ||
It supports all options and features of the base rule. | ||
This version adds support for numerous typescript features. | ||
|
||
## How to use | ||
|
||
```cjson | ||
{ | ||
// note you must disable the base rule as it can report incorrect errors | ||
"no-unused-expressions": "off", | ||
"@typescript-eslint/no-unused-expressions": ["error"] | ||
} | ||
``` | ||
|
||
## Options | ||
|
||
See [eslint/no-unused-expressions options](https://eslint.org/docs/rules/no-unused-expressions#options). | ||
|
||
<sup>Taken with ❤️ [from ESLint core](https://github.com/eslint/eslint/blob/master/docs/rules/no-unused-expressions.md)</sup> |
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
Oops, something went wrong.