putout 26.9.2 → 26.11.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.
package/ChangeLog CHANGED
@@ -1,3 +1,32 @@
1
+ 2022.06.02, v26.11.0
2
+
3
+ fix:
4
+ - (putout) resolve name before parsing options
5
+
6
+
7
+ feature:
8
+ - (package) @putout/plugin-simplify-ternary v3.0.0
9
+ - (@putout/plugin-simplify-ternary) drop support of 🐊 < 26
10
+ - (@putout/plugin-simplify-ternary) add support of spread
11
+
12
+
13
+ 2022.06.01, v26.10.0
14
+
15
+ fix:
16
+ - (@putout/cli-cache) canUseCache: no when places.length
17
+
18
+ feature:
19
+ - (putout) process-file: --disalble-all show places found by parsers other then javascript
20
+ - (package) @putout/cli-cache v1.1.0
21
+ - (@putout/cli-cache) drop support of node < 16
22
+ - (@putout/cli-cache) canUseCache: can even if places found
23
+
24
+ 2022.05.31, v26.9.3
25
+
26
+ feature:
27
+ - (putout) cli: get rid of rawPlaces
28
+
29
+
1
30
  2022.05.31, v26.9.2
2
31
 
3
32
  feature:
package/lib/cli/index.js CHANGED
@@ -20,8 +20,6 @@ const {
20
20
  defaultProcessors,
21
21
  } = require('@putout/engine-processor');
22
22
 
23
- const merge = require('../merge');
24
-
25
23
  const getFiles = require('./get-files');
26
24
  const {createCache} = require('@putout/cli-cache');
27
25
  const supportedFiles = require('./supported-files');
@@ -277,7 +275,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
277
275
  plugins,
278
276
  };
279
277
 
280
- const {rawPlaces, exited} = await run({
278
+ const {places, exited} = await run({
281
279
  fix,
282
280
  exit,
283
281
  readFile,
@@ -301,13 +299,11 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
301
299
  if (exited)
302
300
  return;
303
301
 
304
- const mergedPlaces = merge(...rawPlaces);
305
-
306
302
  fileCache.reconcile();
307
303
 
308
304
  if (enableAll || disableAll) {
309
305
  const {ruler} = await simpleImport('@putout/cli-ruler');
310
- await ruler({enableAll, disableAll, readFile, writeFile}, mergedPlaces);
306
+ await ruler({enableAll, disableAll, readFile, writeFile}, places);
311
307
  }
312
308
 
313
309
  if (fix && staged) {
@@ -319,7 +315,7 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile})
319
315
  return exit(STAGE);
320
316
  }
321
317
 
322
- if (mergedPlaces.length)
318
+ if (places.length)
323
319
  return exit(PLACE);
324
320
 
325
321
  const exitCode = getExitCode(wasStop);
@@ -16,7 +16,7 @@ const getMatchedOptions = (name, options) => {
16
16
  return merge(options, parseMatch(name, options.match));
17
17
  };
18
18
 
19
- module.exports = ({fix, fixCount, isFlow, ruler = {}, logError, raw}) => async ({name, source, startLine, options}) => {
19
+ module.exports = ({fix, fixCount, isFlow, logError, raw}) => async ({name, source, startLine, options}) => {
20
20
  const isTS = /\.tsx?$/.test(name) || /{tsx?}$/.test(name);
21
21
  const matchedOptions = getMatchedOptions(name, options);
22
22
 
@@ -35,12 +35,6 @@ module.exports = ({fix, fixCount, isFlow, ruler = {}, logError, raw}) => async (
35
35
  const {code = source} = result || {};
36
36
  const allPlaces = result ? result.places : parseError(e);
37
37
 
38
- if (ruler.disable || ruler.enable || ruler.disableAll || ruler.enableAll)
39
- return {
40
- places: formatPlaces(startLine, allPlaces),
41
- code,
42
- };
43
-
44
38
  const [newCode, newPlaces] = await eslint({
45
39
  name,
46
40
  code,
@@ -9,7 +9,7 @@ const report = Report();
9
9
  module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile, exit, isStop, wasStop, names, write, log, rulesdir, fix, processorRunners, fileCache, currentFormat, formatterOptions, options, raw}) => {
10
10
  const processFile = initProcessFile(options);
11
11
  const {length} = names;
12
- const rawPlaces = [];
12
+ const places = [];
13
13
 
14
14
  for (let index = 0; index < length; index++) {
15
15
  if (wasStop())
@@ -19,7 +19,7 @@ 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} = await runWorker({
22
+ const {exited, places: currentPlaces = []} = await runWorker({
23
23
  readFile,
24
24
  writeFile,
25
25
  exit,
@@ -31,7 +31,6 @@ module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile,
31
31
  index: currentIndex,
32
32
  name,
33
33
  count: length,
34
- rawPlaces,
35
34
  processFile,
36
35
  fileCache,
37
36
  raw,
@@ -43,9 +42,11 @@ module.exports.run = async ({transform, plugins, noConfig, readFile, writeFile,
43
42
  transform,
44
43
  });
45
44
 
45
+ places.push(...currentPlaces);
46
+
46
47
  if (exited)
47
- return {exited, rawPlaces};
48
+ return {exited, places};
48
49
  }
49
50
 
50
- return {rawPlaces};
51
+ return {places};
51
52
  };
@@ -32,12 +32,12 @@ const createFormatterProxy = (options) => {
32
32
  });
33
33
  };
34
34
 
35
- module.exports = async ({readFile, report, writeFile, exit, raw, write, log, currentFormat, rulesdir, formatterOptions, noConfig, transform, plugins, index, fix, processFile, processorRunners, fileCache, rawPlaces, name, count}) => {
35
+ module.exports = async ({readFile, report, writeFile, exit, raw, write, log, currentFormat, rulesdir, formatterOptions, noConfig, transform, plugins, index, fix, processFile, processorRunners, fileCache, name, count}) => {
36
36
  const resolvedName = resolve(name)
37
37
  .replace(/^\./, cwd);
38
38
 
39
39
  const [configError, options] = tryCatch(getOptions, {
40
- name,
40
+ name: resolvedName,
41
41
  rulesdir,
42
42
  noConfig,
43
43
  transform,
@@ -59,7 +59,6 @@ module.exports = async ({readFile, report, writeFile, exit, raw, write, log, cur
59
59
  resolvedName,
60
60
  index,
61
61
  count,
62
- rawPlaces,
63
62
  });
64
63
 
65
64
  if (success)
@@ -109,15 +108,13 @@ module.exports = async ({readFile, report, writeFile, exit, raw, write, log, cur
109
108
  if (fixable)
110
109
  fileCache.setInfo(name, places, options);
111
110
 
112
- rawPlaces.push(places);
113
-
114
111
  return {
115
- rawPlaces,
112
+ places,
116
113
  success: true,
117
114
  };
118
115
  };
119
116
 
120
- async function runCache({fileCache, report, write, formatterOptions, currentFormat, name, resolvedName, index, count, rawPlaces, options}) {
117
+ async function runCache({fileCache, report, write, formatterOptions, currentFormat, name, resolvedName, index, count, options}) {
121
118
  if (!fileCache.canUseCache(name, options))
122
119
  return false;
123
120
 
@@ -134,7 +131,6 @@ async function runCache({fileCache, report, write, formatterOptions, currentForm
134
131
  const line = await report(currentFormat, formatterProxy);
135
132
 
136
133
  write(line || '');
137
- rawPlaces.push(places);
138
134
 
139
135
  return true;
140
136
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "26.9.2",
3
+ "version": "26.11.0",
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 and babel plugins support of js, jsx typescript, flow files, markdown, yaml and json",
@@ -47,7 +47,7 @@
47
47
  "@babel/code-frame": "^7.10.4",
48
48
  "@babel/traverse": "^7.12.5",
49
49
  "@babel/types": "^7.12.6",
50
- "@putout/cli-cache": "^1.0.0",
50
+ "@putout/cli-cache": "^1.1.0",
51
51
  "@putout/cli-keypress": "^1.0.0",
52
52
  "@putout/cli-match": "^1.0.0",
53
53
  "@putout/cli-ruler": "^2.0.0",
@@ -165,7 +165,7 @@
165
165
  "@putout/plugin-reuse-duplicate-init": "^4.0.0",
166
166
  "@putout/plugin-simplify-assignment": "^1.0.0",
167
167
  "@putout/plugin-simplify-logical-expressions": "^2.0.0",
168
- "@putout/plugin-simplify-ternary": "^2.0.0",
168
+ "@putout/plugin-simplify-ternary": "^3.0.0",
169
169
  "@putout/plugin-split-nested-destructuring": "^1.0.0",
170
170
  "@putout/plugin-split-variable-declarations": "^2.0.0",
171
171
  "@putout/plugin-strict-mode": "^5.0.0",