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

Add "minimum: 0" to "integer" options in schema #4941

Closed
alberto opened this Issue Jan 13, 2016 · 10 comments

Comments

Projects
None yet
4 participants
@alberto
Copy link
Member

alberto commented Jan 13, 2016

Options taking an integer value only make sense with values >= 0 AFAIK, so I think we should add "minimum": 0 to their schema.

Here are the rules that use "type": "integer":

complexity
indent
max-depth
max-len
max-nested-callbacks
max-params
max-statements
no-multiple-empty-lines

@alberto alberto changed the title Update: Add "minimum: 0" to "integer" options in schema Add "minimum: 0" to "integer" options in schema Jan 13, 2016

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Jan 13, 2016

You're saying to go through an update each rule's schema to have this?

@alberto

This comment has been minimized.

Copy link
Member Author

alberto commented Jan 13, 2016

I'm sorry, I'm not sure I understand the question.

I'm proposing to replace the ocurrences in the schemas of those rules from:

{
    "type": "integer"
}

to

{
    "type": "integer",
    "minimum": 0
}
@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Jan 13, 2016

Yeah, that's what I meant (wrote "an" instead of "and"). You want to update each rule's schema as opposed to making some central change so all schemas automatically are changed?

@nzakas nzakas added accepted and removed evaluating labels Jan 13, 2016

@nzakas

This comment has been minimized.

Copy link
Member

nzakas commented Jan 13, 2016

Any way, I think that's a good idea. The more specific we can be, the better.

@alberto

This comment has been minimized.

Copy link
Member Author

alberto commented Jan 13, 2016

I don't know of a better way to do it. :)

Also, I'm not totally sure if we will ever need negative integers, so I wouldn't force it anyway.

I actually found there is a positiveInteger definition in json-schema-schema.json which is exactly that, but I don't know if (and how) it could be used. I tried using {"type": "positiveInteger"} in a schema but that didn't work.

@gyandeeps

This comment has been minimized.

Copy link
Member

gyandeeps commented Jan 13, 2016

@alberto

This comment has been minimized.

Copy link
Member Author

alberto commented Jan 13, 2016

Should we force any of the values to be at least 1? Or do we want to play safe here, just in case?

I think some candidates would be:

max-statements
max-length
indent
complexity
@alberto

This comment has been minimized.

Copy link
Member Author

alberto commented Jan 13, 2016

@gyandeeps does that mean that positiveInteger is not meant to be used within the rule schema, or just that I am doing it wrong? :)

@gyandeeps

This comment has been minimized.

Copy link
Member

gyandeeps commented Jan 13, 2016

I dont think you can use that as a type. But @btmills is the expert on this.

@btmills

This comment has been minimized.

Copy link
Member

btmills commented Jan 14, 2016

@alberto in json-schema-schema.json, positiveInteger is a custom definition that gets reused elsewhere in the schema; it's not something that's publicly available.

ilyavolodin added a commit that referenced this issue Jan 14, 2016

Merge pull request #4945 from eslint/issue4941
Update: Add minimum value to integer values in schema (fixes #4941)

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.