@putout/engine-loader 7.1.2 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -2
- package/lib/index.js +3 -3
- package/lib/is-enabled.js +6 -13
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
[NPMIMGURL]: https://img.shields.io/npm/v/@putout/engine-loader.svg?style=flat&longCache=true
|
|
4
4
|
[NPMURL]: https://npmjs.org/package/@putout/engine-loader"npm"
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
🐊[**Putout**](https://github.com/coderaiser/putout) loader for `plugins` and `processors`.
|
|
7
7
|
|
|
8
8
|
## Install
|
|
9
9
|
|
|
@@ -11,12 +11,33 @@ Load 🐊[**Putout**](https://github.com/coderaiser/putout) `Plugins` and `Proce
|
|
|
11
11
|
npm i @putout/engine-loader
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
## Plugins
|
|
15
|
+
|
|
16
|
+
Loader supports two kinds of plugins:
|
|
17
|
+
|
|
18
|
+
- ☝️ [**Onerule Plugin**](#simple-plugin)
|
|
19
|
+
- ☝️ [**Multirule Plugin**](#multirule-plugin)
|
|
20
|
+
|
|
21
|
+
### Onerule Plugin
|
|
22
|
+
|
|
23
|
+
Simplest type of plugin support by [`@putout/engine-runner`](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#supported-plugin-types), contains one rule.
|
|
24
|
+
|
|
25
|
+
### Multirule Plugin
|
|
26
|
+
|
|
27
|
+
Nested contains one or more rules:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
module.exports.rules = {
|
|
31
|
+
'remove-unused-variables': require('@putout/plugin-remove-unused-variables'),
|
|
32
|
+
};
|
|
33
|
+
```
|
|
34
|
+
|
|
14
35
|
## Env Variables
|
|
15
36
|
|
|
16
37
|
When you need to get things working with Yarn PnP, and using custom `plugins` `formatters` or `processers`, add env variable
|
|
17
38
|
`PUTOUT_YARN_PNP` with name of a package that contains dependencies you need.
|
|
18
39
|
|
|
19
|
-
##
|
|
40
|
+
## API
|
|
20
41
|
|
|
21
42
|
### loadPlugins
|
|
22
43
|
|
package/lib/index.js
CHANGED
|
@@ -93,11 +93,11 @@ module.exports.loadPlugins = (options) => {
|
|
|
93
93
|
// but we can't because of a way multi-rule plugins
|
|
94
94
|
// works. We can't determine count and names of all
|
|
95
95
|
// rules of a plugin before load.
|
|
96
|
-
for (const plugin of plugins) {
|
|
97
|
-
if (!isEnabled(
|
|
96
|
+
for (const [name, plugin] of plugins) {
|
|
97
|
+
if (!isEnabled(name, cookedRules))
|
|
98
98
|
continue;
|
|
99
99
|
|
|
100
|
-
result.push(mergeRules(plugin, cookedRules));
|
|
100
|
+
result.push(mergeRules([name, plugin], cookedRules));
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
return result;
|
package/lib/is-enabled.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const {isArray} = Array;
|
|
4
|
-
|
|
5
|
-
const isBool = (a) => typeof a === 'boolean';
|
|
6
|
-
|
|
7
3
|
module.exports = (name, rules) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return rules[name];
|
|
13
|
-
|
|
14
|
-
let resultState = true;
|
|
4
|
+
for (const {rule, state} of rules) {
|
|
5
|
+
if (rule === name)
|
|
6
|
+
return state;
|
|
7
|
+
}
|
|
15
8
|
|
|
16
9
|
for (const {rule, state} of rules) {
|
|
17
10
|
if (RegExp(`^${rule}`).test(name))
|
|
18
|
-
|
|
11
|
+
return state;
|
|
19
12
|
}
|
|
20
13
|
|
|
21
|
-
return
|
|
14
|
+
return true;
|
|
22
15
|
};
|
|
23
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/engine-loader",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "load plugins and prepare them to run",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"eslint-plugin-n": "^15.2.4",
|
|
54
54
|
"eslint-plugin-putout": "^16.0.0",
|
|
55
55
|
"estrace": "*",
|
|
56
|
+
"babel-plugin-angularjs-annotate": "https://github.com/putoutjs/babel-plugin-angularjs-annotate",
|
|
56
57
|
"just-camel-case": "^4.0.2",
|
|
57
58
|
"lerna": "^6.0.1",
|
|
58
59
|
"madrun": "^9.0.0",
|