putout 33.6.1 → 33.7.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,28 @@
1
+ 2023.11.17, v33.7.0
2
+
3
+ fix:
4
+ - 0650c3c03 @putout/plugin-nextjs: update-tsconfig: disabled by default
5
+
6
+ feature:
7
+ - cd981e88c @putout/plugin-putout: declare: matchFiles: add
8
+ - 3b577c59d @putout/operator-match-files: add
9
+ - 2dff879d0 putout: exports: transform, findPlaces
10
+ - c8be4d2d0 @putout/plugin-nextjs: update-tsconfig-file: reuse update-tsconfig-file
11
+ - 80cd0b2a7 @putout/plugin-nextjs: update-tsconfig: add
12
+ - f48b53485 @putout/plugin-nextjs: update-tsconfig-file: add
13
+
14
+ 2023.11.16, v33.6.2
15
+
16
+ fix:
17
+ - eae45513d @putout/operator-filesystem: writeFileContent: base64
18
+
19
+ feature:
20
+ - 70959a20b putout: @putout/plugin-eslint v6.0.0
21
+ - 9841829ab @putout/plugin-eslint: drop support of 🐊 < 33
22
+ - 6b06a327e @putout/operate: setLiteralValue: empty double quotes in raw
23
+ - 7a5dfa11b @putout/operator-filesystem: use base64 inside readFileContent/writeFileContent
24
+ - ad1a02449 @putotu/operator-filesystem: writeFileContent: field exists
25
+
1
26
  2023.11.15, v33.6.1
2
27
 
