question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make `inputs` required

See original GitHub issue

If 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 accepted
  • description (required) text used for visual displays in CLI/UI to help users input/find/validate values
  • when (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:closed
  • Created 4 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
erquhartcommented, Mar 13, 2020

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.

1reaction
erquhartcommented, Mar 13, 2020

It will be breaking, but agreed that it doesn’t seem to be in use for current plugins.

We should also add:

  • select: JSON type string, HTML <select>

Nice to haves (not in scope for beta):

  • select: JSON type string or array (for multi-select), HTML <select>

Also noticed that the original spec has a displayName - my label proposal would replace that.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found