@putout/engine-loader 13.1.1 → 15.0.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 CHANGED
@@ -53,7 +53,7 @@ So when someone using your plugin, he needs to enable it:
53
53
 
54
54
  ## Env Variables
55
55
 
56
- When you need to get things working with Yarn PnP, and using custom `plugins` `formatters` or `processors`, add env variable
56
+ When you need to get things working with Yarn OnP, and using custom `plugins` `formatters` or `processors`, add env variable
57
57
  `PUTOUT_YARN_PNP` with name of a package that contains dependencies you need.
58
58
 
59
59
  ## API
@@ -197,6 +197,24 @@ await loadProcess('json', () => {
197
197
  });
198
198
  ```
199
199
 
200
+ ### validateRules
201
+
202
+ ```js
203
+ const {validateRules} = require('@putout/engine-loader');
204
+
205
+ const pluginNames = [];
206
+ const rules = {
207
+ 'remove-unused-variables': 'on',
208
+ };
209
+
210
+ validateRules({
211
+ pluginNames,
212
+ rules,
213
+ });
214
+
215
+ // throws since there is no plugin name passed that matches rule 'remove-unused-variables'
216
+ ```
217
+
200
218
  ## License
201
219
 
202
220
  MIT
package/lib/index.js CHANGED
@@ -42,6 +42,18 @@ module.exports.loadProcessorsAsync = async (options, load) => {
42
42
 
43
43
  module.exports.createAsyncLoader = createAsyncLoader;
44
44
 
45
+ module.exports.validateRules = (options) => {
46
+ check(options);
47
+
48
+ const {pluginNames = [], rules = {}} = options;
49
+ const items = parsePluginNames(pluginNames);
50
+
51
+ validateRules({
52
+ rules,
53
+ items,
54
+ });
55
+ };
56
+
45
57
  module.exports.loadPlugins = (options) => {
46
58
  check(options);
47
59
 
@@ -51,17 +63,11 @@ module.exports.loadPlugins = (options) => {
51
63
  const loadedRules = getLoadedRules(cookedRules);
52
64
 
53
65
  const items = parsePluginNames(pluginNames);
54
-
55
66
  const plugins = loadPlugins({
56
67
  items,
57
68
  loadedRules,
58
69
  });
59
70
 
60
- validateRules({
61
- rules,
62
- items,
63
- });
64
-
65
71
  return filterEnabledPlugins({
66
72
  plugins,
67
73
  cookedRules,
@@ -124,4 +130,3 @@ function extendRules(rule, plugin) {
124
130
 
125
131
  return result;
126
132
  }
127
-
package/lib/load/load.js CHANGED
@@ -17,12 +17,14 @@ const load = (type) => ({name, namespace}) => {
17
17
 
18
18
  const [error, result] = tryCatch(customRequire, pluginPath);
19
19
 
20
+ /* c8 ignore start */
20
21
  if (error?.code === 'ERR_REQUIRE_ESM')
21
22
  assign(error, {
22
23
  message: `☝️ Looks like '${name}' is ESM, use 'await putoutAsync()' instead`,
23
24
  name,
24
25
  });
25
26
 
27
+ /* c8 ignore end */
26
28
  if (error)
27
29
  throw error;
28
30
 
@@ -4,7 +4,6 @@ const {basename} = require('node:path');
4
4
 
5
5
  const {
6
6
  parseRules,
7
- validateRules,
8
7
  isEnabled,
9
8
  getLoadedRules,
10
9
  } = require('../rules');
@@ -32,11 +31,6 @@ module.exports.loadPluginsAsync = async (options) => {
32
31
  loadedRules,
33
32
  });
34
33
 
35
- validateRules({
36
- rules,
37
- items,
38
- });
39
-
40
34
  return filterEnabledPlugins({
41
35
  plugins,
42
36
  cookedRules,
@@ -29,13 +29,13 @@ module.exports.validateRules = ({items, rules}) => {
29
29
  isWithSlash = parsedPluginName === parseSlashes(rule);
30
30
 
31
31
  if (isName && plugin.rules)
32
- throw Error(`Rule "${rule}" cannot be applied to nested plugin "${pluginName}"`);
32
+ throw Error(`Rule '${rule}' cannot be applied to nested plugin '${pluginName}'`);
33
33
 
34
34
  if (isName || isWithSlash)
35
35
  break;
36
36
  }
37
37
 
38
38
  if (!isName && !isWithSlash)
39
- throw Error(`No plugin found for a rule: "${rule}"`);
39
+ throw Error(`No plugin found for a rule: '${rule}'`);
40
40
  }
41
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/engine-loader",
3
- "version": "13.1.1",
3
+ "version": "15.0.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",
@@ -11,7 +11,7 @@
11
11
  "changelog": false,
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "git://github.com/coderaiser/putout.git"
14
+ "url": "git+https://github.com/coderaiser/putout.git"
15
15
  },
16
16
  "scripts": {
17
17
  "test": "madrun test",
@@ -24,7 +24,7 @@
24
24
  "report": "madrun report"
25
25
  },
26
26
  "dependencies": {
27
- "@putout/engine-parser": "^10.0.0",
27
+ "@putout/engine-parser": "^11.0.0",
28
28
  "diff-match-patch": "^1.0.4",
29
29
  "nano-memoize": "^3.0.11",
30
30
  "once": "^1.4.0",
@@ -50,9 +50,9 @@
50
50
  "c8": "^10.0.0",
51
51
  "eslint": "^9.0.0",
52
52
  "eslint-plugin-n": "^17.0.0",
53
- "eslint-plugin-putout": "^22.0.0",
53
+ "eslint-plugin-putout": "^23.0.0",
54
54
  "estrace": "*",
55
- "just-camel-case": "^4.0.2",
55
+ "just-camel-case": "^6.2.0",
56
56
  "lerna": "^6.0.1",
57
57
  "madrun": "^10.0.0",
58
58
  "mock-require": "^3.0.3",