Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many rule allow unwanted additionalProperties #189

Closed
Dimava opened this issue Apr 21, 2023 · 11 comments
Closed

Many rule allow unwanted additionalProperties #189

Dimava opened this issue Apr 21, 2023 · 11 comments

Comments

@Dimava
Copy link
Contributor

Dimava commented Apr 21, 2023

I see over 25 rules with

[k: string]: any;

which disappear if json-schema-to-typescript is configured with { additionalProperties: /* default to: */ false }

I think at least 75% of that is schema typos, and we should use { additionalProperties: /* default to: */ false }

If the type actually has additionalProperties it is always written in type (as Record types obviously require them to exist), while when it hasn't it may be just be forgotten

@Dimava
Copy link
Contributor Author

Dimava commented Apr 21, 2023

image

@Shinigami92
Copy link
Collaborator

Oh nice there is a property for that? wow? This could actually fix all our issues 🎉

@Shinigami92
Copy link
Collaborator

I will check that tomorrow or you already did a PR

@Dimava
Copy link
Contributor Author

Dimava commented Apr 21, 2023

I didnt

@Shinigami92
Copy link
Collaborator

I didnt

I meant: I will do a PR on my own tomorrow if you did not already send a PR from your side

sorry for misunderstandment 😅
I think english is not the native language for both of us 😅

@Dimava
Copy link
Contributor Author

Dimava commented Apr 21, 2023

Other things that coiuld be fixed are

        ignore?: (string & { // string:not(...):not(...), should be just string here
          [k: string]: any;
        } & {
          [k: string]: any;
        })[];

and

        ignorePatterns?: any[]; // mostly string[]

and maybe a couple of annoying TS types that depend on ESLint types

@Dimava
Copy link
Contributor Author

Dimava commented Apr 21, 2023

I didnt

I meant: I will do a PR on my own tomorrow if you did not already send a PR from your side

sorry for misunderstandment 😅 I think english is not the native language for both of us 😅

In my language "I will check that tomorrow or you already did a PR" would be read as a question, so I answered that 😅

@Dimava
Copy link
Contributor Author

Dimava commented Apr 21, 2023

Some context-sensitive types like

export type regex = string & { _?: regex }; // string that is used as RegExp pattern
export type glob = string & { _?: regex }; // string which is used as glob pattern

could also be (very) useful, but that's hard to mantain

@Shinigami92
Copy link
Collaborator

@Shinigami92
Copy link
Collaborator

@Dimava The [k: string]: any; itself is not a problem at all, it just means that other properties can be added to the object and mostly if you need that you should check the website documentation of the rule.

Only stuff like string & otherStuff is something like a bug and we might need to report that back to json-schema-to-typescript repo

But for now I fixed it with #190

@Shinigami92
Copy link
Collaborator

plugin types are now supported via @eslint-type/*
if there are any additionalProperties I think they need to be fixed in their respective meta schemas in the specific plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants