@putout/plugin-nodejs 7.2.0 → 8.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
@@ -5,7 +5,7 @@
5
5
 
6
6
  > **Node.js** is an open-source, cross-platform, **JavaScript** runtime environment.
7
7
  >
8
- > (c) [nodejs.org](https://nodejs.org/en/)
8
+ > (c) [Nodejs.org](https://nodejs.org/en/)
9
9
 
10
10
  🐊[**Putout**](https://github.com/coderaiser/putout) plugin adds ability to transform to new **Node.js** API and apply best practices.
11
11
 
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const {operator} = require('putout');
4
+ const {compute} = operator;
4
5
 
5
6
  const isNumber = (a) => typeof a === 'number';
6
7
 
7
- const {compute} = operator;
8
-
9
8
  module.exports.report = () => `Use 'Buffer.alloc()' or 'Buffer.from()' instead of 'Buffer()' and 'new Buffer()'`;
10
9
 
11
10
  module.exports.match = () => ({
@@ -19,14 +18,18 @@ module.exports.match = () => ({
19
18
 
20
19
  module.exports.replace = () => ({
21
20
  'new Buffer(__a)': transform,
21
+ 'new Buffer(__a, __b)': transform,
22
22
  'Buffer(__a)': transform,
23
23
  });
24
24
 
25
- function transform(vars, path) {
25
+ function transform({__b}, path) {
26
26
  const [, value] = compute(path.get('arguments.0'));
27
27
 
28
28
  if (isNumber(value))
29
29
  return 'Buffer.alloc(__a)';
30
30
 
31
+ if (__b)
32
+ return 'Buffer.from(__a, __b)';
33
+
31
34
  return 'Buffer.from(__a)';
32
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "7.2.0",
3
+ "version": "8.0.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code to new API of Node.js",
@@ -38,14 +38,14 @@
38
38
  "c8": "^8.0.0",
39
39
  "eslint": "^8.0.1",
40
40
  "eslint-plugin-n": "^16.0.0",
41
- "eslint-plugin-putout": "^19.0.0",
41
+ "eslint-plugin-putout": "^20.0.0",
42
42
  "lerna": "^6.0.1",
43
43
  "madrun": "^9.0.0",
44
44
  "montag": "^1.2.1",
45
45
  "nodemon": "^3.0.1"
46
46
  },
47
47
  "peerDependencies": {
48
- "putout": ">=31"
48
+ "putout": ">=32"
49
49
  },
50
50
  "license": "MIT",
51
51
  "engines": {