Commit graph

1448 commits

Author SHA1 Message Date
DonIsaac
d24985ed51 feat(linter): add oxc-security/api-keys (#5906)
## What This PR does
Adds a new `oxc-security/api-key` rule that scans for hard-coded API keys.

It is broken up into "secret rules", where each one is responsible for finding a different kind of key. It is architecturally identical to how lint rules themselves. This PR also includes the first of these rules, for AWS access key IDs.

Logic and rules are based on [keyhunter](https://github.com/Donisaac/keyhunter). I've licensed that repo under GNU GPLv3, but it's my code and I can do what I want with it 😈 (read: I'm fine with it being MIT for oxc).

This PR is a complete feature in its own right, but does not represent the end of this work. See https://github.com/oxc-project/backlog/issues/116 to track overall progress.
2024-09-22 22:39:56 +00:00
DonIsaac
74d8714d5a feat(semantic): add help message for invalid let x?: number (#5969) 2024-09-22 15:59:49 +00:00
Boshen
612f638bcd
chore: change just c to run cargo conformance 2024-09-22 23:50:30 +08:00
DonIsaac
f1551d64bc fix(semantic): ? on variable declaration type annotations is a syntax error (#5956)
Closes #5955
2024-09-22 00:01:47 +00:00
Dunqing
4a62703d88 feat(isolated-declarations): handle export in the namespace correctly (#5950)
Previous I didn't follow the behavior of `TypeScript` to handle `export` in `namespace` as I thought no one used this
2024-09-21 16:39:58 +00:00
Alexander S.
463c24e5ec
fix(prettier): handle TSTypeLiteral as an object (#5946)
- [x] semi is optional with the right configuration
2024-09-21 23:27:12 +08:00
Boshen
f4aefb57d8 fix(codegen): print let[0] as (let)[0] (#5947) 2024-09-21 15:09:55 +00:00
overlookmotel
4e9e838838 fix(transformer): fix arrow function transform (#5933)
Fix arrow function transform's treatment of `this` within classes.
2024-09-21 07:48:18 +00:00
Boshen
12d4888120 chore(prettier): remove incorrect comment printing logic (#5889)
Remove the previous incorrect implementation, cc @leaysgur
2024-09-21 04:45:18 +00:00
overlookmotel
15743344b1 test(transformer): add test for arrow function transform (#5932)
Add test for `this` in nested block inside arrow function.
2024-09-21 00:53:43 +00:00
Boshen
d901772daa feat(codegen): implement minify number from terser (#5929) 2024-09-20 14:42:28 +00:00
Boshen
6757c5829f
chore(transform_conformance): remove unused snapshots/typescript.snap.md
closes #5922
2024-09-20 22:41:41 +08:00
overlookmotel
b80a9eec7f refactor(ast_tools): shorten code (#5915)
#5904 reduced the generated code for `Visit` trait. Shorten the codegen a little after that change.
2024-09-20 14:15:11 +00:00
overlookmotel
eadffb900e test(conformance): move conformance snapshots into separate directory (#5924) 2024-09-20 12:30:39 +00:00
DonIsaac
ba7b01fbdf refactor(linter): Add LinterBuilder (#5714)
This will replace `OxlintOptions` in an upstream PR. This also adds `plugins` to
`Oxlintrc`. This field gets respected by the builder, but not by
`OxlintOptions`.
2024-09-20 11:58:37 +00:00
overlookmotel
8ade793dfe test(prettier): move prettier conformance snapshots into separate directory (#5921) 2024-09-20 11:34:13 +00:00
overlookmotel
bd318b1eec test(transformer): join paths in cross-platform compatible way (#5920) 2024-09-20 11:30:12 +00:00
overlookmotel
7d32d2086c
test(transformer): update transform conformance README (#5919)
Add reference to our additional tests + tidy up capitalization.
2024-09-20 11:46:44 +01:00
overlookmotel
9dac6dfb23 test(transformer): move transformer conformance snapshots into separate directory (#5917)
Move snapshots for transform conformance into a `snapshots` sub-folder.
2024-09-20 10:25:17 +00:00
camchenry
f4fac0f488 refactor(ast): remove .iter() where not needed (#5904)
this is just an experiment, I noticed while profiling these code paths came up a number of times:
<img width="1077" alt="Screenshot 2024-09-19 at 8 32 51 PM" src="https://github.com/user-attachments/assets/d0f4d703-c456-4344-8f57-81f0b3f491a0">
2024-09-20 02:41:49 +00:00
Alexander S.
65c337a071
feat(prettier): improve ts compatibility (#5900) 2024-09-20 10:40:31 +08:00
overlookmotel
4d5c4f6cad fix(transformer): fix reference flags in logical assignment operator transform (#5903) 2024-09-20 01:26:55 +00:00
overlookmotel
d335a6760e fix(transformer): fix references in logical assignment operator transform (#5896)
Re-use existing reference, rather than creating a new one.
2024-09-20 01:26:53 +00:00
overlookmotel
cab441c572 test(transformer): fix JSX test options (#5895)
Fix a test by setting correct options.
2024-09-20 01:26:52 +00:00
overlookmotel
9758c1a5cc fix(transformer): JSX source: add var _jsxFileName statement (#5894)
Fix JSX source transform when run alone without main JSX transform.

The added test case is same as one of Babel's exec test cases, but the exec test fails due to `transformAsync` not being present.
2024-09-20 01:26:52 +00:00
Boshen
84a5816d03
feat(isolated_declarations): add stripInternal (#5878)
closes #3906
closes #5687
closes #3958

---------

Co-authored-by: Dunqing <dengqing0821@gmail.com>
2024-09-19 23:14:47 +08:00
Boshen
db4f16a98f refactor(semantic): call with_trivias before build_with_jsdoc (#5875) 2024-09-19 04:12:57 +00:00
Alexander S.
4e37d18b2e
feat(prettier): start supporting tsx syntax (#5866)
Look at first: #5864 

the only merge conflict for this PR should then be the ts snap file. 
If you want, you can also skip the other PR and merge this one directly
:)
2024-09-19 09:40:07 +08:00
overlookmotel
0c8733df23 test(transformer): clean up identation in test fixtures (#5863)
Not sure how added up with mix of tabs and spaces.
2024-09-18 15:19:59 +00:00
overlookmotel
c96b712f6b refactor(syntax)!: remove SymbolFlags::ArrowFunction (#5857)
`SymbolFlags::ArrowFunction` is an oddity, as whether a symbol is an arrow function is not statically knowable. In the following cases, `f` symbol did not have `ArrowFunction` flag set:

```js
const {f} = {f: () => {}};
```

```js
let f = 123;
f = () => {};
```

`SymbolFlags::ArrowFunction` is therefore not particularly useful, and possibly misleading. Having it complicates the transformer, and it's not used anywhere in Oxc.

This PR removes it.
2024-09-18 14:03:03 +00:00
overlookmotel
2e93548816 ci(transformer): enable arrow function transform in transformer benchmark (#5851) 2024-09-18 11:08:27 +00:00
overlookmotel
ef8dcc9d4d test(transformer): more tests for arrow function transform (#5849) 2024-09-18 09:46:58 +00:00
overlookmotel
49ee1dcff2 fix(transformer): arrow function transform handle this in arrow function in class static block (#5848)
Class static blocks also hold a `this` binding.
2024-09-18 09:46:57 +00:00
Alexander S.
31da9bce3f
feat(prettier): class improvements part 2 (#5838) 2024-09-18 11:07:51 +08:00
Alexander S.
c6d97e9366
feat(prettier): improve ts class output (#5835)
please look first at  #5834 :)
2024-09-17 17:33:35 -04:00
Alexander S.
6d9ccdda92
feat(prettier): support TSMappedType (#5834) 2024-09-17 16:25:51 -04:00
Boshen
5901d2a0f1 fix(codegen): various spacing issues (#5820) 2024-09-17 09:03:28 +00:00
Alexander S.
18e4ac22ad
feat(prettier): improve TSInterfaceDeclaration (#5817)
last one for today :)

---------

Co-authored-by: Don Isaac <donald.isaac@gmail.com>
2024-09-17 14:41:33 +08:00
DonIsaac
a438743191 refactor(linter): move OxlintConfig to Oxlintrc (#5707) 2024-09-17 05:15:37 +00:00
Alexander S.
b5ac5a6bf0
feat(prettier): support TSModuleDeclaration (#5813)
Goal of this PR is to resolve this test:
aa3853b776/tests/format/typescript/interface/separator.ts
2024-09-16 16:39:42 -04:00
Alexander S.
8b1485bb00
feat(prettier): improve ClassMemberish with print_class_property (#5811) 2024-09-16 13:32:20 -04:00
Alexander S.
01f8c1bca8
feat(prettier): support TSIntersectionType and TSUnionType (#5794) 2024-09-16 13:09:30 -04:00
Alexander S.
52c64093f9
feat(prettier): support typescript enums (#5790)
The last failed test is only because of the comments. the oxc prettier
output is:

```
enum Direction {
  Up = 1,
  Down,
  Left,
  Right,
}

enum FileAccess {
  None,
  Read = // constant members
  1 << 1,
  Write = 1 << 2,
  ReadWrite = Read | Write,
  G = // computed member
  "123".length,
}

enum Empty {}

const enum Enum {
  A = 1,
  B = A * 2,
}
```
Expected output:
aa3853b776/tests/format/typescript/enum/__snapshots__/format.test.js.snap (L91-L99)

Hope you can tell more why this happens :)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2024-09-16 11:58:04 +08:00
Boshen
213dbc04ff chore(transform_conformance): do not print comments yet (#5788) 2024-09-15 15:48:58 +00:00
Boshen
512be65fa7 refactor(coverage): remove sourcemap snapshot (#5782) 2024-09-15 08:56:54 +00:00
overlookmotel
3230ae5842 feat(semantic): add SemanticBuilder::with_excess_capacity (#5762)
Add `SemanticBuilder::with_excess_capacity` method to request that `SemanticBuilder` over-allocate space in `Semantic`'s `Vec`s.

Use this method to reserve 200% extra capacity for transformer to create more scopes, symbols and references.

200% is an unscientific guess of how much extra capacity is required. Obviously it depends on what transforms are enabled and content of the source code.
2024-09-14 15:02:16 +00:00
Dunqing
36e698b411 perf(transformer): call transform_jsx in exit_expression rather than enter_expression (#5751)
### Difference

In `enter_expression`: Recursive transform JSX
In `exit_expression`: Deep first transform

After the change,  `transform_jsx` still has a lot of room for improvement.
2024-09-13 17:58:41 +00:00
Dunqing
3cc38dfc05 fix(transformer/react): react refresh panics when encounter use hook (#5768)
close: #5766

I even forgot that React has a `use` hook in the latest version
2024-09-13 16:17:33 +00:00
Dunqing
77d9170f84 fix(transformer/react): isStaticChildren should be false when there is only one child (#5745)
We found a warning report [here](206df66e70/packages/react/src/jsx/ReactJSXElement.js (L614-L632)). It caused by we transform incorrectly
2024-09-13 13:20:59 +00:00
Dunqing
c9fea5dd16 chore(tasks/transformer_conformance): remove an ignored test that has passed (#5750) 2024-09-13 09:03:48 +00:00