@putout/plugin-types 7.0.0 → 8.0.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,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => `Use 'Array.isArray()' instead of 'instanceof'`;
2
2
 
3
- module.exports.report = () => `Use 'Array.isArray()' instead of 'instanceof'`;
4
-
5
- module.exports.replace = ({options}) => {
3
+ export const replace = ({options}) => {
6
4
  const {inline} = options;
7
5
 
8
6
  return {
@@ -1,6 +1,5 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {compare, getBindingPath} = operator;
5
4
 
6
5
  const NAMES = {
@@ -50,8 +49,8 @@ const NOT_BODIES = {
50
49
  equalUndefined: '__a !== undefined',
51
50
  };
52
51
 
53
- module.exports.report = () => `Use function to check type instead of 'typeof' or 'instanceof'`;
54
- module.exports.match = () => ({
52
+ export const report = () => `Use function to check type instead of 'typeof' or 'instanceof'`;
53
+ export const match = () => ({
55
54
  [EQUAL]: check,
56
55
  [NOT_EQUAL]: check,
57
56
  [EQUAL_INSTANCE_OF]: check,
@@ -60,7 +59,7 @@ module.exports.match = () => ({
60
59
  [NOT_EQUAL_UNDEFINED]: check,
61
60
  });
62
61
 
63
- module.exports.replace = () => ({
62
+ export const replace = () => ({
64
63
  [BODIES.function]: 'isFn(__a)',
65
64
  [BODIES.string]: 'isString(__a)',
66
65
  [BODIES.number]: 'isNumber(__a)',
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- module.exports.declare = () => ({
1
+ export const declare = () => ({
4
2
  isString: `const isString = (a) => typeof a === 'string'`,
5
3
  isEmptyString: `const isEmptyString = (a) => !a && isString(a)`,
6
4
  isNumber: `const isNumber = (a) => !Number.isNaN(a) && typeof a === 'number'`,
package/lib/index.js CHANGED
@@ -1,16 +1,14 @@
1
- 'use strict';
1
+ import * as applyIsArray from './apply-is-array/index.js';
2
+ import * as declare from './declare/index.js';
3
+ import * as convertTypeofToIsType from './convert-typeof-to-is-type/index.js';
4
+ import * as removeUselessConversion from './remove-useless-conversion/index.js';
5
+ import * as removeUselessConstructor from './remove-useless-constructor/index.js';
6
+ import * as removeDoubleNegations from './remove-double-negations/index.js';
7
+ import * as removeUselessTypeof from './remove-useless-typeof/index.js';
2
8
 
3
- const applyIsArray = require('./apply-is-array');
4
- const declare = require('./declare');
5
- const convertTypeofToIsType = require('./convert-typeof-to-is-type');
6
- const removeUselessConversion = require('./remove-useless-conversion');
7
- const removeUselessConstructor = require('./remove-useless-constructor');
8
- const removeDoubleNegations = require('./remove-double-negations');
9
- const removeUselessTypeof = require('./remove-useless-typeof');
10
-
11
- module.exports.rules = {
9
+ export const rules = {
12
10
  'apply-is-array': applyIsArray,
13
- declare,
11
+ 'declare': declare,
14
12
  'convert-typeof-to-is-type': convertTypeofToIsType,
15
13
  'remove-useless-conversion': removeUselessConversion,
16
14
  'remove-useless-constructor': removeUselessConstructor,
@@ -1,10 +1,8 @@
1
- 'use strict';
1
+ export const report = () => `Avoid double negations in conditions`;
2
2
 
3
- module.exports.report = () => `Avoid double negations in conditions`;
3
+ export const filter = ({parentPath}) => !parentPath.isJSXExpressionContainer();
4
4
 
5
- module.exports.filter = ({parentPath}) => !parentPath.isJSXExpressionContainer();
6
-
7
- module.exports.replace = () => ({
5
+ export const replace = () => ({
8
6
  'if (!!__a) __b': 'if (__a) __b',
9
7
  '!!__a ? __b : __c': '__a ? __b : __c',
10
8
  '!!__a && __b': '__a && __b',
@@ -1,19 +1,18 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {
5
4
  isBooleanLiteral,
6
5
  isNumericLiteral,
7
6
  } = types;
8
7
 
9
- module.exports.report = () => 'Avoid useless constructor';
8
+ export const report = () => 'Avoid useless constructor';
10
9
 
11
- module.exports.match = () => ({
10
+ export const match = () => ({
12
11
  'Boolean(__a)': ({__a}) => isBooleanLiteral(__a),
13
12
  'Number(__a)': ({__a}) => isNumericLiteral(__a),
14
13
  });
15
14
 
16
- module.exports.replace = () => ({
15
+ export const replace = () => ({
17
16
  'String("__a")': '__a',
18
17
  'Boolean(__a)': '__a',
19
18
  'Number(__a)': '__a',
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ export const report = () => `Avoid useless type conversion`;
2
2
 
3
- module.exports.report = () => `Avoid useless type conversion`;
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  'Boolean(__a.includes(__b))': '__a.includes(__b)',
7
5
  'String(typeof __a)': 'typeof __a',
8
6
  'if (Boolean(__a)) __b': 'if (__a) __b',
@@ -1,7 +1,5 @@
1
- 'use strict';
1
+ export const report = () => `Avoid useless 'typeof'`;
2
2
 
3
- module.exports.report = () => `Avoid useless 'typeof'`;
4
-
5
- module.exports.replace = () => ({
3
+ export const replace = () => ({
6
4
  'typeof typeof __a': 'typeof __a',
7
5
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@putout/plugin-types",
3
- "version": "7.0.0",
4
- "type": "commonjs",
3
+ "version": "8.0.0",
4
+ "type": "module",
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",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-types#readme",
@@ -31,24 +31,23 @@
31
31
  "types"
32
32
  ],
33
33
  "devDependencies": {
34
- "@putout/eslint-flat": "^2.0.0",
34
+ "@putout/eslint-flat": "^3.0.0",
35
35
  "@putout/plugin-putout": "*",
36
- "@putout/test": "^11.0.0",
36
+ "@putout/test": "^13.0.0",
37
37
  "c8": "^10.0.0",
38
38
  "eslint": "^9.0.0",
39
39
  "eslint-plugin-n": "^17.0.0",
40
- "eslint-plugin-putout": "^24.0.0",
41
- "lerna": "^6.0.1",
42
- "madrun": "^10.0.0",
40
+ "eslint-plugin-putout": "^26.0.0",
41
+ "madrun": "^11.0.0",
43
42
  "montag": "^1.2.1",
44
43
  "nodemon": "^3.0.1"
45
44
  },
46
45
  "peerDependencies": {
47
- "putout": ">=38"
46
+ "putout": ">=40"
48
47
  },
49
48
  "license": "MIT",
50
49
  "engines": {
51
- "node": ">=18"
50
+ "node": ">=20"
52
51
  },
53
52
  "publishConfig": {
54
53
  "access": "public"