redlint 6.8.0 → 6.9.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,11 @@
1
+ 2026.06.08, v6.9.0
2
+
3
+ feature:
4
+ - 07c69cd test: compare-files: no file found
5
+ - da040d4 redlint: test: run: module.exports overwrite
6
+ - 3747c0e redlint: test: transformWithOptions
7
+ - 3b2954b redlint: test: read-fixture: rm unused names
8
+
1
9
  2026.06.07, v6.8.0
2
10
 
3
11
  feature:
@@ -14,7 +14,7 @@ export function compareFiles({transformed, correct}) {
14
14
 
15
15
  for (const [line, files] of entries(outputFiles)) {
16
16
  for (const [name, content] of entries(files)) {
17
- const correctContent = correctFiles[line][name];
17
+ const correctContent = correctFiles[line][name] || '';
18
18
 
19
19
  if (correctContent === content)
20
20
  continue;
@@ -1,16 +1,32 @@
1
1
  import {operator} from 'putout';
2
2
 
3
- const {getTemplateValues} = operator;
3
+ const {stringify} = JSON;
4
+
5
+ const {
6
+ getTemplateValues,
7
+ compare,
8
+ } = operator;
9
+
4
10
  const TRANSFORM = 't.transform(__a)';
5
11
  const TRANSFORM_COUPLE = 't.transform(__a, __b)';
12
+ const TRANSFORM_WITH_OPTIONS = 't.transformWithOptions(__a, __b)';
6
13
 
7
- export const report = parseValue;
14
+ export const report = (path) => {
15
+ const name = parseName(path);
16
+ const options = parseOptions(path);
17
+
18
+ return `${name} -> ${options}`;
19
+ };
8
20
 
9
21
  export const fix = () => {};
10
22
 
11
- export const include = () => [TRANSFORM, TRANSFORM_COUPLE];
23
+ export const include = () => [
24
+ TRANSFORM,
25
+ TRANSFORM_COUPLE,
26
+ TRANSFORM_WITH_OPTIONS,
27
+ ];
12
28
 
13
- function parseValue(path) {
29
+ function parseName(path) {
14
30
  const {length} = path.node.arguments;
15
31
 
16
32
  if (length === 1) {
@@ -22,3 +38,12 @@ function parseValue(path) {
22
38
 
23
39
  return __a.value;
24
40
  }
41
+
42
+ function parseOptions(path) {
43
+ if (!compare(path, TRANSFORM_WITH_OPTIONS))
44
+ return '{}';
45
+
46
+ const {value} = path.get('arguments.1').evaluate();
47
+
48
+ return stringify(value, null, 4);
49
+ }
@@ -2,7 +2,12 @@ import {putout} from 'putout';
2
2
  import * as getFixtureNamesPlugin from './get-fixture-names-plugin/index.js';
3
3
  import * as getFixtureOnlyNamesPlugin from './get-fixture-only-names-plugin/index.js';
4
4
 
5
- const getName = (a) => a.message;
5
+ const {parse} = JSON;
6
+
7
+ const getNameWithOptions = (a) => {
8
+ return a.message.split(' -> ');
9
+ };
10
+
6
11
  const isOnly = (a) => a.rule === 'get-fixture-only-names';
7
12
 
8
13
  export const getFixtureNames = (source) => {
@@ -17,11 +22,11 @@ export const getFixtureNames = (source) => {
17
22
  const fixturesOnly = places.filter(isOnly);
18
23
 
19
24
  if (fixturesOnly.length) {
20
- const names = fixturesOnly.map(getName);
25
+ const names = fixturesOnly.map(getNameWithOptions);
21
26
  return convertToTuple(names);
22
27
  }
23
28
 
24
- const names = places.map(getName);
29
+ const names = places.map(getNameWithOptions);
25
30
 
26
31
  return convertToTuple(names);
27
32
  };
@@ -29,11 +34,11 @@ export const getFixtureNames = (source) => {
29
34
  function convertToTuple(names) {
30
35
  const result = [];
31
36
 
32
- for (const base of names) {
37
+ for (const [base, options = '{}'] of names) {
33
38
  const name = `${base}.js`;
34
39
  const nameFix = `${base}-fix.js`;
35
40
 
36
- result.push([name, nameFix]);
41
+ result.push([name, nameFix, parse(options)]);
37
42
  }
38
43
 
39
44
  return result;
@@ -6,12 +6,10 @@ const {fromEntries, entries} = Object;
6
6
  const getMessage = (a) => a.message;
7
7
  const SPLITTER = ' -> ';
8
8
 
9
- export const readFixture = (ast, names) => {
9
+ export const readFixture = (ast) => {
10
10
  const places = transform(ast, {
11
11
  rules: {
12
- 'read-fixture': ['on', {
13
- names,
14
- }],
12
+ 'read-fixture': 'on',
15
13
  },
16
14
  plugins: [
17
15
  ['read-fixture', readFixturesPlugin],
@@ -2,19 +2,26 @@ import {putout} from 'putout';
2
2
 
3
3
  const noop = () => {};
4
4
 
5
- export const run = (content, options) => {
6
- const {require = noop, incorrect} = options;
5
+ export const run = (content, config) => {
6
+ const {
7
+ require = noop,
8
+ incorrect,
9
+ options,
10
+ } = config;
7
11
 
8
12
  if (!incorrect)
9
13
  return;
10
14
 
11
15
  const plugin = createPlugin(content, require);
12
16
 
13
- return runPlugin(plugin, incorrect);
17
+ return runPlugin(plugin, incorrect, options);
14
18
  };
15
19
 
16
- function runPlugin(plugin, source) {
20
+ function runPlugin(plugin, source, options) {
17
21
  const {code} = putout(source, {
22
+ rules: {
23
+ run: ['on', options],
24
+ },
18
25
  plugins: [
19
26
  ['run', plugin],
20
27
  ],
@@ -41,5 +48,5 @@ function createPlugin(content, require) {
41
48
 
42
49
  fn(module, exports, require);
43
50
 
44
- return exports;
51
+ return module.exports;
45
52
  }
package/lib/test/test.js CHANGED
@@ -46,11 +46,12 @@ export const test = (filesystem, overrides = {}) => {
46
46
 
47
47
  initFixture(ast, names);
48
48
 
49
- const fixture = readFixture(ast, names);
49
+ const fixture = readFixture(ast);
50
50
 
51
51
  const plugin = readFileContent(index);
52
52
  const filename = getFilename(index);
53
53
  const require = createRequire(filename);
54
+ const options = buildOptions(names);
54
55
 
55
56
  const output = ['\n'];
56
57
  const log = createLog(output);
@@ -59,6 +60,7 @@ export const test = (filesystem, overrides = {}) => {
59
60
  const transformed = run(plugin, {
60
61
  require,
61
62
  incorrect,
63
+ options: options[name],
62
64
  });
63
65
 
64
66
  const status = correct === transformed ? SUCCESS : FAIL;
@@ -98,3 +100,15 @@ export const test = (filesystem, overrides = {}) => {
98
100
 
99
101
  return [null, output.join('')];
100
102
  };
103
+
104
+ const cutExtension = (a) => a.replace('.js', '');
105
+
106
+ function buildOptions(names) {
107
+ const options = {};
108
+
109
+ for (const [name, , currentOptions] of names) {
110
+ options[cutExtension(name)] = currentOptions;
111
+ }
112
+
113
+ return options;
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redlint",
3
- "version": "6.8.0",
3
+ "version": "6.9.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Lint Filesystem with 🐊Putout",