@putout/plugin-nodejs 19.0.0 → 19.1.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
@@ -19,7 +19,6 @@ npm i putout @putout/plugin-nodejs -D
19
19
 
20
20
  - ✅ [add-node-prefix](#add-node-prefix);
21
21
  - ✅ [add-missing-strict-mode](#add-missing-strict-mode);
22
- - ✅ [apply-global-this](#apply-global-this);
23
22
  - ✅ [convert-buffer-to-buffer-alloc](#convert-buffer-to-buffer-alloc);
24
23
  - ✅ [convert-commonjs-to-esm](#convert-commonjs-to-esm);
25
24
  - ✅ [convert-dirname-to-url](#convert-dirname-to-url);
@@ -48,7 +47,6 @@ npm i putout @putout/plugin-nodejs -D
48
47
  "rules": {
49
48
  "nodejs/add-missing-strict-mode": "on",
50
49
  "nodejs/add-node-prefix": "on",
51
- "nodejs/apply-global-this": "off",
52
50
  "nodejs/convert-commonjs-to-esm": "off",
53
51
  "nodejs/convert-esm-to-commonjs": "off",
54
52
  "nodejs/cjs-file": "off",
@@ -106,33 +104,6 @@ Linter | Rule | Fix
106
104
  🐊 **Putout** | [`add-node-prefix`](https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs/add-node-prefix#readme) | ✅
107
105
  ⏣ **ESLint** | [`prefer-node-protocol`](https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/prefer-node-protocol.md#readme) | ✅
108
106
 
109
- ## apply-global-this
110
-
111
- > Legacy. Use `globalThis` instead.
112
- >
113
- > (c) [nodejs.org](https://nodejs.org/api/globals.html#global)
114
-
115
- Check out in 🐊[Putout Editor](https://putout.cloudcmd.io/#/gist/c72c8e1b1d0c2b45fd0d15d837dcae52/c7f33d77d19efe962339debbcf20f68bf2159aee).
116
-
117
- ### ❌ Example of incorrect code
118
-
119
- ```js
120
- global.__putout_debug = debugFn;
121
- ```
122
-
123
- ### ✅ Example of correct code
124
-
125
- ```js
126
- globalThis.__putout_debug = debugFn;
127
- ```
128
-
129
- ### Comparison
130
-
131
- Linter | Rule | Fix
132
- -------|------|------------|
133
- 🐊 **Putout** | [`apply-global-this`](https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs/apply-node-prefix#readme) | ✅
134
- ⏣ **ESLint** | [`no-node-globals`](https://docs.deno.com/lint/rules/no-node-globals/) | ❌
135
-
136
107
  ## convert-buffer-to-buffer-alloc
137
108
 
138
109
  > The `Buffer()` function and `new Buffer()` constructor are **deprecated** due to API usability issues that can lead to accidental security issues.
@@ -163,12 +163,13 @@ function addExportToBinding(name, path) {
163
163
  return exportNamedDeclaration(null, [exportSpecifier(imported, imported)]);
164
164
  }
165
165
 
166
- if (binding.references > 1)
167
- return '';
168
-
169
166
  if (isImportDefaultSpecifier(bindingPath)) {
167
+ if (binding.references > 1)
168
+ return '';
169
+
170
170
  const {local} = bindingPath.node;
171
171
  const {source} = bindingPath.parentPath.node;
172
+
172
173
  const specifiers = [
173
174
  exportNamespaceSpecifier(local),
174
175
  ];
package/lib/index.js CHANGED
@@ -1,4 +1,3 @@
1
- import * as applyGlobalThis from './apply-global-this/index.js';
2
1
  import * as convertBufferToBufferAlloc from './convert-buffer-to-buffer-alloc/index.js';
3
2
  import * as convertFsPromises from './convert-fs-promises/index.js';
4
3
  import * as convertPromisifyToFsPromises from './convert-promisify-to-fs-promises/index.js';
@@ -49,5 +48,4 @@ export const rules = {
49
48
  'remove-illegal-strict-mode': strictMode.rules['remove-illegal'],
50
49
  'remove-useless-promisify': removeUselessPromisify,
51
50
  'group-require-by-id': groupRequireById,
52
- 'apply-global-this': applyGlobalThis,
53
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-nodejs",
3
- "version": "19.0.0",
3
+ "version": "19.1.0",
4
4
  "type": "module",
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",
@@ -1,6 +0,0 @@
1
- export const report = () => `Use 'globalThis' instead of 'global'`;
2
-
3
- export const replace = () => ({
4
- 'global.__a': 'globalThis.__a',
5
- 'const __a = global': 'const __a = globalThis',
6
- });