@putout/plugin-types 2.1.0 → 2.3.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.
|
@@ -25,6 +25,16 @@ const BODIES = {
|
|
|
25
25
|
bigint: `typeof __a === 'bigint'`,
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
+
const NOT_BODIES = {
|
|
29
|
+
function: `typeof __a !== 'function'`,
|
|
30
|
+
string: `typeof __a !== 'string'`,
|
|
31
|
+
number: `typeof __a !== 'number'`,
|
|
32
|
+
boolean: `typeof __a !== 'boolean'`,
|
|
33
|
+
undefined: `typeof __a !== 'undefined'`,
|
|
34
|
+
symbol: `typeof __a !== 'symbol'`,
|
|
35
|
+
bigint: `typeof __a !== 'bigint'`,
|
|
36
|
+
};
|
|
37
|
+
|
|
28
38
|
module.exports.report = () => `Use function to check type instead of 'typeof'`;
|
|
29
39
|
module.exports.match = () => ({
|
|
30
40
|
[GENERAL]: ({__a, __b}, path) => {
|
|
@@ -49,6 +59,13 @@ module.exports.replace = () => ({
|
|
|
49
59
|
[BODIES.undefined]: 'isUndefined(__a)',
|
|
50
60
|
[BODIES.symbol]: 'isSymbol(__a)',
|
|
51
61
|
[BODIES.bigint]: 'isBigInt(__a)',
|
|
62
|
+
[NOT_BODIES.function]: '!isFn(__a)',
|
|
63
|
+
[NOT_BODIES.string]: '!isString(__a)',
|
|
64
|
+
[NOT_BODIES.number]: '!isNumber(__a)',
|
|
65
|
+
[NOT_BODIES.boolean]: '!isBool(__a)',
|
|
66
|
+
[NOT_BODIES.undefined]: '!isUndefined(__a)',
|
|
67
|
+
[NOT_BODIES.symbol]: '!isSymbol(__a)',
|
|
68
|
+
[NOT_BODIES.bigint]: '!isBigInt(__a)',
|
|
52
69
|
});
|
|
53
70
|
|
|
54
71
|
function isBind(path, name) {
|
package/lib/declare/index.js
CHANGED
|
@@ -9,5 +9,6 @@ module.exports.declare = () => ({
|
|
|
9
9
|
isObject: `const isObject = (a) => a && typeof a === 'object'`,
|
|
10
10
|
isUndefined: `const isUndefined = (a) => typeof a === 'undefined'`,
|
|
11
11
|
isSymbol: `const isSymbol = (a) => typeof a === 'symbol'`,
|
|
12
|
+
isBigInt: `const isBigInt = (a) => typeof a === 'bigint'`,
|
|
12
13
|
isNull: `const isNull = (a) => !a && typeof a === 'object'`,
|
|
13
14
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/plugin-types",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.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",
|