Make `inputs` required
See original GitHub issueIf a plugin is using config values a.k.a inputs the plugin author must define the name, types, a description of the fields, & a when property. This will help ensure plugins self-document & give us a clear path forward for a world-class DX.
Required input
fields
The soon to be renamed config key a.k.a inputs
should have these required fields.
type
(required) Type of input accepteddescription
(required) text used for visual displays in CLI/UI to help users input/find/validate valueswhen
(required) When specifies when the configuration value is needed & where it will be used
Below is an example. The full API spec is outlined here
function netlifyPlugin(config) {
return {
name: 'netlify-plugin-example',
inputs: {
foo: {
/* Type of input accepted */
type: 'string',
/* text used for visual displays in CLI/UI to help users input/find/validate values */
description: 'Number required for service to function',
/* When specifies when the configuration value is needed & where it will be used */
when: 'onInit',
},
},
/* Lifecycle methods */
onInit: async ({ pluginConfig }) => {
console.log(pluginConfig.foo)
},
}
}
DX
It would be a cool bonus if we warn plugin authors if they are trying to access values from pluginConfig
that have not been defined yet. Perhaps via JS proxy
Rollout
Rolling this out will be a breaking change for most plugins that have been written, we will need to coordinate & update everything we have the control to update to accommodate these new required fields.
Related issues:
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
HTML input required Attribute - W3Schools
The required attribute is a boolean attribute. When present, it specifies that an input field must be filled out before submitting the form....
Read more >HTML attribute: required - HTML: HyperText Markup Language
The Boolean required attribute, if present, indicates that the user must specify a value for the input before the owning form can be ......
Read more >HTML | <input> required Attribute - GeeksforGeeks
The HTML required Attribute is a Boolean attribute which is used to specify that the input element must be filled out before submitting...
Read more >3 Examples of HTML Required Attribute - eduCBA
1. <input> Attribute: Required Field ... To mark a field as simple is to add the “required “attribute into the input element. The...
Read more >Required HTML For Input Required: Get The Code Now »
Attribute of: How To Use Input To Create Form Fields In HTML: Easy Tutorial ... Specifies that the input field is required; disallows...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ironically, considering the title of the issue, note that my previous example shows
inputs
as optional. This is because a plugin could conceivably run without inputs, so optional would seem the natural choice. The goal of this issue is to ensure that user inputs can’t be accessed by the plugin without being properly defined - we accomplish that by only passing defined inputs to the plugin.It will be breaking, but agreed that it doesn’t seem to be in use for current plugins.
We should also add:
select
: JSON typestring
, HTML<select>
Nice to haves (not in scope for beta):
select
: JSON typestring
orarray
(for multi-select), HTML<select>
Also noticed that the original spec has a
displayName
- mylabel
proposal would replace that.