@@ -19,6 +19,7 @@ npm i putout @putout/plugin-nodejs -D
1919
2020- ✅ [ add-node-prefix] ( #add-node-prefix ) ;
2121- ✅ [ add-missing-strict-mode] ( #add-missing-strict-mode ) ;
22+ - ✅ [ apply-global-this] ( #apply-global-this ) ;
2223- ✅ [ convert-buffer-to-buffer-alloc] ( #convert-buffer-to-buffer-alloc ) ;
2324- ✅ [ convert-commonjs-to-esm] ( #convert-commonjs-to-esm ) ;
2425- ✅ [ convert-dirname-to-url] ( #convert-dirname-to-url ) ;
@@ -45,13 +46,15 @@ npm i putout @putout/plugin-nodejs -D
4546``` json
4647{
4748 "rules" : {
49+ "nodejs/add-missing-strict-mode" : " on" ,
50+ "nodejs/add-node-prefix" : " on" ,
51+ "nodejs/apply-global-this" : " off" ,
4852 "nodejs/convert-commonjs-to-esm" : " off" ,
4953 "nodejs/convert-esm-to-commonjs" : " off" ,
5054 "nodejs/cjs-file" : " off" ,
5155 "nodejs/mjs-file" : " off" ,
5256 "nodejs/rename-file-cjs-to-js" : " off" ,
5357 "nodejs/rename-file-mjs-to-js" : " off" ,
54- "nodejs/add-node-prefix" : " on" ,
5558 "nodejs/convert-buffer-to-buffer-alloc" : " on" ,
5659 "nodejs/convert-fs-promises" : " on" ,
5760 "nodejs/convert-promisify-to-fs-promises" : " on" ,
@@ -63,7 +66,6 @@ npm i putout @putout/plugin-nodejs -D
6366 "nodejs/declare-after-require" : " on" ,
6467 "nodejs/group-require-by-id" : " on" ,
6568 "nodejs/remove-process-exit" : " on" ,
66- "nodejs/add-missing-strict-mode" : " on" ,
6769 "nodejs/remove-useless-strict-mode" : " on" ,
6870 "nodejs/remove-illegal-strict-mode" : " on" ,
6971 "nodejs/remove-useless-promisify" : " on"
@@ -101,9 +103,36 @@ await import('node:path');
101103
102104Linter | Rule | Fix
103105--------|-------|------------|
104- 🐊 ** Putout** | [ ` apply -node-prefix` ] ( https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs/apply -node-prefix#readme ) | ✅
106+ 🐊 ** Putout** | [ ` add -node-prefix` ] ( https://github.com/coderaiser/putout/tree/master/packages/plugin-nodejs/add -node-prefix#readme ) | ✅
105107⏣ ** ESLint** | [ ` prefer-node-protocol ` ] ( https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/prefer-node-protocol.md#readme ) | ✅
106108
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+
107136## convert-buffer-to-buffer-alloc
108137
109138> The ` Buffer() ` function and ` new Buffer() ` constructor are ** deprecated** due to API usability issues that can lead to accidental security issues.
0 commit comments