3
28
  feature:
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+
3
+ const loader = require('@putout/engine-loader');
4
+ const runner = require('@putout/engine-runner');
5
+
6
+ module.exports.defaultOptions = (opts = {}) => {
7
+ const {
8
+ parser = 'babel',
9
+ printer = opts.printer || 'putout',
10
+ fix = true,
11
+ fixCount = 2,
12
+ loadPlugins = loader.loadPlugins,
13
+ loadPluginsAsync = loader.loadPluginsAsync,
14
+ runPlugins = runner.runPlugins,
15
+ } = opts;
16
+
17
+ return {
18
+ ...opts,
19
+ parser,
20
+ printer,
21
+ fix,
22
+ fixCount,
23
+ loadPlugins,
24
+ loadPluginsAsync,
25
+ runPlugins,
26
+ };
27
+ };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const {transform, transformAsync} = require('./transform');
4
+
5
+ module.exports.findPlaces = (ast, source, opts) => {
6
+ return transform(ast, source, {
7
+ ...opts,
8
+ fix: false,
9
+ });
10
+ };
11
+
12
+ module.exports.findPlacesAsync = async (ast, source, opts) => {
13
+ return await transformAsync(ast, source, {
14
+ ...opts,
15
+ fix: false,
16
+ });
17
+ };
package/lib/putout.js CHANGED
@@ -1,10 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const {traverse, types} = require('@putout/babel');
4
-
5
- const loader = require('@putout/engine-loader');
6
- const runner = require('@putout/engine-runner');
7
-
8
4
  const {
9
5
  parse,
10
6
  print,
@@ -13,35 +9,19 @@ const {
13
9
  } = require('@putout/engine-parser');
14
10
 
15
11
  const {cutShebang, mergeShebang} = require('./shebang');
12
+ const {defaultOptions} = require('./default-options');
13
+ const {transform, transformAsync} = require('./transform');
16
14
 
17
- const isString = (a) => typeof a === 'string';
15
+ const {
16
+ findPlaces,
17
+ findPlacesAsync,
18
+ } = require('./find-places');
18
19
 
19
- const defaultOpts = (opts = {}) => {
20
- const {
21
- parser = 'babel',
22
- printer = opts.printer || 'putout',
23
- fix = true,
24
- fixCount = 2,
25
- loadPlugins = loader.loadPlugins,
26
- loadPluginsAsync = loader.loadPluginsAsync,
27
- runPlugins = runner.runPlugins,
28
- } = opts;
29
-
30
- return {
31
- ...opts,
32
- parser,
33
- printer,
34
- fix,
35
- fixCount,
36
- loadPlugins,
37
- loadPluginsAsync,
38
- runPlugins,
39
- };
40
- };
20
+ const isString = (a) => typeof a === 'string';
41
21
 
42
22
  module.exports = (source, opts) => {
43
23
  check(source);
44
- opts = defaultOpts(opts);
24
+ opts = defaultOptions(opts);
45
25
 
46
26
  const {
47
27
  parser,
@@ -87,7 +67,7 @@ module.exports = (source, opts) => {
87
67
 
88
68
  module.exports.putoutAsync = async (source, opts) => {
89
69
  check(source);
90
- opts = defaultOpts(opts);
70
+ opts = defaultOptions(opts);
91
71
 
92
72
  const {
93
73
  parser,
@@ -131,93 +111,11 @@ module.exports.putoutAsync = async (source, opts) => {
131
111
  };
132
112
  };
133
113
 
114
+ module.exports.transform = transform;
134
115
  module.exports.transformAsync = transformAsync;
135
- module.exports.findPlaces = (ast, source, opts) => {
136
- return transform(ast, source, {
137
- ...opts,
138
- fix: false,
139
- });
140
- };
141
- module.exports.findPlacesAsync = async (ast, source, opts) => {
142
- return await transformAsync(ast, source, {
143
- ...opts,
144
- fix: false,
145
- });
146
- };
147
-
148
- async function transformAsync(ast, source, opts) {
149
- opts = defaultOpts(opts);
150
-
151
- const {
152
- plugins: pluginNames,
153
- cache,
154
- rules,
155
- fix,
156
- fixCount,
157
- loadPluginsAsync,
158
- runPlugins,
159
- } = opts;
160
-
161
- const [, shebang] = cutShebang(source);
162
-
163
- const plugins = await loadPluginsAsync({
164
- pluginNames,
165
- cache,
166
- rules,
167
- });
168
-
169
- const places = runPlugins({
170
- ast,
171
- shebang,
172
- fix,
173
- fixCount,
174
- plugins,
175
- });
176
-
177
- return places;
178
- }
179
116
 
180
- // why we pass 'source' to 'transform()'?
181
- // because we need to calculate position in a right way
182
- // and determine is shebang is exists
183
- //
184
- // 25 return {¬
185
- // 26 line: shebang ? line + 1 : line,¬
186
- // 27 column,¬
187
- // 28 };¬
188
- //
189
- module.exports.transform = transform;
190
- function transform(ast, source, opts) {
191
- opts = defaultOpts(opts);
192
-
193
- const {
194
- plugins: pluginNames,
195
- cache,
196
- rules,
197
- fix,
198
- fixCount,
199
- loadPlugins,
200
- runPlugins,
201
- } = opts;
202
-
203
- const [, shebang] = cutShebang(source);
204
-
205
- const plugins = loadPlugins({
206
- pluginNames,
207
- cache,
208
- rules,
209
- });
210
-
211
- const places = runPlugins({
212
- ast,
213
- shebang,
214
- fix,
215
- fixCount,
216
- plugins,
217
- });
218
-
219
- return places;
220
- }
117
+ module.exports.findPlaces = findPlaces;
118
+ module.exports.findPlacesAsync = findPlacesAsync;
221
119
 
222
120
  module.exports.parse = parse;
223
121
  module.exports.print = print;
@@ -236,6 +134,7 @@ module.exports.operator = {
236
134
  ...require('@putout/operator-regexp'),
237
135
  ...require('@putout/operator-add-args'),
238
136
  ...require('@putout/operator-filesystem'),
137
+ ...require('@putout/operator-match-files'),
239
138
  };
240
139
 
241
140
  module.exports.ignores = require('./ignores');
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ const {defaultOptions} = require('./default-options');
4
+ const {cutShebang} = require('./shebang');
5
+
6
+ // why we pass 'source' to 'transform()'?
7
+ // because we need to calculate position in a right way
8
+ // and determine is shebang is exists
9
+ //
10
+ // 25 return {¬
11
+ // 26 line: shebang ? line + 1 : line,¬
12
+ // 27 column,¬
13
+ // 28 };¬
14
+ //
15
+ module.exports.transform = (ast, source, opts) => {
16
+ opts = defaultOptions(opts);
17
+
18
+ const {
19
+ plugins: pluginNames,
20
+ cache,
21
+ rules,
22
+ fix,
23
+ fixCount,
24
+ loadPlugins,
25
+ runPlugins,
26
+ } = opts;
27
+
28
+ const [, shebang] = cutShebang(source);
29
+
30
+ const plugins = loadPlugins({
31
+ pluginNames,
32
+ cache,
33
+ rules,
34
+ });
35
+
36
+ const places = runPlugins({
37
+ ast,
38
+ shebang,
39
+ fix,
40
+ fixCount,
41
+ plugins,
42
+ });
43
+
44
+ return places;
45
+ };
46
+
47
+ module.exports.transformAsync = async (ast, source, opts) => {
48
+ opts = defaultOptions(opts);
49
+
50
+ const {
51
+ plugins: pluginNames,
52
+ cache,
53
+ rules,
54
+ fix,
55
+ fixCount,
56
+ loadPluginsAsync,
57
+ runPlugins,
58
+ } = opts;
59
+
60
+ const [, shebang] = cutShebang(source);
61
+
62
+ const plugins = await loadPluginsAsync({
63
+ pluginNames,
64
+ cache,
65
+ rules,
66
+ });
67
+
68
+ const places = runPlugins({
69
+ ast,
70
+ shebang,
71
+ fix,
72
+ fixCount,
73
+ plugins,
74
+ });
75
+
76
+ return places;
77
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "33.6.1",
3
+ "version": "33.7.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, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -19,7 +19,9 @@
19
19
  "./cli/run": "./lib/cli/runner/work",
20
20
  "./loader": "./lib/loader.mjs",
21
21
  "./package.json": "./package.json",
22
- "./lint/json": "./lib/lint/json.mjs"
22
+ "./lint/json": "./lib/lint/json.mjs",
23
+ "./transform": "./lib/transform.js",
24
+ "./find-places": "./lib/find-places.js"
23
25
  },
24
26
  "bin": {
25
27
  "putout": "bin/putout.mjs"
@@ -73,6 +75,7 @@
73
75
  "@putout/operator-declare": "^8.0.0",
74
76
  "@putout/operator-filesystem": "^2.0.0",
75
77
  "@putout/operator-json": "^1.0.1",
78
+ "@putout/operator-match-files": "^1.0.0",
76
79
  "@putout/operator-regexp": "^1.0.0",
77
80
  "@putout/plugin-apply-at": "^2.0.0",
78
81
  "@putout/plugin-apply-destructuring": "^7.0.0",
@@ -101,7 +104,7 @@
101
104
  "@putout/plugin-declare": "^2.0.0",
102
105
  "@putout/plugin-declare-before-reference": "^3.0.0",
103
106
  "@putout/plugin-declare-imports-first": "^2.0.0",
104
- "@putout/plugin-eslint": "^5.0.0",
107
+ "@putout/plugin-eslint": "^6.0.0",
105
108
  "@putout/plugin-extract-object-properties": "^9.0.0",
106
109
  "@putout/plugin-extract-sequence-expressions": "^3.0.0",
107
110
  "@putout/plugin-filesystem": "^1.0.0",