-
Notifications
You must be signed in to change notification settings - Fork 14
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
style(specs): add out-of-line-one-of rule (and allOf and anyOf) APIC-418 #512
Conversation
✅ Deploy Preview for api-clients-automation canceled.
|
✗ The generated branch has been deleted.If the PR has been merged, you can check the generated code on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice
eslint/src/index.ts
Outdated
'out-of-line-enum': outOfLineEnum, | ||
'out-of-line-one-of': outOfLineOneOf, | ||
'out-of-line-all-of': outOfLineAllOf, | ||
'out-of-line-any-of': outOfLineAnyOf, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it works but maybe we can remove the extra outOfLineXXX
files to call the createOutOfLineRule
here, I feel like it would be easier to understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create one rule that handle all of them ? It's easier to do it that way, and very flexible, maybe we want do disable it for anyOf
at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sorry I meant that since those function just make a call with a different parameter, maybe we could have
'out-of-line-enum': outOfLineEnum, | |
'out-of-line-one-of': outOfLineOneOf, | |
'out-of-line-all-of': outOfLineAllOf, | |
'out-of-line-any-of': outOfLineAnyOf, | |
'out-of-line-enum': createOutOfLineRule({ property: 'enum' }), | |
'out-of-line-one-of': createOutOfLineRule({ property: 'oneOf' }), | |
'out-of-line-all-of': createOutOfLineRule({ property: 'allOf' }), | |
'out-of-line-any-of': createOutOfLineRule({ property: 'anyOf' }), |
So we don't have to go to an empty file :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this is possible ?
those functions are ts, here it's js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this is possible ?
We return a const so I'd assume it does yes
those functions are ts, here it's js
The index
is a ts file too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I did not tried locally I just guessed D: )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the index.ts file is transpiled in js and used as a package, not imported directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep but in the end this object will hold a rule value, I mean I don't see why it wouldn't work the same way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I though you were talking about the .eslintrc.js
file sorry all my comments makes no sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no prob!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could rename the test file eslint/tests/outOfLineEnum.test.ts
to eslint/tests/createOutOfLineRule.test.ts
and test each case we support in it
eslint/src/rules/outOfLineRule.ts
Outdated
export function createOutOfLineRule({ | ||
property, | ||
description = `${property} must be out of line, not nested inside properties`, | ||
messageId = `${property}OutOfLine`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageId = `${property}OutOfLine`, | |
messageId = `${property}NotOutOfLine`, |
Shouldn't it be that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know, should the message tell you what's expected or what happened ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just based my comment on what's existing and tested
I believe since the message is must be out of line
, the error thrown should be that it's notOutOfLine
but up to you!
(Spammer) I realized the tests are not ran in this PR, we should update the run condition of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!!
🧭 What and Why
🎟 JIRA Ticket: APIC-418
Reuse the logic of the
out-of-line-enum
rule to create rules foroneOf, allOf, anyOf
.The specs already complied with this rule.
🧪 Test
CI