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

wrongly transformed array of string #584

Closed
eMerzh opened this issue Mar 21, 2024 · 6 comments
Closed

wrongly transformed array of string #584

eMerzh opened this issue Mar 21, 2024 · 6 comments

Comments

@eMerzh
Copy link

eMerzh commented Mar 21, 2024

hello ...
i found an issue eslint-types/eslint-define-config that i think comes from the transformation of the jsonschema to typescript

this schema:

https://github.com/eslint/eslint/blob/b91f9dc072f17f5ea79803deb86cf002d031b4cf/lib/rules/camelcase.js#L30

is transformed

to

{
  ignoreDestructuring?: boolean
  ignoreImports?: boolean
  ignoreGlobals?: boolean
  properties?: "always" | "never"
  allow?: [] | [string]
}

the issue is allow should be string[] instead of [string]

@gkssf
Copy link

gkssf commented Mar 26, 2024

The generated code makes sense to me since you have provided items as an array: [{ type: "string" }] and not as an object { type: "string" }. It literally assumes that your first element should be of type string.

@eMerzh
Copy link
Author

eMerzh commented Mar 26, 2024

as i understand it should be an array of string , not super familiair with json schema, but how is it supposed to be ?

@Shinigami92
Copy link

as i understand it should be an array of string , not super familiair with json schema, but how is it supposed to be ?

I think they want to tell you that the issue is in eslint, not in json-schema

@eMerzh
Copy link
Author

eMerzh commented Mar 26, 2024

hehe, i got the hint @Shinigami92 :) ...

but if i look https://json-schema.org/understanding-json-schema/reference/array

What i understand (again, i'm a noob in jsonschema)

In the following example, we define that each item in an array is a number:

  "type": "array",
  "items": {
    "type": "number"
  }
}
[1, 2, 3, 4, 5]

This let me think that

  "type": "array",
  "items": {
    "type": "string"
  }
}

should allow

["one", "two", "three"]

No ?
if no (which is possible), can you help me find how is it supposed to look ?

@Shinigami92
Copy link

items: [{type:'string'}] != items: {type:'string'}

@eMerzh
Copy link
Author

eMerzh commented Mar 26, 2024

oook :) thanks... let's go open a Pr there :)

@eMerzh eMerzh closed this as completed Mar 26, 2024
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

3 participants