Skip to content

Commit 3bb4505

Browse files
authored
Release 0.9.7 (#199)
Co-authored-by: oxc-bot <176400334+oxc-bot@users.noreply.github.com>
1 parent 38df82e commit 3bb4505

File tree

9 files changed

+229
-17
lines changed

9 files changed

+229
-17
lines changed

src/docs/guide/usage/linter/generated-cli.md

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ Arguments:
6565
Enable the promise plugin and detect promise usage problems
6666
- **` --node-plugin`** &mdash;
6767
Enable the node plugin and detect node usage problems
68+
- **` --security-plugin`** &mdash;
69+
Enable the security plugin and detect security problems
6870

6971
## Fix Problems
7072

src/docs/guide/usage/linter/generated-config.md

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ Globals can be disabled by setting their value to `"off"`. For example, in an en
6161

6262
You may also use `"readable"` or `false` to represent `"readonly"`, and `"writeable"` or `true` to represent `"writable"`.
6363

64+
## plugins
65+
66+
type: `array`
67+
68+
### plugins[n]
69+
70+
type: `string`
71+
6472
## rules
6573

6674
type: `object`

src/docs/guide/usage/linter/generated-rules.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
The progress of all rule implementations is tracked [here](https://github.com/oxc-project/oxc/issues/481).
44

5-
- Total number of rules: 429
5+
- Total number of rules: 432
66
- Rules turned on by default: 96
77

8-
## Correctness (169):
8+
## Correctness (170):
99

1010
Code that is outright wrong or useless.
1111
| Rule name | Source | Default | Fixable? |
@@ -154,6 +154,7 @@ Code that is outright wrong or useless.
154154
| [no-render-return-value](/docs/guide/usage/linter/rules/react/no-render-return-value.html) | react || |
155155
| [no-string-refs](/docs/guide/usage/linter/rules/react/no-string-refs.html) | react || |
156156
| [void-dom-elements-no-children](/docs/guide/usage/linter/rules/react/void-dom-elements-no-children.html) | react || |
157+
| [api-keys](/docs/guide/usage/linter/rules/security/api-keys.html) | security | | |
157158
| [no-duplicate-enum-values](/docs/guide/usage/linter/rules/typescript/no-duplicate-enum-values.html) | typescript || |
158159
| [no-extra-non-null-assertion](/docs/guide/usage/linter/rules/typescript/no-extra-non-null-assertion.html) | typescript || |
159160
| [no-misused-new](/docs/guide/usage/linter/rules/typescript/no-misused-new.html) | typescript || |
@@ -192,7 +193,7 @@ Code that can be written to run faster.
192193
| [jsx-no-new-function-as-prop](/docs/guide/usage/linter/rules/react_perf/jsx-no-new-function-as-prop.html) | react_perf | | |
193194
| [jsx-no-new-object-as-prop](/docs/guide/usage/linter/rules/react_perf/jsx-no-new-object-as-prop.html) | react_perf | | |
194195

195-
## Restriction (58):
196+
## Restriction (57):
196197

197198
Lints which prevent the use of language and library features. Must not be enabled as a whole, should be considered on a case-by-case basis before enabling.
198199
| Rule name | Source | Default | Fixable? |
@@ -209,7 +210,7 @@ Lints which prevent the use of language and library features. Must not be enable
209210
| [no-iterator](/docs/guide/usage/linter/rules/eslint/no-iterator.html) | eslint | | 🚧 |
210211
| [no-plusplus](/docs/guide/usage/linter/rules/eslint/no-plusplus.html) | eslint | | 🚧 |
211212
| [no-proto](/docs/guide/usage/linter/rules/eslint/no-proto.html) | eslint | | 🚧 |
212-
| [no-regex-spaces](/docs/guide/usage/linter/rules/eslint/no-regex-spaces.html) | eslint | | |
213+
| [no-regex-spaces](/docs/guide/usage/linter/rules/eslint/no-regex-spaces.html) | eslint | | 🚧 |
213214
| [no-restricted-globals](/docs/guide/usage/linter/rules/eslint/no-restricted-globals.html) | eslint | | |
214215
| [no-undefined](/docs/guide/usage/linter/rules/eslint/no-undefined.html) | eslint | | |
215216
| [no-unsafe-optional-chaining](/docs/guide/usage/linter/rules/eslint/no-unsafe-optional-chaining.html) | eslint | | |
@@ -229,7 +230,6 @@ Lints which prevent the use of language and library features. Must not be enable
229230
| [no-const-enum](/docs/guide/usage/linter/rules/oxc/no-const-enum.html) | oxc | | 🛠️ |
230231
| [no-optional-chaining](/docs/guide/usage/linter/rules/oxc/no-optional-chaining.html) | oxc | | |
231232
| [no-rest-spread-properties](/docs/guide/usage/linter/rules/oxc/no-rest-spread-properties.html) | oxc | | |
232-
| [avoid-new](/docs/guide/usage/linter/rules/promise/avoid-new.html) | promise | | |
233233
| [catch-or-return](/docs/guide/usage/linter/rules/promise/catch-or-return.html) | promise | | |
234234
| [spec-only](/docs/guide/usage/linter/rules/promise/spec-only.html) | promise | | |
235235
| [button-has-type](/docs/guide/usage/linter/rules/react/button-has-type.html) | react | | |
@@ -256,12 +256,14 @@ Lints which prevent the use of language and library features. Must not be enable
256256
| [prefer-node-protocol](/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.html) | unicorn | | 🛠️ |
257257
| [prefer-number-properties](/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html) | unicorn | | 🚧 |
258258

259-
## Suspicious (18):
259+
## Suspicious (20):
260260

261261
code that is most likely wrong or useless.
262262
| Rule name | Source | Default | Fixable? |
263263
| ------------------------------- | ---------- | ------- | -------- |
264+
| [no-extend-native](/docs/guide/usage/linter/rules/eslint/no-extend-native.html) | eslint | | |
264265
| [no-new](/docs/guide/usage/linter/rules/eslint/no-new.html) | eslint | | |
266+
| [no-unexpected-multiline](/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.html) | eslint | | ⚠️🛠️️ |
265267
| [no-useless-concat](/docs/guide/usage/linter/rules/eslint/no-useless-concat.html) | eslint | | |
266268
| [no-useless-constructor](/docs/guide/usage/linter/rules/eslint/no-useless-constructor.html) | eslint | | 🛠️ |
267269
| [no-duplicates](/docs/guide/usage/linter/rules/import/no-duplicates.html) | import | | |
@@ -355,7 +357,7 @@ Lints which are rather strict or have occasional false positives.
355357
| [prefer-type-error](/docs/guide/usage/linter/rules/unicorn/prefer-type-error.html) | unicorn | | 🛠️ |
356358
| [require-number-to-fixed-digits-argument](/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.html) | unicorn | | 🛠️ |
357359

358-
## Style (99):
360+
## Style (100):
359361

360362
Code that should be written in a more idiomatic way.
361363
| Rule name | Source | Default | Fixable? |
@@ -413,6 +415,7 @@ Code that should be written in a more idiomatic way.
413415
| [require-hook](/docs/guide/usage/linter/rules/jest/require-hook.html) | jest | | |
414416
| [require-top-level-describe](/docs/guide/usage/linter/rules/jest/require-top-level-describe.html) | jest | | |
415417
| [no-exports-assign](/docs/guide/usage/linter/rules/node/no-exports-assign.html) | node | | 🛠️ |
418+
| [avoid-new](/docs/guide/usage/linter/rules/promise/avoid-new.html) | promise | | |
416419
| [param-names](/docs/guide/usage/linter/rules/promise/param-names.html) | promise | | |
417420
| [prefer-await-to-then](/docs/guide/usage/linter/rules/promise/prefer-await-to-then.html) | promise | | |
418421
| [jsx-boolean-value](/docs/guide/usage/linter/rules/react/jsx-boolean-value.html) | react | | 🛠️ |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->
2+
3+
# eslint/no-extend-native <Badge type="info" text="Suspicious" />
4+
5+
<div class="rule-meta">
6+
</div>
7+
8+
### What it does
9+
10+
Prevents extending native global objects such as `Object`, `String`, or `Array` with new
11+
properties.
12+
13+
### Why is this bad?
14+
15+
Extending native objects can cause unexpected behavior and conflicts with other code.
16+
17+
For example:
18+
19+
```js
20+
// Adding a new property, which might seem okay
21+
Object.prototype.extra = 55;
22+
23+
// Defining a user object
24+
const users = {
25+
1: "user1",
26+
2: "user2",
27+
};
28+
29+
for (const id in users) {
30+
// This will print "extra" as well as "1" and "2":
31+
console.log(id);
32+
}
33+
```
34+
35+
### Examples
36+
37+
Examples of **incorrect** code for this rule:
38+
39+
```js
40+
Object.prototype.p = 0;
41+
Object.defineProperty(Array.prototype, "p", { value: 0 });
42+
```
43+
44+
Examples of **correct** code for this rule:
45+
46+
```js
47+
x.prototype.p = 0;
48+
Object.defineProperty(x.prototype, "p", { value: 0 });
49+
```
50+
51+
## References
52+
53+
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_extend_native.rs)

src/docs/guide/usage/linter/rules/eslint/no-regex-spaces.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
# eslint/no-regex-spaces <Badge type="info" text="Restriction" />
44

55
<div class="rule-meta">
6+
<Alert class="fix" type="info">
7+
<span class="emoji">🚧</span> An auto-fix is still under development.
8+
</Alert>
69
</div>
710

811
### What it does
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->
2+
3+
# eslint/no-unexpected-multiline <Badge type="info" text="Suspicious" />
4+
5+
<div class="rule-meta">
6+
<Alert class="fix" type="info">
7+
<span class="emoji">⚠️🛠️️</span> A dangerous auto-fix is available for this rule.
8+
</Alert>
9+
</div>
10+
11+
### What it does
12+
13+
In most cases, semicolons are not required in JavaScript in order for code to be parsed
14+
and executed as expected. Typically this occurs because semicolons are automatically
15+
inserted based on a fixed set of rules. This rule exists to detect those cases where a semicolon
16+
is NOT inserted automatically, and may be parsed differently than expected.
17+
18+
### Why is this bad?
19+
20+
Code that has unexpected newlines may be parsed and executed differently than what the
21+
developer intended. This can lead to bugs that are difficult to track down.
22+
23+
### Examples
24+
25+
Examples of **incorrect** code for this rule:
26+
27+
```js
28+
var a = b(x || y).doSomething();
29+
30+
var a = b[(a, b, c)].forEach(doSomething);
31+
32+
let x = (function () {})`hello`;
33+
34+
foo / bar / g.test(baz);
35+
```
36+
37+
Examples of **correct** code for this rule:
38+
39+
```js
40+
var a = b;
41+
(x || y).doSomething();
42+
43+
var a = b;
44+
[a, b, c].forEach(doSomething);
45+
46+
let x = function () {};
47+
`hello`;
48+
49+
foo;
50+
/bar/g.test(baz);
51+
```
52+
53+
## References
54+
55+
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs)

