This PR adds support for `:has/:is/:where()` and `:not()`. The latter
was already present, but found a bunch of issues with it and I'd say
that it didn't really work before this PR.
Fixes https://github.com/denoland/deno/issues/28335
Internally, we use a group node for array-like children, which is hidden
from the user. When we're asking for a parent of a node we need to take
group nodes into account and walk over them.
Fixes one issue reported in
https://github.com/denoland/deno/issues/28355
This PR adds support for field selectors (`.<field>`) in the lint plugin
API. This is supported in ESLint as well, but was missing in our
implementation.
```css
/* Only search the test expression of an IfStatement */
IfStatement.test
```
Fixes https://github.com/denoland/deno/issues/28314
The code to support regex matching on attribute values was already
there. I just forgot to wire it up properly in the selector matching
code.
Fixes https://github.com/denoland/deno/issues/28336
This PR changes the underlying buffer backed AST format we use for
JavaScript-based linting plugins. It adds support for various new types,
makes traversal code a lot easier and is more polished compared to
previous iterations.
Here is a quick summary (in no particular order):
- Node prop data is separate from traversal, which makes traversal code
so much easier to reason about. Previously, it was interleaved with node
prop data
- spans are in a separate table as well, as they are rarely needed.
- schema is separate from SWC conversion logic, which makes
- supports recursive plain objects
- supports numbers
- supports bigint
- supports regex
- adds all SWC nodes
Apologies, this is kinda a big PR, but it's worth it imo.
_Marking as draft because I need to update some tests tomorrow._
The selector splitting code that's used for JS linting plugins didn't
properly account for selectors being a single character. This can happen
in the case of `*`.
Instead of comparing against the length, we'll now check if the
remaining string portion is not empty, which is more robust. It also
allows us to detect trailing whitespace, which we didn't before.