@putout/test 14.0.0 → 14.2.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 CHANGED
@@ -70,6 +70,20 @@ const test = createTest(import.meta.url, {
70
70
  });
71
71
  ```
72
72
 
73
+ And apply new [operators](https://github.com/coderaiser/supertape?tab=readme-ov-file#operators):
74
+
75
+ ```js
76
+ const test = createTest(import.meta.url, {
77
+ extension: 'wast',
78
+ lint: putout,
79
+ plugins: [
80
+ ['remove-unused-variables', rmVars],
81
+ ],
82
+ }, {
83
+ render: (operator) => (name) => operator.transform,
84
+ });
85
+ ```
86
+
73
87
  ### `report(filename, message: string | string[], plugins?: PutoutPlugin[])`
74
88
 
75
89
  Check error message (or messages) of a plugin:
@@ -10,7 +10,7 @@ import {
10
10
  basename,
11
11
  } from 'node:path';
12
12
  import process from 'node:process';
13
- import eslint from '@putout/eslint';
13
+ import {eslint} from '@putout/eslint';
14
14
  import tryToCatch from 'try-to-catch';
15
15
  import {extend} from 'supertape';
16
16
  import {lint} from '@putout/eslint/lint';
@@ -22,7 +22,7 @@ const {isArray} = Array;
22
22
  const isUpdate = () => process.env.UPDATE === '1';
23
23
 
24
24
  const update = (name, data) => {
25
- const fn = global.writeFileSync || writeFileSync;
25
+ const fn = globalThis.writeFileSync || writeFileSync;
26
26
  fn(name, data);
27
27
  };
28
28
 
@@ -31,7 +31,7 @@ const remove = (name) => {
31
31
  const base = basename(name, ext);
32
32
  const fixtureName = name.replace(base, `${base}-fix`);
33
33
 
34
- const fn = global.unlinkSync || unlinkSync;
34
+ const fn = globalThis.unlinkSync || unlinkSync;
35
35
 
36
36
  tryCatch(fn, String(fixtureName));
37
37
  };
package/lib/fixture.js CHANGED
@@ -10,7 +10,7 @@ const TS = {
10
10
  };
11
11
 
12
12
  module.exports.readFixture = (name, extension) => {
13
- const {readFileSync} = global.__putout_test_fs;
13
+ const {readFileSync} = globalThis.__putout_test_fs;
14
14
  const [eTS, dataTS] = tryCatch(readFileSync, `${name}.ts`, 'utf8');
15
15
 
16
16
  if (!eTS)
@@ -44,27 +44,27 @@ module.exports.readFixture = (name, extension) => {
44
44
  };
45
45
 
46
46
  module.exports.writeFixFixture = ({full, code, extension}) => {
47
- const {writeFileSync} = global.__putout_test_fs;
47
+ const {writeFileSync} = globalThis.__putout_test_fs;
48
48
  writeFileSync(`${full}-fix.${extension}`, code);
49
49
  };
50
50
 
51
51
  module.exports.writeFormatFixture = (full, code) => {
52
- const {writeFileSync} = global.__putout_test_fs;
52
+ const {writeFileSync} = globalThis.__putout_test_fs;
53
53
  writeFileSync(`${full}-format`, code);
54
54
  };
55
55
 
56
56
  module.exports.readFormatFixture = (full) => {
57
- const {readFileSync} = global.__putout_test_fs;
57
+ const {readFileSync} = globalThis.__putout_test_fs;
58
58
  return readFileSync(`${full}-format`, 'utf8');
59
59
  };
60
60
 
61
61
  module.exports.writeFixture = ({full, code, extension}) => {
62
- const {writeFileSync} = global.__putout_test_fs;
62
+ const {writeFileSync} = globalThis.__putout_test_fs;
63
63
  writeFileSync(`${full}.${extension}`, code);
64
64
  };
65
65
 
66
66
  module.exports.rmFixture = (name, extension) => {
67
- const {unlinkSync} = global.__putout_test_fs;
67
+ const {unlinkSync} = globalThis.__putout_test_fs;
68
68
 
69
69
  if (!isUpdate())
70
70
  return;
package/lib/pre-test.js CHANGED
@@ -30,6 +30,8 @@ module.exports.preTest = function preTest(test, plugin) {
30
30
  scan,
31
31
  }] = maybeEntries(plugin);
32
32
 
33
+ isArray(plugin);
34
+
33
35
  const options = {
34
36
  checkDuplicates: false,
35
37
  };
@@ -19,20 +19,20 @@ const processFile = require('@putout/cli-process-file');
19
19
  const {runProcessors} = require('@putout/engine-processor');
20
20
 
21
21
  const isStr = (a) => typeof a === 'string';
22
- const isUpdate = () => Number(global.process.env.UPDATE);
22
+ const isUpdate = () => Number(globalThis.process.env.UPDATE);
23
23
 
24
24
  const update = async (a, b) => {
25
- const write = global.writeFile || writeFile;
25
+ const write = globalThis.writeFile || writeFile;
26
26
  await write(a, b);
27
27
  };
28
28
 
29
29
  const remove = async (a) => {
30
- const remove = global.unlink || unlink;
30
+ const remove = globalThis.unlink || unlink;
31
31
  await tryToCatch(remove, a);
32
32
  };
33
33
 
34
34
  const read = async (a, b) => {
35
- const read = global.readFile || readFile;
35
+ const read = globalThis.readFile || readFile;
36
36
  return await read(a, b);
37
37
  };
38
38
 
@@ -47,7 +47,7 @@ const addDot = (a) => a ? `.${a}` : '';
47
47
  const fail = (t, message) => {
48
48
  const {
49
49
  __putout_test_fail = t.fail,
50
- } = global;
50
+ } = globalThis;
51
51
 
52
52
  return __putout_test_fail(message);
53
53
  };
package/lib/test.js CHANGED
@@ -18,6 +18,7 @@ const {createProgress} = require('@putout/engine-runner/progress');
18
18
 
19
19
  const {createError} = require('./create-error');
20
20
  const {preTest} = require('./pre-test');
21
+
21
22
  const {
22
23
  format,
23
24
  noFormat,
@@ -37,7 +38,7 @@ const isObject = (a) => typeof a === 'object';
37
38
 
38
39
  const {keys} = Object;
39
40
 
40
- global.__putout_test_fs = {
41
+ globalThis.__putout_test_fs = {
41
42
  readFileSync,
42
43
  writeFileSync,
43
44
  existsSync,
@@ -49,7 +50,7 @@ const isUpdate = () => Boolean(Number(process.env.UPDATE));
49
50
  const fail = (t, message) => {
50
51
  const {
51
52
  __putout_test_fail = t.fail,
52
- } = global;
53
+ } = globalThis;
53
54
 
54
55
  return __putout_test_fail(message);
55
56
  };
@@ -64,11 +65,11 @@ const parsePlugin = (plugins) => {
64
65
  return plugins;
65
66
  };
66
67
 
67
- function createTest(dir, maybeOptions) {
68
+ function createTest(dir, maybeOptions, maybeExtends = {}) {
68
69
  dir = join(dir, 'fixture');
69
70
 
70
71
  const {
71
- extension = [],
72
+ extension = '',
72
73
  lint = putout,
73
74
  ...options
74
75
  } = parseOptions(maybeOptions);
@@ -105,6 +106,7 @@ function createTest(dir, maybeOptions) {
105
106
  format: format(dir, options),
106
107
  formatMany: formatMany(dir, options),
107
108
  noFormat: noFormat(dir, options),
109
+ ...maybeExtends,
108
110
  });
109
111
  }
110
112
 
@@ -210,7 +212,6 @@ const transformWithOptions = currify((dir, linterOptions, options, t, name, plug
210
212
  const [input, isTS, currentExtension] = readFixture(full, extension);
211
213
 
212
214
  const rule = parseRule(options);
213
-
214
215
  const rules = {
215
216
  [rule]: ['on', pluginOptions],
216
217
  };
package/lib/test.mjs CHANGED
@@ -4,9 +4,9 @@ import create from './test.js';
4
4
 
5
5
  export default create;
6
6
 
7
- export const createTest = (url, plugins) => {
7
+ export const createTest = (url, plugins, maybeExtends) => {
8
8
  const __filename = fileURLToPath(url);
9
9
  const __dirname = dirname(__filename);
10
10
 
11
- return create(__dirname, plugins);
11
+ return create(__dirname, plugins, maybeExtends);
12
12
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "14.0.0",
3
+ "version": "14.2.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Test runner for 🐊Putout plugins ",
@@ -41,7 +41,7 @@
41
41
  "@putout/cli-process-file": "^4.0.0",
42
42
  "@putout/engine-processor": "*",
43
43
  "@putout/engine-runner": "*",
44
- "@putout/eslint": "^4.0.0",
44
+ "@putout/eslint": "^5.0.0",
45
45
  "@putout/plugin-filesystem": "*",
46
46
  "currify": "^4.0.0",
47
47
  "montag": "^1.2.1",
@@ -61,20 +61,18 @@
61
61
  "@putout/eslint-flat": "^3.0.0",
62
62
  "@putout/formatter-dump": "*",
63
63
  "@putout/formatter-progress": "*",
64
+ "@putout/plugin-destructuring": "*",
64
65
  "@putout/plugin-esm": "*",
65
- "@putout/plugin-extract-object-properties": "*",
66
66
  "@putout/plugin-putout": "*",
67
67
  "@putout/plugin-remove-console": "*",
68
- "@putout/plugin-remove-unused-variables": "*",
68
+ "@putout/plugin-variables": "*",
69
69
  "@putout/processor-wasm": "*",
70
70
  "c8": "^10.0.0",
71
- "eslint": "^9.0.0",
71
+ "eslint": "^10.0.0-alpha.0",
72
72
  "eslint-plugin-n": "^17.0.0",
73
- "eslint-plugin-putout": "^28.0.0",
73
+ "eslint-plugin-putout": "^29.0.0",
74
74
  "madrun": "^11.0.0",
75
- "mock-require": "^3.0.3",
76
- "nodemon": "^3.0.1",
77
- "strip-ansi": "^7.1.0"
75
+ "nodemon": "^3.0.1"
78
76
  },
79
77
  "license": "MIT",
80
78
  "engines": {