checkupjs / checkup

A health checkup for your project.
https://checkupjs.github.io/
MIT License
77 stars 23 forks source link

Simplifies plugin task/action registration to better match other OSS tools #1239

Closed scalvert closed 2 years ago

scalvert commented 2 years ago

The current mechanism used to register both tasks and actions unnecessarily leaks internal API details to plugins. The requirement for users to register tasks by instantiating them directly and for plugins to absorb repetitive boilerplate code that can be better internalized when plugins are read.

As such, this PR simplifies the plugin registration to an object literal with the following structure:

import FooTask from './tasks/foo-task.js';
import { evaluateActions as evaluateFooActions } from './actions/foo-actions.js';

export default {
  tasks: {
    'foo': FooTask,
  },

  actions: {
    'foo': evaluateFooActions,
  }
};

The above means that you simply need to import a task/action, and re-export it in the object literal format provided.