@putout/test 7.5.0 → 7.6.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/README.md +13 -1
- package/lib/pre-test.js +1 -0
- package/lib/test.js +23 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -209,6 +209,18 @@ test('test: no report after transform', (t) => {
|
|
|
209
209
|
});
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
+
|
|
213
|
+
### `noReportAfterTransformWithOptions(filename)`
|
|
214
|
+
|
|
215
|
+
Check error message of a plugin not produced with provided options:
|
|
216
|
+
|
|
217
|
+
```js
|
|
218
|
+
test('test: no report', (t) => {
|
|
219
|
+
t.noReportAfterTransformWithOptions('file');
|
|
220
|
+
t.end();
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
212
224
|
### `noTransform(filename)`
|
|
213
225
|
|
|
214
226
|
Check transform of `filename.js` produce nothing
|
|
@@ -398,7 +410,7 @@ test('test: eslint: transform', (t) => {
|
|
|
398
410
|
### `report(filename, message | []messages)`
|
|
399
411
|
|
|
400
412
|
```js
|
|
401
|
-
test('test: eslint:
|
|
413
|
+
test('test: eslint: report', (t) => {
|
|
402
414
|
t.report('remove-debugger', `Avoid 'debugger' statement`);
|
|
403
415
|
t.end();
|
|
404
416
|
});
|
package/lib/pre-test.js
CHANGED
|
@@ -8,6 +8,7 @@ const maybeTuple = (a) => isArray(a) ? a : ['on', a];
|
|
|
8
8
|
const maybeEntries = (a) => isArray(a) ? a : entries(a).pop();
|
|
9
9
|
|
|
10
10
|
module.exports._maybeEntries = maybeEntries;
|
|
11
|
+
module.exports._maybeTuple = maybeTuple;
|
|
11
12
|
|
|
12
13
|
module.exports.preTest = function preTest(test, plugin) {
|
|
13
14
|
const [name, {
|
package/lib/test.js
CHANGED
|
@@ -110,6 +110,7 @@ function createTest(dir, maybeOptions) {
|
|
|
110
110
|
report: report(dir, options),
|
|
111
111
|
noReport: noReport(dir, options),
|
|
112
112
|
noReportAfterTransform: noReportAfterTransform(dir, options),
|
|
113
|
+
noReportAfterTransformWithOptions: noReportAfterTransformWithOptions(dir, options),
|
|
113
114
|
reportWithOptions: reportWithOptions(dir, options),
|
|
114
115
|
noReportWithOptions: noReportWithOptions(dir, options),
|
|
115
116
|
reportCode: reportCode(options),
|
|
@@ -259,9 +260,8 @@ const toObject = (array) => {
|
|
|
259
260
|
const result = {};
|
|
260
261
|
const first = parsePlugin(array);
|
|
261
262
|
|
|
262
|
-
if (isObject(first) && !isArray(first))
|
|
263
|
+
if (isObject(first) && !isArray(first))
|
|
263
264
|
return first;
|
|
264
|
-
}
|
|
265
265
|
|
|
266
266
|
for (const [name, value] of array) {
|
|
267
267
|
result[name] = value;
|
|
@@ -453,6 +453,27 @@ const noReportAfterTransform = currify((dir, options, t, name) => {
|
|
|
453
453
|
|
|
454
454
|
module.exports._createNoReportAfterTransform = noReportAfterTransform;
|
|
455
455
|
|
|
456
|
+
const noReportAfterTransformWithOptions = currify((dir, options, t, name, ruleOptions) => {
|
|
457
|
+
const full = join(dir, name);
|
|
458
|
+
const [source, isTS] = readFixture(full);
|
|
459
|
+
const rule = parseRule(options);
|
|
460
|
+
|
|
461
|
+
const rules = {
|
|
462
|
+
[rule]: ['on', ruleOptions],
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
return noReportCodeAfterTransform({
|
|
466
|
+
isTS,
|
|
467
|
+
...options,
|
|
468
|
+
rules: {
|
|
469
|
+
...options.rules,
|
|
470
|
+
...rules,
|
|
471
|
+
},
|
|
472
|
+
}, t, source);
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
module.exports._createNoReportAfterTransformWithOptions = noReportAfterTransformWithOptions;
|
|
476
|
+
|
|
456
477
|
const reportWithOptions = currify((dir, options, t, name, message, ruleOptions) => {
|
|
457
478
|
const full = join(dir, name);
|
|
458
479
|
const [source, isTS] = readFixture(full);
|