src/docs/guide/usage/linter/rules/promise/avoid-new.md

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
11
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->
22

3-
# promise/avoid-new <Badge type="info" text="Restriction" />
3+
# promise/avoid-new <Badge type="info" text="Style" />
44

55
<div class="rule-meta">
66
</div>
77

88
### What it does
99

10-
Disallow creating new promises outside of utility libs.
10+
Disallow creating promises with `new Promise()`.
1111

1212
### Why is this bad?
1313

14-
If you dislike the new promise style promises.
14+
Many cases that use `new Promise()` could be refactored to use an
15+
`async` function. `async` is considered more idiomatic in modern JavaScript.
1516

1617
### Example
1718

19+
Examples of **incorrect** code for this rule:
20+
21+
```javascript
22+
function foo() {
23+
return new Promise((resolve, reject) => {
24+
/* ... */
25+
});
26+
}
27+
```
28+
29+
Examples of **correct** code for this rule:
30+
1831
```javascript
19-
new Promise((resolve, reject) => {
20-
/* ... */
21-
});
32+
async function foo() {
33+
// ...
34+
}
35+
const bar = await Promise.all([baz(), bang()]);
2236
```
2337

2438
## References

src/docs/guide/usage/linter/rules/promise/catch-or-return.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
### What it does
99

