putout 41.0.8 → 41.0.10

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,10 +1,53 @@
1
+ 2025.12.27, v41.0.10
2
+
3
+ feature:
4
+ - c55a476c3 putout: @putout/plugin-declare-before-reference v9.0.0
5
+ - 149a38dac @putout/plugin-variables: remove-unused: ArrayPattern: filter before check
6
+ - 7d776bfce @putout/plugin-declare-before-reference: drop support of 🐊 < 41
7
+ - 14369f390 @putout/plugin-declare-before-reference: variables/apply-declarations-order
8
+ - 4e99f41d2 @putout/plugin-variables: apply-destructuring-order: exclude not ObjectPattern
9
+ - 9d892ab70 putout: config: markdown: variables/apply-declarations-order: disable
10
+ - 9a0cd6899 @putout/plugin-variables: apply-declarations-order: both identifiers
11
+ - b44904377 @putout/plugin-putout-config: apply-variables: reuse-duplicate-init
12
+ - 511db8f32 @putout/plugin-variables: reuse-duplicate-init: add
13
+ - 5af46b3a3 @putout/variables: apply-declarations-order: add
14
+ - a05cea44e @putout/plugin-destructuring: apply-declarations-order: add
15
+ - fbb452f01 @putout/plugin-putout: declare-template-variables: no arguments
16
+ - b8e027497 @putout/plugin-putout: declare-template-variables: ArrowFunction body: expression
17
+
18
+ 2025.12.26, v41.0.9
19
+
20
+ feature:
21
+ - 8ea3d2aff putout: @putout/cli-staged v2.0.0
22
+ - 9191746f8 @putout/cli-staged: migrate to ESM
23
+ - ebcefac19 @putout/cli-staged: get rid of mock-require
24
+ - d91e55f21 @putout/plugin-eslint: remove-parser-options: typescript: false positive
25
+ - 710c5f16d @putout/plugin-nodejs: apply-global-this: add
26
+ - 37a32c478 @putout/plugin-filesystem: remove-ds-store-file: add
27
+ - e1c44e536 @putout/plugin-nodejs: declare: buffer: add
28
+ - 0acc4ffc7 @putout/plugin-variables: remove-unused: ArrayPattern: improve support
29
+ - f9d0d6ac5 @putout/plugin-regexp: remove-useless-escape: ^
30
+ - 4daf1bb0f @putout/plugin-regexp: apply-starts-with: \n
31
+ - 62c8c8b28 @putout/plugin-regexp: apply-ends-with: dot
32
+ - 88f6ec881 @putout/plugin-regexp: apply-starts-with: dot
33
+ - 6d4099d45 eslint-plugin-putout: @putout/eslint-config v13.0.0
34
+ - 397531d6a eslint-plugin-putout: rm no-debugger, no-unused-vars
35
+ - 1ac6e8626 @putout/eslint-config: no-debugger, no-unused-vars: off
36
+ - 9e83fcb4d variables: remove-unused: ArrayPattern inside ArrayPattern: add support
37
+ - fa2b4d35e deno config: add
38
+ - b9a7eb0e0 @putout/engine-parser: hermes-parser v0.33.0
39
+ - bcae5b9ce putout: @putout/engine-reporter v6.0.0
40
+ - 333852573 @putout/engine-reporter: get rid of mock-require
41
+ - a3432f746 putout: cli: get-options: putout --no-config: do not exit when no plugins passed
42
+ - 4a45df8f2 @putout/engine-reporter: do not exit when no plugins
43
+
1
44
  2025.12.20, v41.0.8
2
45
 
3
46
  feature:
4
47
  - 9802375a2 putout: @putout/engine-reporter v6.0.0
5
48
  - 0b686ec56 @putout/engine-reporter: get rid of mock-require
6
49
  - e899de3bf putout: cli: get-options: putout --no-config: do not exit when no plugins passed
7
- - bf9b31cfe @putout/engine-reporter: do not exit when plugins
50
+ - bf9b31cfe @putout/engine-reporter: do not exit when no plugins
8
51
 
9
52
  2025.12.19, v41.0.7
10
53
 
