Addresses the review feedback in
https://github.com/denoland/deno/pull/27416 .
- Hoist the buffer max size variable to make it less confusing
- Remove manual AST field counter in favour of an explicit "commit
schema" step which writes the actual field count.
When running selectors for JS linting plugins we would error when
encountering an unknown attribute name:
```js
// selector
Foo[non-existant]
// error
Error: Missing string id: <number>
```
This was caused by using `0` as the invalid marker, but also overloading
`0` with an actual node type. So the fix is to reserve `0` as the
invalid marker and move the property type to the next index.
This PR extracts the core part of
https://github.com/denoland/deno/pull/27203 to make it easier to review
and land in parts.
It contains:
- The JS plugin code the deserializes and walks the buffer
- The Rust portion to serialize SWC to the buffer format (a bunch of
nodes are still todos, but imo these can land anytime later)
- Basic lint plugin types, without the AST node types to make this PR
easier to review
- Added more code comments to explain the format etc.
More fixes and changes will be done in follow-up PRs.
---------
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>