10-
Ensure that each time a then() is applied to a promise, a catch() is applied as well.
11-
Exceptions are made if you are returning that promise.
10+
Ensure that each time a `then()` is applied to a promise, a `catch()`
11+
must be applied as well. Exceptions are made for promises returned from
12+
a function.
1213

1314
### Why is this bad?
1415

15-
Not catching errors in a promise can cause hard to debug problems or missing handling of
16-
error conditions.
16+
Not catching errors in a promise can cause hard to debug problems or
17+
missing handling of error conditions. In the worst case, unhandled
18+
promise rejections can cause your application to crash.
1719

1820
### Example
1921

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. -->
2+
3+
# security/api-keys <Badge type="info" text="Correctness" />
4+
5+
<div class="rule-meta">
6+
</div>
7+
8+
### What it does
9+
10+
Disallows hard-coded API keys and other credentials.
11+
12+
### Why is this bad?
13+
14+
Hard-coding API keys and committing them to source control is a serious
15+
security risk.
16+
17+
1. If your code is leaked, attackers can use your API keys to access your
18+
services and data.
19+
2. Accidental bundling of API keys can lead them to be exposed publicly
20+
in your website, compriming your services.
21+
3. Any developer or contractor you hire will have access to your
22+
services, even after they lose access to your codebase.
23+
4. Even after being deleted, they will be visible in your git repo's
24+
commit history.
25+
5. Key rotation requires a code change and redeployment, and can
26+
therefore not be handled by security teams or by automated systems.
27+
6. Many, many more reasons.
28+
29+
```ts
30+
const API_KEY = "abcdef123456";
31+
const data = await fetch("/api/some/endpoint", {
32+
headers: {
33+
Authorization: `Bearer ${API_KEY}`,
34+
},
35+
});
36+
```
37+
38+
### What To Do Instead
39+
40+
:::warning
41+
The Oxc team are not security experts. We do not endorse any particular
42+
key management service or strategy. Do your research and choose the best
43+
solution/architecture for your use case.
44+
:::
45+
46+
One possible alternative is to store secrets in a secure secrets manager
47+
(such as [AWS
48+
KMS](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/kms/),
49+
[HashiCorp Vault](https://github.com/nodevault/node-vault/tree/master),
50+
[Pangea](https://pangea.cloud/docs/sdk/js/vault#retrieve), etc.) and
51+
request them when your application starts (e.g. a Docker container, an
52+
EC2).
53+
54+
### Examples
55+
56+
Examples of **incorrect** code for this rule:
57+
58+
```js
59+
const AWS_ACCESS_KEY_ID = "AKIA1234X678C123B567";
60+
const OPENAI_API_KEY = "sk_test_1234567890";
61+
```
62+
63+
Examples of **correct** code for this rule:
64+
65+
```js
66+
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID;
67+
const OPENAI_API_KEY = await getSecret("open-ai-api-key");
68+
```
69+
70+
## References
71+
72+
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/security/api_keys/mod.rs)

0 commit comments

Comments
 (0)