@@ -1,22 +1,28 @@
1
- 'use strict';
2
-
3
- const {normalize} = require('node:path');
4
- const {lstat} = require('node:fs/promises');
5
-
6
- const fastGlob = require('fast-glob');
7
- const tryToCatch = require('try-to-catch');
8
-
9
- const {getSupportedGlob} = require('./supported-files');
1
+ import {normalize} from 'node:path';
2
+ import {lstat as _lstat} from 'node:fs/promises';
3
+ import _fastGlob from 'fast-glob';
4
+ import tryToCatch from 'try-to-catch';
5
+ import {getSupportedGlob as _getSupportedGlob} from './supported-files.js';
10
6
 
11
7
  const rmDuplicates = (a) => Array.from(new Set(a));
12
8
  const unixifyPath = (a) => !a.includes('\\') ? a : a.replace(/\\/g, '/');
13
9
 
14
- module.exports = async (args, options) => {
15
- return await tryToCatch(getFiles, args, options);
10
+ export const getFiles = async (args, options, overrides = {}) => {
11
+ const {
12
+ fastGlob = _fastGlob,
13
+ lstat = _lstat,
14
+ getSupportedGlob = _getSupportedGlob,
15
+ } = overrides;
16
+
17
+ return await tryToCatch(getFilesProcessor, args, options, {
18
+ fastGlob,
19
+ lstat,
20
+ getSupportedGlob,
21
+ });
16
22
  };
17
23
 
18
- async function getFiles(args, options) {
19
- const promises = args.map(addExt(options));
24
+ async function getFilesProcessor(args, options, overrides) {
25
+ const promises = args.map(addExt(options, overrides));
20
26
  const files = await Promise.all(promises);
21
27
  const mergedFiles = files.flat();
22
28
 
@@ -28,10 +34,16 @@ const globOptions = {
28
34
  dot: true,
29
35
  };
30
36
 
31
- const addExt = (options) => async function addExt(a) {
37
+ const addExt = (options, overrides = {}) => async function addExt(a) {
38
+ const {
39
+ fastGlob,
40
+ lstat,
41
+ getSupportedGlob,
42
+ } = overrides;
43
+
32
44
  const [[e], files] = await Promise.all([
33
45
  tryToCatch(lstat, a),
34
- safeGlob(a, {
46
+ safeGlob(a, fastGlob, {
35
47
  onlyFiles: false,
36
48
  ...options,
37
49
  }),
@@ -48,7 +60,7 @@ const addExt = (options) => async function addExt(a) {
48
60
 
49
61
  if (info.isDirectory()) {
50
62
  const glob = getSupportedGlob(file);
51
- promises.push(await safeGlob(glob, options));
63
+ promises.push(await safeGlob(glob, fastGlob, options));
52
64
  continue;
53
65
  }
54
66
 
@@ -69,7 +81,7 @@ function throwNotFound(a) {
69
81
  throw Error(`No files matching the pattern '${a}' were found`);
70
82
  }
71
83
 
72
- async function safeGlob(glob, options) {
84
+ async function safeGlob(glob, fastGlob, options) {
73
85
  const result = await fastGlob(unixifyPath(glob), {
74
86
  ...options,
75
87
  ...globOptions,
package/lib/cli/index.js CHANGED
@@ -8,6 +8,7 @@ const {nanomemoize} = require('nano-memoize');
8
8
  const tryCatch = require('try-catch');
9
9
  const wraptile = require('wraptile');
10
10
  const fullstore = require('fullstore');
11
+ const _cliStaged = require('@putout/cli-staged');
11
12
 
12
13
  const {
13
14
  getFilePatterns,
@@ -15,13 +16,14 @@ const {
15
16
  defaultProcessors,
16
17
  } = require('@putout/engine-processor');
17
18
 
19
+ const _initReport = require('@putout/engine-reporter/report');
18
20
  const {keypress: _keypress} = require('@putout/cli-keypress');
19
21
 
20
22
  const supportedFiles = require('./supported-files');
21
- const getOptions = require('./get-options');
23
+ const _getOptions = require('./get-options');
22
24
  const {argvConfig, parseArgs} = require('./parse-args');
23
25
 
24
- const getFiles = require('./get-files');
26
+ const {getFiles: _getFiles} = require('./get-files.mjs');
25
27
  const {version, dependencies} = require('../../package.json');
26
28
  const {formatter: defaultFormatter} = require('../../putout.json');
27
29
  const {simpleImport} = require('./simple-import');
@@ -46,11 +48,12 @@ const {
46
48
  const noop = () => {};
47
49
  const {keys} = Object;
48
50
  const {isSupported} = supportedFiles;
49
- const getFormatter = nanomemoize(require('@putout/engine-reporter/formatter').getFormatter);
51
+ const _getFormatter = nanomemoize(require('@putout/engine-reporter/formatter').getFormatter);
50
52
 
51
53
  const cwd = process.cwd();
52
- const {PUTOUT_FILES = ''} = process.env;
53
- const envNames = !PUTOUT_FILES ? [] : PUTOUT_FILES.split(',');
54
+ const {env} = process;
55
+
56
+ const getEnvNames = () => !env.PUTOUT_FILES ? [] : env.PUTOUT_FILES.split(',');
54
57
 
55
58
  const getExitCode = (wasStop) => wasStop() ? WAS_STOP : OK;
56
59
  const isStr = (a) => typeof a === 'string';
@@ -76,6 +79,13 @@ module.exports = async (overrides = {}) => {
76
79
  writeFile,
77
80
  trace = noop,
78
81
  keypress = _keypress,
82
+ getOptions = _getOptions,
83
+ getFiles = _getFiles,
84
+ cliStaged = _cliStaged,
85
+ cliCache,
86
+ initProcessFile,
87
+ initReport = _initReport,
88
+ getFormatter = _getFormatter,
79
89
  } = overrides;
80
90
 
81
91
  const isStop = parseIsStop(overrides.isStop || noop, {
@@ -212,7 +222,7 @@ module.exports = async (overrides = {}) => {
212
222
  const stagedNames = [];
213
223
 
214
224
  if (staged) {
215
- const {get} = require('@putout/cli-staged');
225
+ const {get} = cliStaged;
216
226
  const {findUp} = await simpleImport('find-up');
217
227
 
218
228
  const [error, names] = await tryToCatch(get, {
@@ -229,7 +239,7 @@ module.exports = async (overrides = {}) => {
229
239
  const globFiles = [
230
240
  ...stagedNames,
231
241
  ...args._.map(String),
232
- ...envNames,
242
+ ...getEnvNames(),
233
243
  ];
234
244
 
235
245
  const [e, names] = await getFiles(globFiles, {
@@ -247,7 +257,7 @@ module.exports = async (overrides = {}) => {
247
257
  if (noFiles)
248
258
  return exit();
249
259
 
250
- const {createCache} = await simpleImport('@putout/cli-cache');
260
+ const {createCache} = cliCache || await simpleImport('@putout/cli-cache');
251
261
 
252
262
  const fileCache = await createCache({
253
263
  version,
@@ -273,7 +283,10 @@ module.exports = async (overrides = {}) => {
273
283
  plugins,
274
284
  };
275
285
 
286
+ const report = initReport();
287
+
276
288
  const {places, exited} = await run({
289
+ report,
277
290
  processorRunners,
278
291
  trace,
279
292
  fix,
@@ -294,6 +307,7 @@ module.exports = async (overrides = {}) => {
294
307
  noConfig,
295
308
  plugins,
296
309
  transform,
310
+ initProcessFile,
297
311
  });
298
312
 
299
313
  if (exited)
@@ -313,7 +327,7 @@ module.exports = async (overrides = {}) => {
313
327
  }
314
328
 
315
329
  if (fix && staged) {
316
- const {set} = require('@putout/cli-staged');
330
+ const {set} = cliStaged;
317
331
  const {findUp} = await simpleImport('find-up');
318
332
 
319
333
  const stagedNames = await set({
@@ -1,13 +1,34 @@
1
1
  'use strict';
2
2
 
3
- const Report = require('@putout/engine-reporter/report');
4
-
5
- const initProcessFile = require('@putout/cli-process-file');
3
+ const _initProcessFile = require('@putout/cli-process-file');
6
4
  const {runWriter} = require('./writer.js');
7
5
 
8
- const report = Report();
9
-
10
- module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile, exit, isStop, wasStop, names, write, log, rulesdir, fix, processorRunners, fileCache, currentFormat, formatterOptions, options, raw, trace}) => {
6
+ module.exports.run = async (overrides) => {
7
+ const {
8
+ transform,
9
+ plugins,
10
+ noConfig,
11
+ readFile,
12
+ writeFile,
13
+ exit,
14
+ isStop,
15
+ wasStop,
16
+ names,
17
+ write,
18
+ log,
19
+ rulesdir,
20
+ fix,
21
+ processorRunners,
22
+ fileCache,
23
+ currentFormat,
24
+ formatterOptions,
25
+ options,
26
+ raw,
27
+ trace,
28
+ initProcessFile = _initProcessFile,
29
+ report,
30
+ } = overrides;
31
+
11
32
  const processFile = initProcessFile(options);
12
33
  const {length} = names;
13
34
  const places = [];
@@ -11,8 +11,15 @@ const {runReader} = require('./reader.js');
11
11
 
12
12
  const isParser = (rule) => rule.startsWith('parser');
13
13
  const isParsingError = ({rule}) => isParser(rule);
14
- const chooseName = (name, resolvedName) => !isIDE ? name : resolvedName;
15
- const isIDE = /JetBrains/.test(env.TERMINAL_EMULATOR) || env.TERM_PROGRAM === 'vscode';
14
+
15
+ const chooseName = (name, resolvedName) => !isIDE() ? name : resolvedName;
16
+
17
+ const isIDE = () => {
18
+ if (/JetBrains/.test(env.TERMINAL_EMULATOR))
19
+ return true;
20
+
21
+ return env.TERM_PROGRAM === 'vscode';
22
+ };
16
23
 
17
24
  const createFormatterProxy = (options) => {
18
25
  return new Proxy(options, {
@@ -1,4 +1,5 @@
1
1
  import process from 'node:process';
2
+ import {Buffer} from 'node:buffer';
2
3
  import {putoutAsync} from '../putout.js';
3
4
  import ignores from '../ignores.js';
4
5
  import parseOptions from '../parse-options/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "41.0.8",
3
+ "version": "41.0.10",
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",
@@ -58,7 +58,7 @@
58
58
  "@putout/cli-match": "^2.0.0",
59
59
  "@putout/cli-process-file": "^4.0.0",
60
60
  "@putout/cli-ruler": "^4.0.0",
61
- "@putout/cli-staged": "^1.0.0",
61
+ "@putout/cli-staged": "^2.0.0",
62
62
  "@putout/cli-validate-args": "^2.0.0",
63
63
  "@putout/compare": "^19.0.0",
64
64
  "@putout/engine-loader": "^16.0.0",
@@ -111,7 +111,7 @@
111
111
  "@putout/plugin-convert-to-arrow-function": "^4.0.0",
112
112
  "@putout/plugin-coverage": "^1.0.0",
113
113
  "@putout/plugin-declare": "^6.0.0",
114
- "@putout/plugin-declare-before-reference": "^8.0.0",
114
+ "@putout/plugin-declare-before-reference": "^9.0.0",
115
115
  "@putout/plugin-destructuring": "^1.0.0",
116
116
  "@putout/plugin-eslint": "^15.0.0",
117
117
  "@putout/plugin-esm": "^6.0.0",
@@ -163,7 +163,6 @@
163
163
  "@putout/plugin-remove-useless-replace": "^2.0.0",
164
164
  "@putout/plugin-remove-useless-template-expressions": "^3.0.0",
165
165
  "@putout/plugin-return": "^2.0.0",
166
- "@putout/plugin-reuse-duplicate-init": "^8.0.0",
167
166
  "@putout/plugin-simplify-ternary": "^8.0.0",
168
167
  "@putout/plugin-spread": "^1.0.0",
169
168
  "@putout/plugin-tape": "^19.0.0",
package/putout.json CHANGED
@@ -61,6 +61,7 @@
61
61
  "labels/remove-unused": "off",
62
62
  "remove-useless-escape": "off",
63
63
  "variables/remove-useless": "off",
64
+ "variables/apply-declarations-order": "off",
64
65
  "destructuring/remove-useless-variables": "off",
65
66
  "remove-useless-push": "off",
66
67
  "esm/remove-useless-export-specifiers": "off",
@@ -240,7 +241,6 @@
240
241
  "remove-unreachable-code",
241
242
  "remove-duplicate-keys",
242
243
  "return",
243
- "reuse-duplicate-init",
244
244
  "spread",
245
245
  "simplify-ternary",
246
246
  "convert-expression-to-params",