-
Notifications
You must be signed in to change notification settings - Fork 2
Update types for upcoming changes #22
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,14 +18,54 @@ const { socketYmlSchemaV1 } = require('./lib/v1') | |
* @property {boolean} [authenticatedProjectReports] enable/disable authenticated project report URLs | ||
*/ | ||
|
||
/** | ||
* Configures how an issue should be handled by a given layer of configuration. | ||
* - "defer" will cause the issue to bubble up to a higher layer. E.G. socket.yml may defer to organization settings. This acts as if the value is unset. | ||
* - "error" will cause an alert to be shown and require some kind of interaction/setting and will block usage if it is encountered. The interaction may be a prompt, a PR comment, etc. | ||
* - "warn" will cause an alert to be shown but will not require any interaction/setting and will not block usage if it is encountered. | ||
* - "ignore" will cause an issue to not be shown and not require any interaction/setting and will not block usage if it is encountered. | ||
* | ||
* @typedef {'defer' | 'error' | 'warn' | 'ignore'} SocketIssueRuleAction | ||
*/ | ||
|
||
/** | ||
* @typedef SocketIssueRuleObject | ||
* @property {SocketIssueRuleAction} [action] | ||
*/ | ||
|
||
/** | ||
* @typedef {boolean | SocketIssueRuleObject} SocketIssueRuleValue | ||
*/ | ||
|
||
/** | ||
* @typedef SocketYml | ||
* @property {2} version | ||
* @property {string[]} projectIgnorePaths | ||
* @property {{ [issueName: string]: boolean }} issueRules | ||
* @property {{ [issueName: string]: SocketIssueRuleValue }} issueRules | ||
* @property {SocketYmlGitHub} githubApp | ||
*/ | ||
|
||
/** @type {import('ajv').JSONSchemaType<SocketIssueRuleValue>} */ | ||
const socketYmlIssueRule = { | ||
anyOf: [ | ||
{ | ||
type: 'boolean', | ||
default: false | ||
}, | ||
{ | ||
type: 'object', | ||
properties: { | ||
action: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the plan to add more properties to this? |
||
type: 'string', | ||
enum: ['defer', 'error', 'warn', 'ignore'], | ||
// note: ajv does not allow this enum to be `null`, this is due to anyOf | ||
nullable: true | ||
} | ||
} | ||
} | ||
] | ||
} | ||
|
||
/** @type {import('ajv').JSONSchemaType<SocketYml>} */ | ||
const socketYmlSchema = { | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
|
@@ -40,7 +80,7 @@ const socketYmlSchema = { | |
issueRules: { | ||
type: 'object', | ||
required: [], | ||
additionalProperties: { type: 'boolean' }, | ||
additionalProperties: socketYmlIssueRule, | ||
default: {} | ||
}, | ||
githubApp: { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A few thoughts after mulling over it. Curious what your thoughts are:
Did you consider something more like
Just thinking
Is easier to remember than
If we have plans for additional keys, maybe the object makes sense. Do we have an idea what those would be and how they would be used?
The other thought I had was what was the purpose of the
defer
rule action?error
andwarn
take the place oftrue
,ignore
is a synonym forfalse
. But omitting a rule is implicitly adefer
. Does it enable some kind of new functionality or just serve the role of explicitly defining that behavior?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.
We definitely should look at telemetry and role based prompting here which is why I'm not keen on a string, if we do a string now it would be more breaking in the future.
defer
is to allow explicit saving of that so that the behavior is recorded and not changed. Some UI toggling for example oftrue
/false
with a checkbox cannot represent this currently and has an implicit (very hard to understand) 3rd state that is like defer going on right now.