@putout/plugin-putout 25.4.0 → 25.6.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.
@@ -1,6 +1,17 @@
1
- import {operator} from 'putout';
1
+ import {operator, types} from 'putout';
2
+ import toSnakeCase from 'just-snake-case';
3
+
4
+ const {
5
+ arrayExpression,
6
+ isObjectExpression,
7
+ isStringLiteral,
8
+ isTemplateLiteral,
9
+ stringLiteral,
10
+ isArrayExpression,
11
+ } = types;
2
12
 
3
13
  const {compare} = operator;
14
+
4
15
  const TYPES = {
5
16
  noReport: 'noReportWithOptions',
6
17
  report: 'noReport',
@@ -22,9 +33,37 @@ export const report = (path) => {
22
33
  export const exclude = () => [
23
34
  't.noReport(__a, __array)',
24
35
  ];
36
+
37
+ export const match = () => ({
38
+ 't.noReport(__a, __b)': ({__b}) => {
39
+ if (isStringLiteral(__b))
40
+ return true;
41
+
42
+ if (isTemplateLiteral(__b))
43
+ return true;
44
+
45
+ return isObjectExpression(__b);
46
+ },
47
+ });
25
48
  export const replace = () => ({
26
- 't.noReport(__a, __object)': 't.noReportWithOptions(__a, __object)',
27
- 't.noReport(__a, __b)': 't.noReport(__a)',
49
+ 't.noReport(__a, "__b")': 't.noReport(__a)',
50
+ 't.noReport(__a, __b)': ({__b}, path) => {
51
+ if (!isObjectExpression(__b))
52
+ return 't.noReport(__a)';
53
+
54
+ const {value} = __b.properties[0];
55
+
56
+ if (isArrayExpression(value))
57
+ return 't.noReportWithOptions(__a, __b)';
58
+
59
+ const name = toSnakeCase(value.name);
60
+
61
+ path.node.arguments[1] = arrayExpression([
62
+ arrayExpression([stringLiteral(name), value]),
63
+ ]);
64
+
65
+ return path;
66
+ },
28
67
  't.report(__a)': 't.noReport(__a)',
29
68
  't.noReportWithOptions(__a)': 't.noReport(__a)',
30
69
  't.noReportWithOptions(__a, __b, __c)': 't.noReportWithOptions(__a, __c)',
@@ -61,6 +61,9 @@ export const traverse = ({push}) => ({
61
61
 
62
62
  const {init} = bindingNode;
63
63
 
64
+ if (compare(init, '__a.getPrevSibling()'))
65
+ return false;
66
+
64
67
  push({
65
68
  init,
66
69
  path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-putout",
3
- "version": "25.4.0",
3
+ "version": "25.6.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with plugins development",
@@ -33,6 +33,7 @@
33
33
  "dependencies": {
34
34
  "fullstore": "^3.0.0",
35
35
  "just-camel-case": "^6.2.0",
36
+ "just-snake-case": "^3.2.0",
36
37
  "try-catch": "^3.0.0"
37
38
  },
38
39
  "keywords": [
@@ -49,7 +50,7 @@
49
50
  "chalk": "^5.3.0",
50
51
  "eslint": "^9.0.0",
51
52
  "eslint-plugin-n": "^17.0.0",
52
- "eslint-plugin-putout": "^26.0.0",
53
+ "eslint-plugin-putout": "^27.0.0",
53
54
  "madrun": "^11.0.0",
54
55
  "montag": "^1.2.1",
55
56
  "nodemon": "^3.0.1",