oxc/crates/oxc_ast/src
DonIsaac 68efcd4000 feat(linter/react-perf): handle new objects and arrays in prop assignment patterns (#4396)
# What This PR Does

Massively improves all `react-perf` rules
- feat: handle new objects/etc assigned to variables
```tsx
const Foo = () => {
  const x = { foo: 'bar' } // <- now reports this new object
  return <Bar x={x} />
}
```
- feat: handle new objects/etc in binding patterns
```tsx
const Foo = ({ x = [] }) => {
  //           ^^^^^^ now reports this new array
  return <Bar x={x} />
}
```
-feat: nice and descriptive labels for new objects/etc assigned to intermediate variables
```
  ⚠ eslint-plugin-react-perf(jsx-no-new-object-as-prop): JSX attribute values should not contain objects created in the same scope.
   ╭─[jsx_no_new_object_as_prop.tsx:1:27]
 1 │ const Foo = () => { const x = {}; return <Bar x={x} /> }
   ·                           ┬   ─┬                 ┬
   ·                           │    │                 ╰── And used here
   ·                           │    ╰── And assigned a new value here
   ·                           ╰── The prop was declared here
   ╰────
  help: simplify props or memoize props in the parent component (https://react.dev/reference/react/memo#my-component-rerenders-when-a-prop-is-an-object-or-array).
```
- feat: consider `Object.assign()` and `Object.create()` as a new object
- feat: consider `arr.[map, filter, concat]` as a new array
- refactor: move shared implementation code to `ReactPerfRule` in `oxc_linter::utils::react_perf`
2024-07-23 01:52:59 +00:00
..
ast refactor(ast_codegen): better visit marker parsing. (#4371) 2024-07-20 17:07:24 +00:00
ast_impl feat(linter/react-perf): handle new objects and arrays in prop assignment patterns (#4396) 2024-07-23 01:52:59 +00:00
generated fix(ast): visit Programs hashbang field first (#4368) 2024-07-19 16:27:51 +00:00
syntax_directed_operations chore: improve some format by running cargo +nightly fmt 2024-06-19 00:48:30 +08:00
ast_builder_impl.rs chore: remove unsafe_code = "warn" rust lint 2024-07-15 10:39:08 +08:00
ast_kind_impl.rs fix(semantic): resolve references to the incorrect symbol (#4280) 2024-07-17 02:50:48 +00:00
lib.rs feat(ast)!: generate ast_builder.rs. (#3890) 2024-07-09 00:57:26 +00:00
precedence.rs fix(codegen): print parenthesis properly (#4245) 2024-07-14 04:13:10 +00:00
serialize.rs refactor(ast): refactor custom Serialize impls (#3859) 2024-06-24 02:31:59 +00:00
trivia.rs refactor(ast)!: store span details inside comment struct (#4132) 2024-07-09 23:23:43 +08:00