This plugin intends to add eslint rules in your moleculer project
when using the @treatwell/moleculer-essentials
and @treatwell/moleculer-call-wrapper
packages.
Install eslint-plugin-moleculer
with your package manager:
yarn add -D @treatwell/eslint-plugin-moleculer
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,
);
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',
},
};
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) |