putout 29.12.0 β†’ 29.12.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/ChangeLog CHANGED
@@ -1,3 +1,19 @@
1
+ 2023.06.06, v29.12.2
2
+
3
+ feature:
4
+ - 2fa1f0396 package: @putout/plugin-convert-esm-to-commonjs v6.0.0
5
+ - 445b85b77 @putout/plugin-convert-esm-to-commonjs: drop support of 🐊 < 29
6
+ - f1776923a @putout/plugin-putout: check-replace-code: add support of __args__a
7
+ - 3102231e5 @putout/compare: isLinkedId: improve support
8
+
9
+ 2023.06.05, v29.12.1
10
+
11
+ feature:
12
+ - a70c3d9eb package: @putout/plugin-convert-array-copy-to-slice v3.0.0
13
+ - f22597d5d @putout/plugin-convert-array-copy-to-slice: drop support of node < 16
14
+ - 8c84d5a91 @putout/plugin-convert-array-copy-to-slice: use @putout/printer
15
+ - d3e57f1b0 @putout/plugin-minify: mangle-names: add ability to configure with mangleClassNames
16
+
1
17
  2023.06.05, v29.12.0
2
18
 
3
19
  fix:
package/README.md CHANGED
@@ -289,6 +289,7 @@ putout(source, {
289
289
  'remove-unused-variables',
290
290
  ],
291
291
  });
292
+
292
293
  // returns
