Skip to content

Add defaults to schema #258

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

Merged
merged 5 commits into from
Jun 11, 2019
Merged

Conversation

MrHen
Copy link
Contributor

@MrHen MrHen commented Jun 5, 2019

Fixes #214.

Honestly, I'm not sure this issue makes a lot of sense. There were only three rules I saw that had options at all:

  • assertion-arguments: Default is undefined. I added it explicitly but it seems kind of redundant.
  • max-asserts: Cannot use a default as per Use JSON schema default in rules #214 (comment). I'm not a big fan of non-object options anyway. I recommend converting from the numeric option to an object which would then pick up the default. This would be a breaking change, though. Alternatively, set the default in schema but also use the fallback in create.
  • test-title-format: Default is also undefined.

Am I missing something about this request? There was no Object.assign usage to replace.

@GMartigny
Copy link
Contributor

I opened an issue to eslint reporting this. It's working as designed for now. Either we complain to ajv to add this behavior or we "convert from the numeric option to an object which would then pick up the default" as you said.

@sindresorhus
Copy link
Member

sindresorhus commented Jun 10, 2019

Alternatively, set the default in schema but also use the fallback in create.

👍 With a TODO comment about removing the fallback in the next major version.

@MrHen
Copy link
Contributor Author

MrHen commented Jun 10, 2019

@sindresorhus I think I got it right this time? Although now I'm thinking I should just file an Issue for it and include a link in the TODO comment. 😛

@sindresorhus
Copy link
Member

Although now I'm thinking I should just file an Issue for it and include a link in the TODO comment.

👍

@sindresorhus sindresorhus merged commit 0856689 into avajs:master Jun 11, 2019
@sindresorhus
Copy link
Member

@MrHen Can you submit the PR URL here: https://issuehunt.io/r/avajs/eslint-plugin-ava/issues/214 ?

@MrHen MrHen deleted the feature/214-Defaults branch June 11, 2019 11:50
@MrHen
Copy link
Contributor Author

MrHen commented Jun 11, 2019

@sindresorhus Done. Sorry, I keep forgetting it isn't automatic.

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

Successfully merging this pull request may close these issues.

Use JSON schema default in rules
3 participants