@putout/plugin-printer 8.16.0 → 8.16.2

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
@@ -324,7 +324,7 @@ export const beforeIf = createTypeChecker([
324
324
 
325
325
  ## remove-useless-path-from-type-checker
326
326
 
327
- Selector always starts from `path`, so it can be `parentPath.`, or `node.`, but never `path.`, sinse it is self reference.
327
+ Selector always starts from `path`, so it can be `parentPath.`, or `node.`, but never `path.`, since it is self reference.
328
328
 
329
329
  Checkout in 🐊[**Putout Editor**](https://putout.cloudcmd.io/#/gist/ef8e1dc1036a4a2fcc99b32c3dc661e2/bc43a082dc9cb5ed8a8afe6964174f0d1be2e1c1).
330
330
 
@@ -20,7 +20,11 @@ export const fix = (path) => {
20
20
  };
21
21
 
22
22
  export const filter = (path) => {
23
- return compareAny(next(path), ['indent()', 'print.indent()', 'write.indent()']);
23
+ return compareAny(next(path), [
24
+ 'indent()',
25
+ 'print.indent()',
26
+ 'write.indent()',
27
+ ]);
24
28
  };
25
29
 
26
30
  export const include = () => [
@@ -25,7 +25,11 @@ export const include = () => [
25
25
  ];
26
26
 
27
27
  export const filter = (path) => {
28
- return compareAny(prev(path), ['indent()', 'print.indent()', 'write.indent()']);
28
+ return compareAny(prev(path), [
29
+ 'indent()',
30
+ 'print.indent()',
31
+ 'write.indent()',
32
+ ]);
29
33
  };
30
34
 
31
35
  function choose(path) {
@@ -1,7 +1,9 @@
1
- import {types} from 'putout';
1
+ import {types, operator} from 'putout';
2
2
  import {isTypeExists} from '#types';
3
3
 
4
+ const {createTypeChecker} = operator;
4
5
  const addQuotes = (a) => `'${a}'`;
6
+
5
7
  const {
6
8
  isIdentifier,
7
9
  isCallExpression,
@@ -31,6 +33,11 @@ export const report = ({type}) => {
31
33
  return `Unknown type detected: '${type}'. Use ${instead} instead`;
32
34
  };
33
35
 
36
+ const isWrongTuple = createTypeChecker([
37
+ ['-: parentPath.parentPath -> !ArrayExpression'],
38
+ ['+: parentPath.node.elements.length', '=', 3],
39
+ ]);
40
+
34
41
  export const fix = () => {};
35
42
 
36
43
  export const traverse = ({push}) => ({
@@ -45,6 +52,9 @@ export const traverse = ({push}) => ({
45
52
 
46
53
  const {value} = path.node;
47
54
 
55
+ if (isWrongTuple(path))
56
+ return;
57
+
48
58
  if (!value.includes(ARROW)) {
49
59
  if (/^[a-zA-Z].+/.test(value) && !isTypeExists(value))
50
60
  push({
package/lib/types.js CHANGED
@@ -8,6 +8,7 @@ const TYPES_EXISTS = new Set([
8
8
 
9
9
  const TYPES_NOT_EXISTS = new Set([
10
10
  'ExportDeclaration',
11
+ 'Function',
11
12
  ]);
12
13
 
13
14
  export function isTypeExists(type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-printer",
3
- "version": "8.16.0",
3
+ "version": "8.16.2",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds support of transformations for @putout/printer",