293
294
  `
294
295
  const t = 'hello';
package/bin/putout.mjs CHANGED
@@ -4,7 +4,6 @@ import {
4
4
  readFile,
5
5
  writeFile,
6
6
  } from 'fs/promises';
7
-
8
7
  import cli from '../lib/cli/index.js';
9
8
 
10
9
  const {stdout} = process;
@@ -20,4 +19,3 @@ await cli({
20
19
  readFile,
21
20
  writeFile,
22
21
  });
23
-
@@ -9,6 +9,7 @@ module.exports = (line) => {
9
9
 
10
10
  const [from, to] = line.split('->');
11
11
  const report = returns(line);
12
+
12
13
  const replace = returns({
13
14
  [from]: to,
14
15
  });
@@ -18,6 +19,7 @@ module.exports = (line) => {
18
19
  replace,
19
20
  }];
20
21
 
21
- return [plugin];
22
+ return [
23
+ plugin,
24
+ ];
22
25
  };
23
-
@@ -17,4 +17,3 @@ module.exports = {
17
17
  UNHANDLED: 13,
18
18
  CANNOT_LINT_STAGED: 14,
19
19
  };
20
-
@@ -26,4 +26,3 @@ module.exports.getFormatter = async (formatterOptional, exit) => {
26
26
 
27
27
  exit(CANNOT_LOAD_FORMATTER, error);
28
28
  };
29
-
@@ -20,8 +20,7 @@ async function getFiles(args, options) {
20
20
  const files = await Promise.all(promises);
21
21
  const mergedFiles = files.flat();
22
22
 
23
- return rmDuplicates(mergedFiles)
24
- .map(normalize);
23
+ return rmDuplicates(mergedFiles).map(normalize);
25
24
  }
26
25
 
27
26
  const globOptions = {
@@ -16,7 +16,10 @@ const maybeConfig = {
16
16
  plugins: [],
17
17
  };
18
18
 
19
- PUTOUT_CONFIG_FILE && assign(maybeConfig, require(join(process.cwd(), PUTOUT_CONFIG_FILE)));
19
+ PUTOUT_CONFIG_FILE && assign(maybeConfig, require(join(
20
+ process.cwd(),
21
+ PUTOUT_CONFIG_FILE,
22
+ )));
20
23
 
21
24
  module.exports = ({noConfig, plugins, name, transform, rulesdir}) => {
22
25
  const transformPlugins = buildPlugins(transform);
@@ -47,4 +50,3 @@ module.exports = ({noConfig, plugins, name, transform, rulesdir}) => {
47
50
  ],
48
51
  };
49
52
  };
50
-
package/lib/cli/help.js CHANGED
@@ -3,6 +3,7 @@
3
3
  module.exports = () => {
4
4
  const bin = require('../../help.json');
5
5
  const usage = 'Usage: putout [options] [path]';
6
+
6
7
  const result = [
7
8
  usage,
8
9
  'Options: ',
@@ -14,4 +15,3 @@ module.exports = () => {
14
15
 
15
16
  return result.join('\n');
16
17
  };
17
-
package/lib/cli/index.js CHANGED
@@ -45,6 +45,7 @@ const {
45
45
  const getFormatter = nanomemoize(require('./formatter').getFormatter);
46
46
 
47
47
  const cwd = process.cwd();
48
+
48
49
  const {
49
50
  PUTOUT_FILES = '',
50
51
  PUTOUT_PRINTER,
@@ -146,6 +147,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
146
147
  } = args;
147
148
 
148
149
  const {red} = await simpleImport('chalk');
150
+
149
151
  const exit = getExit({
150
152
  red,
151
153
  raw,
@@ -180,7 +182,11 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
180
182
 
181
183
  if (isStr(args.match)) {
182
184
  const {match} = await simpleImport('@putout/cli-match');
183
- const {code, message} = await match({
185
+
186
+ const {
187
+ code,
188
+ message,
189
+ } = await match({
184
190
  pattern: args.match,
185
191
  cwd,
186
192
  readFile,
@@ -195,10 +201,17 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
195
201
 
196
202
  if (enable || disable) {
197
203
  const {ruler} = await simpleImport('@putout/cli-ruler');
198
- ruler({enable, disable, readFile, writeFile}, []);
204
+
205
+ ruler({
206
+ enable,
207
+ disable,
208
+ readFile,
209
+ writeFile,
210
+ }, []);
199
211
  }
200
212
 
201
213
  const noConfig = !args.config;
214
+
202
215
  const [configError, config] = tryCatch(getOptions, {
203
216
  name: `${cwd}/*`,
204
217
  rulesdir,
@@ -231,7 +244,10 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
231
244
  if (staged) {
232
245
  const {get} = require('./staged');
233
246
  const {findUp} = await simpleImport('find-up');
234
- const [error, names] = await tryToCatch(get, {findUp});
247
+
248
+ const [error, names] = await tryToCatch(get, {
249
+ findUp,
250
+ });
235
251
 
236
252
  if (error)
237
253
  return exit(CANNOT_LINT_STAGED, `--staged: ${error.message}`);
@@ -286,7 +302,10 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
286
302
  printer: PUTOUT_PRINTER,
287
303
  };
288
304
 
289
- const {places, exited} = await run({
305
+ const {
306
+ places,
307
+ exited,
308
+ } = await run({
290
309
  fix,
291
310
  exit,
292
311
  readFile,
@@ -314,13 +333,22 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
314
333
 
315
334
  if (enableAll || disableAll) {
316
335
  const {ruler} = await simpleImport('@putout/cli-ruler');
317
- await ruler({enableAll, disableAll, readFile, writeFile}, places);
336
+
337
+ await ruler({
338
+ enableAll,
339
+ disableAll,
340
+ readFile,
341
+ writeFile,
342
+ }, places);
318
343
  }
319
344
 
320
345
  if (fix && staged) {
321
346
  const {set} = require('./staged');
322
347
  const {findUp} = await simpleImport('find-up');
323
- const stagedNames = await set({findUp});
348
+
349
+ const stagedNames = await set({
350
+ findUp,
351
+ });
324
352
 
325
353
  if (!stagedNames.length)
326
354
  return exit(STAGE);
@@ -356,4 +384,3 @@ function addOnce(emitter, name, fn) {
356
384
  if (!emitter.listenerCount(name))
357
385
  emitter.on(name, fn);
358
386
  }
359
-
@@ -1,10 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = (e) => {
4
- const {line, column} = e.loc || {
4
+ const {
5
+ line,
6
+ column,
7
+ } = e.loc || {
5
8
  line: 1,
6
9
  column: 1,
7
10
  };
11
+
8
12
  const rule = e.rule ? `${e.rule} (parser)` : 'parser';
9
13
  const message = cutBrackets(e.message);
10
14
 
@@ -26,4 +30,3 @@ function cutBrackets(a) {
26
30
 
27
31
  return a.slice(0, index);
28
32
  }
29
-
@@ -69,4 +69,3 @@ function formatPlaces(line = 1, places) {
69
69
 
70
70
  return newPlaces;
71
71
  }
72
-
package/lib/cli/report.js CHANGED
@@ -31,4 +31,3 @@ module.exports = () => {
31
31
  });
32
32
  };
33
33
  };
34
-
@@ -50,7 +50,11 @@ module.exports.lint = async ({raw, log, dir, resolvedName, options, readFile, fi
50
50
  };
51
51
  }
52
52
 
53
- ({isProcessed, places, processedSource} = result);
53
+ ({
54
+ isProcessed,
55
+ places,
56
+ processedSource,
57
+ } = result);
54
58
 
55
59
  return {
56
60
  isProcessed,
@@ -59,4 +63,3 @@ module.exports.lint = async ({raw, log, dir, resolvedName, options, readFile, fi
59
63
  rawSource,
60
64
  };
61
65
  };
62
-
@@ -19,7 +19,10 @@ module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile,
19
19
  const currentIndex = isStop() ? length - 1 : index;
20
20
  const name = names[index];
21
21
 
22
- const {exited, places: currentPlaces = []} = await runWorker({
22
+ const {
23
+ exited,
24
+ places: currentPlaces = [],
25
+ } = await runWorker({
23
26
  readFile,
24
27
  writeFile,
25
28
  exit,
@@ -45,8 +48,13 @@ module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile,
45
48
  places.push(...currentPlaces);
46
49
 
47
50
  if (exited)
48
- return {exited, places};
51
+ return {
52
+ exited,
53
+ places,
54
+ };
49
55
  }
50
56
 
51
- return {places};
57
+ return {
58
+ places,
59
+ };
52
60
  };
@@ -1,18 +1,19 @@
1
1
  'use strict';
2
2
 
3
3
  const {resolve} = require('path');
4
- const {
5
- cwd,
6
- env,
7
- } = require('process');
4
+
5
+ const {cwd, env} = require('process');
6
+
8
7
  const tryCatch = require('try-catch');
9
8
  const {readFileSync} = require('fs');
10
9
 
11
10
  const getOptions = require('../get-options.js');
11
+
12
12
  const {
13
13
  INVALID_CONFIG,
14
14
  NO_PROCESSORS,
15
15
  } = require('../exit-codes.js');
16
+
16
17
  const {lint} = require('./lint.js');
17
18
 
18
19
  const isParser = (rule) => rule.startsWith('parser');
@@ -33,8 +34,7 @@ const createFormatterProxy = (options) => {
33
34
  };
34
35
 
35
36
  module.exports = async ({readFile, report, writeFile, exit, raw, write, log, currentFormat, rulesdir, formatterOptions, noConfig, transform, plugins, index, fix, processFile, processorRunners, fileCache, name, count}) => {
36
- const resolvedName = resolve(name)
37
- .replace(/^\./, cwd);
37
+ const resolvedName = resolve(name).replace(/^\./, cwd);
38
38
 
39
39
  const [configError, options] = tryCatch(getOptions, {
40
40
  name: resolvedName,
@@ -48,6 +48,7 @@ module.exports = async ({readFile, report, writeFile, exit, raw, write, log, cur
48
48
  return exit(INVALID_CONFIG, configError);
49
49
 
50
50
  const {dir} = options;
51
+
51
52
  const success = await runCache({
52
53
  options,
53
54
  fileCache,
@@ -119,6 +120,7 @@ async function runCache({fileCache, report, write, formatterOptions, currentForm
119
120
  return false;
120
121
 
121
122
  const places = fileCache.getPlaces(name);
123
+
122
124
  const formatterProxy = createFormatterProxy({
123
125
  report,
124
126
  formatterOptions,
@@ -134,4 +136,3 @@ async function runCache({fileCache, report, write, formatterOptions, currentForm
134
136
 
135
137
  return true;
136
138
  }
137
-
@@ -4,4 +4,3 @@ module.exports.simpleImport = async (url) => {
4
4
  const result = await import(url);
5
5
  return result.default || result;
6
6
  };
7
-
package/lib/cli/staged.js CHANGED
@@ -42,7 +42,10 @@ const head = ([a]) => a;
42
42
  const joinDir = (a) => (b) => join(a, b);
43
43
 
44
44
  module.exports.get = async function get({findUp}) {
45
- const dir = await findGit({findUp});
45
+ const dir = await findGit({
46
+ findUp,
47
+ });
48
+
46
49
  const status = await git.statusMatrix({
47
50
  fs,
48
51
  dir,
@@ -70,7 +73,10 @@ async function getStatus(dir, filepath) {
70
73
  }
71
74
 
72
75
  module.exports.set = async function set({findUp}) {
73
- const dir = await findGit({findUp});
76
+ const dir = await findGit({
77
+ findUp,
78
+ });
79
+
74
80
  const names = namesStore();
75
81
  const statusPromises = [];
76
82
 
@@ -93,4 +99,3 @@ module.exports.set = async function set({findUp}) {
93
99
 
94
100
  return staged;
95
101
  };
96
-
package/lib/codeframe.js CHANGED
@@ -3,7 +3,10 @@
3
3
  const {codeFrameColumns} = require('@babel/code-frame');
4
4
 
5
5
  module.exports = ({source, error, highlightCode = true}) => {
6
- const {message, loc} = error;
6
+ const {
7
+ message,
8
+ loc,
9
+ } = error;
7
10
 
8
11
  if (!loc)
9
12
  return message;
@@ -17,4 +20,3 @@ module.exports = ({source, error, highlightCode = true}) => {
17
20
  message,
18
21
  });
19
22
  };
20
-
package/lib/ignores.js CHANGED
@@ -28,4 +28,3 @@ function mergeIgnores(ignores) {
28
28
 
29
29
  return Array.from(noDuplicates);
30
30
  }
31
-
package/lib/loader.mjs CHANGED
@@ -26,6 +26,7 @@ export const transformSource = (source, context) => {
26
26
  const {url} = context;
27
27
 
28
28
  const name = url.replace('file://', '');
29
+
29
30
  const options = parseOptions({
30
31
  name,
31
32
  });
@@ -44,4 +45,3 @@ export const transformSource = (source, context) => {
44
45
  };
45
46
 
46
47
  export const load = toLoad(transformSource);
47
-
package/lib/merge.js CHANGED
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const deepmerge = require('deepmerge');
4
- const arrayUnion = (...a) => [...new Set(a.flat())];
4
+
5
+ const arrayUnion = (...a) => [
6
+ ...new Set(a.flat()),
7
+ ];
5
8
 
6
9
  const arrayMerge = (a, b) => arrayUnion(b, a);
7
10
 
@@ -10,4 +13,3 @@ module.exports = (...args) => {
10
13
  arrayMerge,
11
14
  });
12
15
  };
13
-
@@ -2,6 +2,7 @@
2
2
 
3
3
  const {homedir} = require('os');
4
4
  const {readdirSync} = require('fs');
5
+
5
6
  const {
6
7
  dirname,
7
8
  join,
@@ -43,9 +44,13 @@ module.exports = (info = {}) => {
43
44
  ];
44
45
 
45
46
  const mergedOptions = merge(...optionsList);
47
+
46
48
  const mergedDefaultsMatch = merge(
47
49
  mergedOptions,
48
- parseMatch(name, mergedOptions.match),
50
+ parseMatch(
51
+ name,
52
+ mergedOptions.match,
53
+ ),
49
54
  options,
50
55
  );
51
56
 
@@ -55,13 +60,13 @@ module.exports = (info = {}) => {
55
60
  parseMatch(name, options.match),
56
61
  ]);
57
62
 
58
- const resultOptions = merge(
63
+ const resultOptions = merge(...[
59
64
  readCodeMods(),
60
65
  readRules('./', rulesdir),
61
66
  mergedOptions,
62
67
  mergedDefaultsMatch,
63
68
  mergedMatch,
64
- );
69
+ ]);
65
70
 
66
71
  validateOptions(resultOptions);
67
72
 
@@ -85,16 +90,14 @@ function _readOptions(name) {
85
90
 
86
91
  if (packagePath)
87
92
  return [
88
- dirname(packagePath), {
93
+ dirname(packagePath),
94
+ {
89
95
  ...options,
90
96
  ...require(packagePath).putout,
91
97
  },
92
98
  ];
93
99
 
94
- return [
95
- '',
96
- {},
97
- ];
100
+ return ['', {}];
98
101
  }
99
102
 
100
103
  const isInclude = (a) => !/(^not-rule-.*|^node_modules$)/.test(a);
@@ -136,4 +139,3 @@ const _readHomeOptions = once(() => {
136
139
  });
137
140
 
138
141
  const _readCodeMods = once(() => readRules(home, '.putout'));
139
-
@@ -2,7 +2,10 @@
2
2
 
3
3
  const picomatch = require('picomatch');
4
4
 
5
- const {keys, assign} = Object;
5
+ const {
6
+ keys,
7
+ assign,
8
+ } = Object;
6
9
 
7
10
  module.exports = (name, match) => {
8
11
  if (!match || !name)
@@ -32,4 +35,3 @@ module.exports = (name, match) => {
32
35
  rules,
33
36
  };
34
37
  };
35
-
@@ -18,4 +18,3 @@ function wild(str) {
18
18
 
19
19
  return wildcard;
20
20
  }
21
-
@@ -12,6 +12,7 @@ module.exports = (name, configName, overrides) => {
12
12
 
13
13
  const customRequire = overrides?.require || require;
14
14
  const dir = dirname(name);
15
+
15
16
  const [mainDir, optionsList] = getOptionsList({
16
17
  dir,
17
18
  configName,
@@ -47,4 +48,3 @@ function getOptionsList({dir, configName, customRequire}) {
47
48
 
48
49
  return [mainDir, optionsList.reverse()];
49
50
  }
50
-
@@ -77,7 +77,10 @@
77
77
  },
78
78
  "formatter": {
79
79
  "description": "Choose the way to show information about errors found",
80
- "type": ["string", "array"]
80
+ "type": [
81
+ "string",
82
+ "array"
83
+ ]
81
84
  },
82
85
  "processors": {
83
86
  "description": "Tell 🐊Putout which processors to use to support file types other then JavaScript",
@@ -113,6 +116,8 @@
113
116
  "type": "array",
114
117
  "uniqueItems": true
115
118
  },
116
- "rules": {"$ref": "#/definitions/rules"}
119
+ "rules": {
120
+ "$ref": "#/definitions/rules"
121
+ }
117
122
  }
118
123
  }
package/lib/putout.js CHANGED
@@ -5,6 +5,7 @@ const types = require('@babel/types');
5
5
 
6
6
  const loader = require('@putout/engine-loader');
7
7
  const runner = require('@putout/engine-runner');
8
+
8
9
  const {
9
10
  parse,
10
11
  print,
@@ -12,7 +13,11 @@ const {
12
13
  template,
13
14
  } = require('@putout/engine-parser');
14
15
 
15
- const {cutShebang, mergeShebang} = require('./shebang');
16
+ const {
17
+ cutShebang,
18
+ mergeShebang,
19
+ } = require('./shebang');
20
+
16
21
  const isString = (a) => typeof a === 'string';
17
22
 
18
23
  const defaultOpts = (opts = {}) => {
@@ -51,6 +56,7 @@ module.exports = (source, opts) => {
51
56
  } = opts;
52
57
 
53
58
  const [clearSource, shebang] = cutShebang(source);
59
+
54
60
  const ast = parse(clearSource, {
55
61
  sourceFileName,
56
62
  parser,
@@ -72,6 +78,7 @@ module.exports = (source, opts) => {
72
78
  sourceMapName,
73
79
  printer,
74
80
  });
81
+
75
82
  const code = mergeShebang(shebang, printed);
76
83
 
77
84
  return {
@@ -111,6 +118,7 @@ function transform(ast, source, opts) {
111
118
  } = opts;
112
119
 
113
120
  const [, shebang] = cutShebang(source);
121
+
114
122
  const plugins = loadPlugins({
115
123
  pluginNames,
116
124
  cache,
package/lib/putout.mjs CHANGED
@@ -2,7 +2,6 @@ import putout from './putout.js';
2
2
 
3
3
  export {load} from './loader.mjs';
4
4
  export * from './putout.js';
5
-
6
5
  export default function(...a) {
7
6
  return putout(...a);
8
7
  }
package/lib/shebang.js CHANGED
@@ -11,10 +11,17 @@ module.exports.mergeShebang = (shebang, source) => {
11
11
 
12
12
  module.exports.cutShebang = (source) => {
13
13
  if (source.indexOf('#'))
14
- return [source, ''];
14
+ return [
15
+ source,
16
+ '',
17
+ ];
15
18
 
16
19
  const lines = source.split('\n');
17
- const result = lines.slice(1).join('\n');
20
+
21
+ const result = lines
22
+ .slice(1)
23
+ .join('\n');
24
+
18
25
  const [shebang] = lines;
19
26
 
20
27
  return [
@@ -22,4 +29,3 @@ module.exports.cutShebang = (source) => {
22
29
  `${shebang}\n`,
23
30
  ];
24
31
  };
25
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "29.12.0",
3
+ "version": "29.12.2",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -80,13 +80,13 @@
80
80
  "@putout/plugin-conditions": "^1.0.0",
81
81
  "@putout/plugin-convert-apply-to-spread": "^4.0.0",
82
82
  "@putout/plugin-convert-arguments-to-rest": "^2.0.0",
83
- "@putout/plugin-convert-array-copy-to-slice": "^2.0.0",
83
+ "@putout/plugin-convert-array-copy-to-slice": "^3.0.0",
84
84
  "@putout/plugin-convert-assignment-to-arrow-function": "^1.0.0",
85
85
  "@putout/plugin-convert-assignment-to-comparison": "^1.0.0",
86
86
  "@putout/plugin-convert-commonjs-to-esm": "^9.0.0",
87
87
  "@putout/plugin-convert-concat-to-flat": "^1.0.0",
88
88
  "@putout/plugin-convert-const-to-let": "^1.0.0",
89
- "@putout/plugin-convert-esm-to-commonjs": "^5.0.0",
89
+ "@putout/plugin-convert-esm-to-commonjs": "^6.0.0",
90
90
  "@putout/plugin-convert-index-of-to-includes": "^2.0.0",
91
91
  "@putout/plugin-convert-mock-require-to-mock-import": "^4.0.0",
92
92
  "@putout/plugin-convert-object-assign-to-merge-spread": "^6.0.0",
package/putout.json CHANGED
@@ -236,4 +236,3 @@
236
236
  "for-of"
237
237
  ]
238
238
  }
239
-