@putout/plugin-putout 23.3.0 β 23.4.1
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 +1 -1
- package/lib/apply-vars/index.js +18 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -322,7 +322,7 @@ export const fix = (path) => {
|
|
|
322
322
|
|
|
323
323
|
## apply-vars
|
|
324
324
|
|
|
325
|
-
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/
|
|
325
|
+
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/6b1a4b5dc75f2591faf580774d23b38f/7278945371ceb76942494f7caf88375d2eaca869).
|
|
326
326
|
|
|
327
327
|
### β Example of incorrect code
|
|
328
328
|
|
package/lib/apply-vars/index.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const {operator} = require('putout');
|
|
4
|
+
const {compareAny} = operator;
|
|
5
|
+
|
|
6
|
+
module.exports.report = () => `Use 'vars' instead of '{}'`;
|
|
7
|
+
|
|
8
|
+
module.exports.match = () => ({
|
|
9
|
+
'({}, path) => __a': isInsideReplacer,
|
|
10
|
+
});
|
|
4
11
|
|
|
5
12
|
module.exports.replace = () => ({
|
|
6
|
-
'({}, path) =>
|
|
13
|
+
'({}, path) => __a': '(vars, path) => __a',
|
|
7
14
|
});
|
|
15
|
+
|
|
16
|
+
const isInsideReplacer = (vars, path) => {
|
|
17
|
+
return compareAny(path, [
|
|
18
|
+
'module.exports.match = __',
|
|
19
|
+
'module.exports.replace = __',
|
|
20
|
+
'export const match = __',
|
|
21
|
+
'export const replace = __',
|
|
22
|
+
]);
|
|
23
|
+
};
|
package/package.json
CHANGED