@putout/plugin-putout 8.8.1 → 8.12.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
@@ -37,6 +37,7 @@ npm i @putout/plugin-putout -D
37
37
  "putout/shorten-imports": "on",
38
38
  "putout/check-replace-code": "on",
39
39
  "putout/declare": "on",
40
+ "putout/includer": "on",
40
41
  "putout/move-require-on-top-level": "on"
41
42
  }
42
43
  }
@@ -497,6 +498,34 @@ test('remove debugger: report', (t) => {
497
498
  });
498
499
  ```
499
500
 
501
+ ## includer
502
+
503
+ ### ❌ Incorrect code example
504
+
505
+ ```js
506
+ module.exports.include = () => 'cons __a = __b';
507
+ module.exports.exclude = () => 'var __a = __b';
508
+
509
+ module.exports.include = 'cons __a = __b';
510
+ module.exports.exclude = 'var __a = __b';
511
+
512
+ module.exports.include = ['cons __a = __b'];
513
+ module.exports.exclude = ['var __a = __b'];
514
+ ```
515
+
516
+ ### ✅ Correct code Example
517
+
518
+ ```js
519
+ module.exports.include = () => ['cons __a = __b'];
520
+ module.exports.exclude = () => ['var __a = __b'];
521
+
522
+ module.exports.include = () => ['cons __a = __b'];
523
+ module.exports.exclude = () => ['var __a = __b'];
524
+
525
+ module.exports.include = () => ['cons __a = __b'];
526
+ module.exports.exclude = () => ['var __a = __b'];
527
+ ```
528
+
500
529
  ## License
501
530
 
502
531
  MIT
@@ -5,12 +5,8 @@ const {compare} = require('putout').operator;
5
5
  module.exports.report = () => 'Identifier should be used instead of empty destructuring';
6
6
 
7
7
  module.exports.match = () => ({
8
- '({}) => __body': (vars, path) => {
9
- return findUp(path, 'module.exports.__a = __');
10
- },
11
- '({}, __a) => __body': (vars, path) => {
12
- return findUp(path, 'module.exports.__a = __');
13
- },
8
+ '({}) => __body': (vars, path) => findUp(path, 'module.exports.__a = __'),
9
+ '({}, __a) => __body': (vars, path) => findUp(path, 'module.exports.__a = __'),
14
10
  });
15
11
 
16
12
  module.exports.replace = () => ({
@@ -6,9 +6,7 @@ const {isESM} = operator;
6
6
  module.exports.report = () => `Use 'createTest(import.meta.url)' instead of 'createTest(__dirname)'`;
7
7
 
8
8
  module.exports.match = () => ({
9
- 'createTest(__dirname, __a)': (vars, path) => {
10
- return isESM(path);
11
- },
9
+ 'createTest(__dirname, __a)': (vars, path) => isESM(path),
12
10
  });
13
11
 
14
12
  module.exports.replace = () => ({
@@ -3,12 +3,16 @@
3
3
  module.exports = {
4
4
  operator: `import {operator} from 'putout'`,
5
5
  compare: `const {compare} = operator`,
6
+ compareAll: `const {compareAll} = operator`,
7
+ compareAny: `const {compareAny} = operator`,
6
8
  contains: `const {contains} = operator`,
7
9
  traverse: `const {traverse} = operator`,
8
10
  declare: `const {declare} = operator`,
9
11
  isSimpleRegExp: `const {isSimpleRegExp} = operator`,
10
12
  getTemplateValues: `const {getTemplateValues} = operator`,
11
13
  addArgument: `const {addArgument} = operator`,
12
- replaceWith: `const {replaceWith} = opreator`,
14
+ replaceWith: `const {replaceWith} = operator`,
15
+ replaceWithMultiple: `const {replaceWithMultiple} = operator`,
16
+ findProperties: `const {findProperties} = operator`,
13
17
  };
14
18
 
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ module.exports.report = () => 'Includer functions should return array (https://git.io/Jyndl)';
4
+
5
+ module.exports.replace = () => ({
6
+ 'module.exports.include = () => "__a"': 'module.exports.include = ["__a"]',
7
+ 'module.exports.exclude = () => "__a"': 'module.exports.exclude = ["__a"]',
8
+
9
+ 'module.exports.include = ["__a"]': 'module.exports.include = () => ["__a"]',
10
+ 'module.exports.exclude = ["__a"]': 'module.exports.exclude = () => ["__a"]',
11
+
12
+ 'module.exports.include = "__a"': 'module.exports.include = ["__a"]',
13
+ 'module.exports.exclude = "__a"': 'module.exports.exclude= ["__a"]',
14
+ });
package/lib/index.js CHANGED
@@ -30,5 +30,6 @@ module.exports.rules = {
30
30
  ...getRule('declare'),
31
31
  ...getRule('add-args'),
32
32
  ...getRule('move-require-on-top-level'),
33
+ ...getRule('includer'),
33
34
  };
34
35
 
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "8.8.1",
3
+ "version": "8.12.0",
4
+ "type": "commonjs",
4
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
6
  "description": "putout plugin helps with plugins development",
6
- "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout",
7
+ "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-putout#readme",
7
8
  "main": "lib/index.js",
8
9
  "release": false,
9
10
  "tag": false,