eslint-plugin-wolkenkit v1.0.0
eslint-plugin-wolkenkit
eslint-plugin-wolkenkit is a set of rules for ESLint.
Table of contents
Installation
$ npm install eslint-plugin-wolkenkitQuick start
First you need to add eslint-plugin-wolkenkit as a plugin to your ESLint configuration file. To improve readability you can skip the eslint-plugin- prefix.
{
"plugins": [
"wolkenkit"
]
}Then you need to configure the rules that you want to use as shown in the following example.
{
"rules": {
"wolkenkit/aggregate-commands": 2,
"wolkenkit/aggregate-commands-mark": 2,
"wolkenkit/aggregate-commands-parameters": 2,
"wolkenkit/aggregate-events": 2,
"wolkenkit/aggregate-exports": 2,
"wolkenkit/aggregate-initialstate": 2,
"wolkenkit/aggregate-order": 2,
"wolkenkit/flow-exports": 2,
"wolkenkit/flow-identity": 2,
"wolkenkit/flow-identity-parameters": 2,
"wolkenkit/flow-initialState": 2,
"wolkenkit/flow-order": 2,
"wolkenkit/flow-transitions": 2,
"wolkenkit/flow-transitions-parameters": 2,
"wolkenkit/flow-when": 2,
"wolkenkit/flow-when-mark": 2,
"wolkenkit/flow-when-parameters": 2,
"wolkenkit/list-exports": 2,
"wolkenkit/list-fields": 2,
"wolkenkit/list-order": 2,
"wolkenkit/list-when": 2,
"wolkenkit/list-when-mark": 2,
"wolkenkit/list-when-parameters": 2
}
}Alternatively, you may enable all recommended rules at once.
{
"extends": [
"plugin:wolkenkit/recommended"
]
}Using rules
Using rules for aggregates
An aggregate is a module that exports initialState, commands, and events.
const initialState = {};
const commands = {
mount (board, command, services, mark) {
// ...
}
};
const events = {};
module.exports = { initialState, commands, events };aggregate-commandsenforces thatcommandsis an object.aggregate-commands-markenforces command handlers to call a method of the mark parameter at the end of their code paths.aggregate-commands-parametersenforces that command handlers have a valid signature.aggregate-eventsenforces thateventsis an object.aggregate-exportsenforces that aggregates exportinitialState,commandsandevents.aggregate-initialstateenforces thatinitialStateis an object.aggregate-orderenforces the order ofinitialState,commands, andevents.
Using rules for flows
A flow is a module that exports when if stateless, and identity, initialState, transitions and when if stateful.
// stateless
const when = {
bar (event, mark) {},
baz (event, services, mark) {}
};
module.exports = { when };
// stateful
const identity = {
foo (event) {
// ...
}
};
const initialState = {};
const transitions = {
foo: {
bar (flow) {
// ...
}
}
};
const when = {
foo: {
bar (flow, event, mark) {},
baz (flow, event, services, mark) {}
}
};
module.exports = { identity, initialState, transitions, when };flow-exportsenforces that flows exportwhenif stateless andidentity,initialState,transitionsandwhenif stateful.flow-identityenforces thatidentityis an object.flow-identity-parametersenforces that identity handlers have a valid signature.flow-initialStateenforces thatinitialStateis an object.floe-orderenforces the order ofidentity,initialState,transitions, andwhen.flow-transitionsenforces thattransitionsis an object and contains objects.flow-transitions-parametersenforces that transition handlers have a valid signature.flow-whenenforces thatwhenis an object and contains objects.flow-when-markenforces when handlers to call a method of the mark parameter at the end of their code paths.flow-when-parametersenforces that when handlers have a valid signature.
Rules for lists
A list is a module that exports fields and when.
const fields = {};
const when = {
mounted (boards, event, services, mark) {
// ...
}
};
module.exports = { fields, when };list-exportsenforces that list exportsfieldsandwhen.list-fieldsenforces thatfieldsis an object.list-orderenforces the order offieldsandwhen.list-whenenforces thatwhenis an object.list-when-markenforces when handlers to call a method of the mark parameter at the end of their code paths.list-when-parametersenforces that when handlers have a valid signature.
Running the build
To build this module use roboter.
$ botLicense
Copyright (c) 2016-2017 the native web.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see GNU Licenses.
8 years ago