eslint / json

JSON language plugin for ESLint
Apache License 2.0
44 stars 4 forks source link

Change Request: add type tests #61

Closed fasttime closed 3 days ago

fasttime commented 4 days ago

Environment

ESLint version: v9.15.0 @eslint/json version: v9.15.0 Node version: v23.2.0 npm version: 10.9.0 Operating System: Windows

What problem do you want to solve?

The types for this plugin are generated automatically using TypeScript's type inference because there is no explicit JSDoc type annotation for the main export. Type inference relies on several assumptions to work correctly and can easily break if the code is changed or refactored, but with the current setup, a breakage in the types would go unnoticed.

What do you think is the correct solution?

There should be unit tests for the types.

Participation

Additional comments

An example of incorrect types that was noticed in #59 is the case in which a nested property is assigned a value after the plugin object is declared. The naive assignment using plugin.configs.recommended.plugins.json = plugin; would cause TypeScript to discard part of the type information from the previous declaration and end up with an incomplete type in the generated .d.ts files.

nzakas commented 4 days ago

Makes sense to me :+1: