@putout/cli-process-file 2.0.1 → 2.1.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.
@@ -18,23 +18,36 @@ const JSON = {
18
18
  },
19
19
  };
20
20
 
21
+ const PACKAGE = {
22
+ ...JSON,
23
+ format: {
24
+ ...JSON.format,
25
+ indent: ' ',
26
+ },
27
+ };
28
+
21
29
  export const configurePrinter = (name, printerOptions) => {
22
30
  const [printer = 'putout', options = {}] = maybeArray(printerOptions);
23
- const ext = name
24
- .split('.')
25
- .pop();
26
31
 
27
32
  if (printer !== 'putout')
28
33
  return printerOptions;
29
34
 
30
- const mergedOptions = deepMerge(parseOptions(ext), options);
35
+ const mergedOptions = deepMerge(parseOptions(name), options);
31
36
 
32
37
  return [printer, mergedOptions];
33
38
  };
34
39
 
35
- function parseOptions(ext) {
36
- if (ext === 'json')
40
+ function parseOptions(name) {
41
+ const ext = name
42
+ .split('.')
43
+ .pop();
44
+
45
+ if (ext === 'json') {
46
+ if (name.endsWith('package.json'))
47
+ return PACKAGE;
48
+
37
49
  return JSON;
50
+ }
38
51
 
39
52
  if (ext === 'yml{json}')
40
53
  return JSON;
@@ -82,7 +82,7 @@ module.exports = ({fix, fixCount, logError, raw}) => async function processFile(
82
82
  };
83
83
  };
84
84
 
85
- function formatPlaces(line = 1, places) {
85
+ function formatPlaces(line = 0, places) {
86
86
  const newPlaces = [];
87
87
 
88
88
  for (const place of places) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/cli-process-file",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "Run all 🐊Putout linters",
6
6
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/cli-process-file#readme",