@putout/plugin-types 1.4.0 → 1.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.
package/README.md CHANGED
@@ -25,6 +25,7 @@ npm i putout @putout/plugin-types -D
25
25
  }
26
26
  }
27
27
  ```
28
+
28
29
  ## Rules
29
30
 
30
31
  ### declare
@@ -33,6 +34,7 @@ Based on [`@putout/operator-declare`](https://github.com/coderaiser/putout/tree/
33
34
  Supported assertions:
34
35
 
35
36
  - `isString`;
37
+ - `isEmptyString`;
36
38
  - `isNumber`;
37
39
  - `isFn`;
38
40
  - `isBool`;
@@ -187,7 +189,6 @@ Array.isArray(x);
187
189
 
188
190
  MIT
189
191
 
190
-
191
192
  ## Comparison
192
193
 
193
194
  Linter | Rule | Fix
@@ -14,4 +14,3 @@ module.exports.replace = ({options}) => {
14
14
  },
15
15
  };
16
16
  };
17
-
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const {operator} = require('putout');
4
- const {compare, getBindingPath} = operator;
4
+ const {
5
+ compare,
6
+ getBindingPath,
7
+ } = operator;
5
8
 
6
9
  const NAMES = {
7
10
  function: 'isFn',
@@ -57,8 +60,10 @@ function isBind(path, name) {
57
60
  if (!bindingPath)
58
61
  return false;
59
62
 
63
+ if (!bindingPath.isVariableDeclarator())
64
+ return false;
65
+
60
66
  const {body} = bindingPath.node.init;
61
67
 
62
68
  return !compare(body, fnBody);
63
69
  }
64
-
@@ -2,6 +2,7 @@
2
2
 
3
3
  module.exports.declare = () => ({
4
4
  isString: `const isString = (a) => typeof a === 'string'`,
5
+ isEmptyString: `const isEmptyString = (a) => !a && isString(a)`,
5
6
  isNumber: `const isNumber = (a) => typeof a === 'number'`,
6
7
  isFn: `const isFn = (a) => typeof a === 'function'`,
7
8
  isBool: `const isBool = (a) => typeof a === 'boolean'`,
@@ -10,4 +11,3 @@ module.exports.declare = () => ({
10
11
  isSymbol: `const isSymbol = (a) => typeof a === 'symbol'`,
11
12
  isNull: `const isNull = (a) => !a && typeof a === 'object'`,
12
13
  });
13
-
package/lib/index.js CHANGED
@@ -12,4 +12,3 @@ module.exports.rules = {
12
12
  ...getRule('remove-double-negations'),
13
13
  ...getRule('remove-useless-typeof'),
14
14
  };
15
-
@@ -13,4 +13,3 @@ module.exports.replace = () => ({
13
13
  'do __a; while(!!__b)': 'do __a; while(__b)',
14
14
  'for (__a; !!__b; __c) __d': 'for (__a; __b; __c) __d',
15
15
  });
16
-
@@ -13,4 +13,3 @@ module.exports.replace = () => ({
13
13
  'for (; Boolean(__b);__c) __d': 'for (; __b; __c) __d',
14
14
  'for (; Boolean(__b);) __d': 'for (; __b;) __d',
15
15
  });
16
-
@@ -5,4 +5,3 @@ module.exports.report = () => `Useless typeof should be avoided`;
5
5
  module.exports.replace = () => ({
6
6
  'typeof typeof __a': 'typeof __a',
7
7
  });
8
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-types",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin adds ability to transform code related to types assertions",
@@ -35,8 +35,8 @@
35
35
  "@putout/test": "^6.0.0",
36
36
  "c8": "^7.5.0",
37
37
  "eslint": "^8.0.1",
38
- "eslint-plugin-n": "^15.2.4",
39
- "eslint-plugin-putout": "^16.0.0",
38
+ "eslint-plugin-n": "^16.0.0",
39
+ "eslint-plugin-putout": "^17.0.0",
40
40
  "lerna": "^6.0.1",
41
41
  "madrun": "^9.0.0",
42
42
  "montag": "^1.2.1",