Skip to content

treatwell/eslint-plugin-moleculer

eslint-plugin-moleculer

npm

This plugin intends to add eslint rules in your moleculer project when using the @treatwell/moleculer-essentials and @treatwell/moleculer-call-wrapper packages.

Installation

Install eslint-plugin-moleculer with your package manager:

  yarn add -D @treatwell/eslint-plugin-moleculer

ESLint Flat config (v9+)

Import the recommended config in your eslint config file (assuming you are using TS eslint):

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import moleculer from '@treatwell/eslint-plugin-moleculer';

export default tseslint.config(
  eslint.configs.recommended,
  tseslint.configs.recommended,
  moleculer.configs.recommended,
);

ESLint legacy config

Enable the plugin in your eslint config and add the rules you want to enforce:

module.exports = {
  // ... rest of the config
  plugins: [
    // ... other plugins
    '@treatwell/eslint-plugin-moleculer',
  ],
  rules: {
    // ... other rules
    '@treatwell/moleculer/service-property-order': 'error',
    '@treatwell/moleculer/no-published-workers': 'error',
  },
};

Rules

Rule Description
@treatwell/moleculer/service-property-order Enforce the order of service properties in Moleculer services in order to make TS types defined by @treatwell/moleculer-essentials work properly.
@treatwell/moleculer/no-published-workers Disallow publishing actions on services where the QueueWorker mixin is setup. Note that it doesn't catch all the cases (e.g. if actions are defined in mixins)

License

MIT

About

Eslint plugin for the moleculer framework

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published