@putout/plugin-printer 4.3.0 → 6.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,9 +1,7 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {addArgs} = operator;
5
-
6
- const parents = [
4
+ const include = [
7
5
  '__ = __',
8
6
  'const __ = __',
9
7
  'module.exports.__a = (path, __object) => __body',
@@ -13,13 +11,21 @@ const parents = [
13
11
  'function __(path, __object) {}',
14
12
  ];
15
13
 
16
- module.exports = addArgs({
14
+ const exclude = [
15
+ '(__a, __b, __c, __object) => __body',
16
+ ];
17
+
18
+ export const {
19
+ report,
20
+ fix,
21
+ traverse,
22
+ } = addArgs({
17
23
  path: ['path', 'module.exports.__a = () => __body'],
18
- maybe: ['{maybe}', parents],
19
- write: ['{write}', parents],
20
- print: ['{print}', parents],
21
- indent: ['{indent}', parents],
22
- compute: ['{compute}', parents],
23
- traverse: ['{traverse}', parents],
24
- store: ['{store}', parents],
24
+ maybe: ['{maybe}', include, exclude],
25
+ write: ['{write}', include, exclude],
26
+ print: ['{print}', include, exclude],
27
+ indent: ['{indent}', include, exclude],
28
+ compute: ['{compute}', include, exclude],
29
+ traverse: ['{traverse}', include, exclude],
30
+ store: ['{store}', include, exclude],
25
31
  });
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const {operator, template} = require('putout');
1
+ import {operator, template} from 'putout';
4
2
 
5
3
  const {
6
4
  compare,
@@ -9,11 +7,11 @@ const {
9
7
  remove,
10
8
  } = operator;
11
9
 
12
- module.exports.report = () => `breakline = newline + indent`;
10
+ export const report = () => `breakline = newline + indent`;
13
11
 
14
12
  const next = (path) => path.parentPath.getNextSibling();
15
13
 
16
- module.exports.fix = (path) => {
14
+ export const fix = (path) => {
17
15
  const sibling = next(path);
18
16
  const newNode = choose(path);
19
17
 
@@ -21,11 +19,11 @@ module.exports.fix = (path) => {
21
19
  replaceWith(path, newNode);
22
20
  };
23
21
 
24
- module.exports.filter = (path) => {
22
+ export const filter = (path) => {
25
23
  return compareAny(next(path), ['indent()', 'print.indent()', 'write.indent()']);
26
24
  };
27
25
 
28
- module.exports.include = () => [
26
+ export const include = () => [
29
27
  'print.newline()',
30
28
  'write.newline()',
31
29
  ];
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
1
  const {assign} = Object;
4
2
 
5
- module.exports.report = () => `Use print('__path') instead of path.get(__path)`;
3
+ export const report = () => `Use print('__path') instead of path.get(__path)`;
6
4
 
7
- module.exports.replace = () => ({
5
+ export const replace = () => ({
8
6
  'print(path.get(__a))': ({__a}) => {
9
7
  const {raw, value} = __a;
10
8
 
@@ -1,6 +1,4 @@
1
- 'use strict';
2
-
3
- const {operator, template} = require('putout');
1
+ import {operator, template} from 'putout';
4
2
 
5
3
  const {
6
4
  compare,
@@ -9,11 +7,11 @@ const {
9
7
  remove,
10
8
  } = operator;
11
9
 
12
- module.exports.report = () => `linebreak = indent + newline`;
10
+ export const report = () => `linebreak = indent + newline`;
13
11
 
14
12
  const prev = (path) => path.parentPath.getPrevSibling();
15
13
 
16
- module.exports.fix = (path) => {
14
+ export const fix = (path) => {
17
15
  const sibling = prev(path);
18
16
  const newNode = choose(path);
19
17
 
@@ -21,12 +19,12 @@ module.exports.fix = (path) => {
21
19
  replaceWith(path, newNode);
22
20
  };
23
21
 
24
- module.exports.include = () => [
22
+ export const include = () => [
25
23
  'print.newline()',
26
24
  'write.newline()',
27
25
  ];
28
26
 
29
- module.exports.filter = (path) => {
27
+ export const filter = (path) => {
30
28
  return compareAny(prev(path), ['indent()', 'print.indent()', 'write.indent()']);
31
29
  };
32
30
 
@@ -1,14 +1,13 @@
1
- 'use strict';
1
+ import {types} from 'putout';
2
2
 
3
- const {types} = require('putout');
4
3
  const {isObjectPattern} = types;
5
4
 
6
5
  const {keys} = Object;
7
6
  const TYPES = keys(types);
8
7
 
9
- module.exports.report = () => `require: ('@putout/babel') -> ('putout/babel').types`;
8
+ export const report = () => `require: ('@putout/babel') -> ('putout/babel').types`;
10
9
 
11
- module.exports.match = () => ({
10
+ export const match = () => ({
12
11
  'const __a = require("@putout/babel")': ({__a}) => {
13
12
  if (!isObjectPattern(__a))
14
13
  return false;
@@ -30,7 +29,7 @@ module.exports.match = () => ({
30
29
  },
31
30
  });
32
31
 
33
- module.exports.replace = () => ({
32
+ export const replace = () => ({
34
33
  'const {types, __a} = require("@putout/babel")': `{
35
34
  const {types} = require("@putout/babel");
36
35
  const {__a} = types;
@@ -1,8 +1,6 @@
1
- 'use strict';
1
+ import types from '@putout/plugin-putout/declare/types';
2
2
 
3
- const types = require('@putout/plugin-putout/declare/types');
4
-
5
- module.exports.declare = () => ({
3
+ export const declare = () => ({
6
4
  createTest: `const {createTest} = require('#test')`,
7
5
  test: 'const {test} = createTest(__dirname)',
8
6
  fixture: 'const {fixture} = createTest(__dirname)',
package/lib/index.js CHANGED
@@ -1,15 +1,13 @@
1
- 'use strict';
1
+ import * as removeArgs from './remove-args/index.js';
2
+ import * as applyBreakline from './apply-breakline/index.js';
3
+ import * as applyLinebreak from './apply-linebreak/index.js';
4
+ import * as applyComputedPrint from './apply-computed-print/index.js';
5
+ import * as addArgs from './add-args/index.js';
6
+ import * as declare from './declare/index.js';
7
+ import * as applyTypes from './apply-types/index.js';
8
+ import * as removeLegacyTestDeclaration from './remove-legacy-test-declaration/index.js';
2
9
 
3
- const removeArgs = require('./remove-args');
4
- const applyBreakline = require('./apply-breakline');
5
- const applyLinebreak = require('./apply-linebreak');
6
- const applyComputedPrint = require('./apply-computed-print');
7
- const addArgs = require('./add-args');
8
- const declare = require('./declare');
9
- const applyTypes = require('./apply-types');
10
- const removeLegacyTestDeclaration = require('./remove-legacy-test-declaration');
11
-
12
- module.exports.rules = {
10
+ export const rules = {
13
11
  'remove-args': removeArgs,
14
12
  'apply-breakline': applyBreakline,
15
13
  'apply-linebreak': applyLinebreak,
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
1
  const checkArgs = ({__args}) => __args.length;
4
2
 
5
- module.exports.report = () => 'Remove useless argument';
3
+ export const report = () => 'Remove useless argument';
6
4
 
7
- module.exports.match = () => ({
5
+ export const match = () => ({
8
6
  'print.newline(__args)': checkArgs,
9
7
  'print.space(__args)': checkArgs,
10
8
 
@@ -25,7 +23,7 @@ module.exports.match = () => ({
25
23
  'print.indent.dec(__args)': checkArgs,
26
24
  });
27
25
 
28
- module.exports.replace = () => ({
26
+ export const replace = () => ({
29
27
  'print.newline(__args)': 'print.newline()',
30
28
  'print.breakline(__a)': 'print.breakline()',
31
29
  'print.linebreak(__a)': 'print.linebreak()',
@@ -1,6 +1,5 @@
1
- 'use strict';
1
+ import {operator} from 'putout';
2
2
 
3
- const {operator} = require('putout');
4
3
  const {traverse} = operator;
5
4
 
6
5
  const EXTEND = `
@@ -9,16 +8,16 @@ const EXTEND = `
9
8
  })
10
9
  `;
11
10
 
12
- module.exports.report = () => `Remove legacy test declaration`;
11
+ export const report = () => `Remove legacy test declaration`;
13
12
 
14
- module.exports.match = () => ({
13
+ export const match = () => ({
15
14
  'const fixture = __': check,
16
15
  'const {printExtension} = __': check,
17
16
  'const {readFixtures} = __': check,
18
17
  [EXTEND]: check,
19
18
  });
20
19
 
21
- module.exports.replace = () => ({
20
+ export const replace = () => ({
22
21
  'const fixture = __': '',
23
22
  'const {printExtension} = __': '',
24
23
  'const {readFixtures} = __': '',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@putout/plugin-printer",
3
- "version": "4.3.0",
4
- "type": "commonjs",
3
+ "version": "6.0.0",
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",
7
7
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/plugin-printer#readme",
@@ -34,25 +34,25 @@
34
34
  "printer"
35
35
  ],
36
36
  "devDependencies": {
37
+ "@putout/eslint-flat": "^3.0.0",
37
38
  "@putout/plugin-declare-before-reference": "*",
38
39
  "@putout/plugin-for-of": "*",
39
40
  "@putout/plugin-remove-nested-blocks": "*",
40
- "@putout/test": "^11.0.0",
41
+ "@putout/test": "^13.0.0",
41
42
  "c8": "^10.0.0",
42
43
  "eslint": "^9.0.0",
43
44
  "eslint-plugin-n": "^17.0.0",
44
- "eslint-plugin-putout": "^23.0.0",
45
- "lerna": "^6.0.1",
46
- "madrun": "^10.0.0",
45
+ "eslint-plugin-putout": "^27.0.0",
46
+ "madrun": "^11.0.0",
47
47
  "montag": "^1.2.1",
48
48
  "nodemon": "^3.0.1"
49
49
  },
50
50
  "peerDependencies": {
51
- "putout": ">=37"
51
+ "putout": ">=40"
52
52
  },
53
53
  "license": "MIT",
54
54
  "engines": {
55
- "node": ">=18"
55
+ "node": ">=20"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"