🛠 Tooling: Find a way to avoid 'as unknown as ESTree.Node' assertions #125
Labels
area: tooling
Managing the repository's maintenance
status: blocked
Waiting for something else to be resolved
Bug Report Checklist
main
branch of the repository.Overview
Following #40 & #59 & ota-meshi/jsonc-eslint-parser#184: the current state of types for AST nodes in this plugin is that we've completely swapped out the built-in ESLint ones. Nodes are instead typed using
import type { AST as JsonAST } from "jsonc-eslint-parser";
->node: JsonAST.JSONProperty
and the like.Unfortunately, ESLint's APIs still expect ESTree nodes. So we end up with assertions any time we need to pass the nodes to ESLint's APIs:
eslint-plugin-package-json/src/rules/valid-repository-directory.ts
Lines 32 to 34 in 84035c3
This isn't ideal. One workaround done by
eslint-plugin-jsonc
is to instead passloc: node.loc
. But I'd ideally like to be able to just pass thenode
directly.Additional Info
I don't know a straightforward way to make this better.
context.report
is typed in@types/eslint
as:...with:
I suppose
@types/eslint
could mark the context with a type parameter like<Node = ESTree.Node>
😬... Eww.Filed ota-meshi/jsonc-eslint-parser#198. Marking as blocked pending discussion there.
The text was updated successfully, but these errors were encountered: