redlint 6.7.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,18 @@
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
+
9
+ 2026.06.07, v6.8.0
10
+
11
+ feature:
12
+ - 4bd96fe redlint: convert: convert-toml-to-yaml: add
13
+ - c58d5a5 convert-json-to-toml: add
14
+ - 2978ff4 redlint: convert toml to json
15
+
1
16
  2026.06.07, v6.7.0
2
17
 
3
18
  feature:
@@ -0,0 +1,14 @@
1
+ import * as pluginFilesystem from '@putout/plugin-filesystem';
2
+
3
+ const [, pluginConvertJsonToToml] = pluginFilesystem.rules['convert-json-to-toml'];
4
+
5
+ export const convertJsonToToml = (filename) => ({
6
+ rules: {
7
+ 'filesystem/convert-json-to-toml': ['on', {
8
+ filename,
9
+ }],
10
+ },
11
+ plugins: [
12
+ ['filesystem/convert-json-to-toml', pluginConvertJsonToToml],
13
+ ],
14
+ });
@@ -0,0 +1,14 @@
1
+ import * as pluginFilesystem from '@putout/plugin-filesystem';
2
+
3
+ const [, pluginConvertTomlToJson] = pluginFilesystem.rules['convert-toml-to-json'];
4
+
5
+ export const convertTomlToJson = (filename) => ({
6
+ rules: {
7
+ 'filesystem/convert-toml-to-json': ['on', {
8
+ filename,
9
+ }],
10
+ },
11
+ plugins: [
12
+ ['filesystem/convert-toml-to-json', pluginConvertTomlToJson],
13
+ ],
14
+ });
@@ -0,0 +1,14 @@
1
+ import * as pluginFilesystem from '@putout/plugin-filesystem';
2
+
3
+ const [, pluginConvertTomlToYaml] = pluginFilesystem.rules['convert-toml-to-yaml'];
4
+
5
+ export const convertTomlToYaml = (filename) => ({
6
+ rules: {
7
+ 'filesystem/convert-toml-to-yaml': ['on', {
8
+ filename,
9
+ }],
10
+ },
11
+ plugins: [
12
+ ['filesystem/convert-toml-to-yaml', pluginConvertTomlToYaml],
13
+ ],
14
+ });
@@ -7,12 +7,21 @@ import {
7
7
  CONVERT_YAML_TO_JSON_DEBUG,
8
8
  CONVERT_JSON_TO_YAML,
9
9
  CONVERT_JSON_TO_YAML_DEBUG,
10
+ CONVERT_TOML_TO_JSON,
11
+ CONVERT_TOML_TO_JSON_DEBUG,
12
+ CONVERT_JSON_TO_TOML,
13
+ CONVERT_JSON_TO_TOML_DEBUG,
14
+ CONVERT_TOML_TO_YAML,
15
+ CONVERT_TOML_TO_YAML_DEBUG,
10
16
  CONVERT_RC_TO_FLAT,
11
17
  } from '../menu.js';
12
18
  import {convertYamlToJson} from './converters/convert-yaml-to-json.js';
13
19
  import {convertJsonToYaml} from './converters/convert-json-to-yaml.js';
14
20
  import {convertJsonToJs} from './converters/convert-json-to-js.js';
15
21
  import {convertJSToJson} from './converters/convert-js-to-json.js';
22
+ import {convertTomlToJson} from './converters/convert-toml-to-json.js';
23
+ import {convertJsonToToml} from './converters/convert-json-to-toml.js';
24
+ import {convertTomlToYaml} from './converters/convert-toml-to-yaml.js';
16
25
  import {convertRCToFlat} from './converters/convert-rc-to-flat.js';
17
26
 
18
27
  const CONVERTERS = {
@@ -24,6 +33,12 @@ const CONVERTERS = {
24
33
  [CONVERT_YAML_TO_JSON_DEBUG]: convertYamlToJson,
25
34
  [CONVERT_JSON_TO_YAML]: convertJsonToYaml,
26
35
  [CONVERT_JSON_TO_YAML_DEBUG]: convertJsonToYaml,
36
+ [CONVERT_TOML_TO_JSON]: convertTomlToJson,
37
+ [CONVERT_TOML_TO_JSON_DEBUG]: convertTomlToJson,
38
+ [CONVERT_JSON_TO_TOML]: convertJsonToToml,
39
+ [CONVERT_JSON_TO_TOML_DEBUG]: convertJsonToToml,
40
+ [CONVERT_TOML_TO_YAML]: convertTomlToYaml,
41
+ [CONVERT_TOML_TO_YAML_DEBUG]: convertTomlToYaml,
27
42
  [CONVERT_RC_TO_FLAT]: convertRCToFlat,
28
43
  };
29
44
 
@@ -7,6 +7,9 @@ import {
7
7
  CONVERT_RC_TO_FLAT,
8
8
  CONVERT_YAML_TO_JSON,
9
9
  CONVERT_JSON_TO_YAML,
10
+ CONVERT_TOML_TO_JSON,
11
+ CONVERT_JSON_TO_TOML,
12
+ CONVERT_TOML_TO_YAML,
10
13
  } from '../menu.js';
11
14
 
12
15
  export * from './convert.js';
@@ -16,6 +19,9 @@ export const chooseConvert = async () => {
16
19
  CONVERT_JSON_TO_JS,
17
20
  CONVERT_YAML_TO_JSON,
18
21
  CONVERT_JSON_TO_YAML,
22
+ CONVERT_TOML_TO_JSON,
23
+ CONVERT_JSON_TO_TOML,
24
+ CONVERT_TOML_TO_YAML,
19
25
  CONVERT_RC_TO_FLAT,
20
26
  BACK,
21
27
  EXIT,
package/lib/menu.js CHANGED
@@ -32,6 +32,15 @@ export const CONVERT_YAML_TO_JSON_DEBUG = '🦏 convert yaml to json: debug';
32
32
  export const CONVERT_JSON_TO_YAML = '🦏 convert json to yaml';
33
33
  export const CONVERT_JSON_TO_YAML_DEBUG = '🦏 convert json to yaml: debug';
34
34
 
35
+ export const CONVERT_TOML_TO_JSON = '🦏 convert toml to json';
36
+ export const CONVERT_TOML_TO_JSON_DEBUG = '🦏 convert toml to json: debug';
37
+
38
+ export const CONVERT_JSON_TO_TOML = '🦏 convert json to toml';
39
+ export const CONVERT_JSON_TO_TOML_DEBUG = '🦏 convert json to toml: debug';
40
+
41
+ export const CONVERT_TOML_TO_YAML = '🦏 convert toml to yaml';
42
+ export const CONVERT_TOML_TO_YAML_DEBUG = '🦏 convert toml to yaml: debug';
43
+
35
44
  export const RENAME_JS_TO_JSX = '🦏 rename js to jsx';
36
45
  export const RENAME_JS_TO_JSX_DEBUG = '🦏 rename js to jsx: debug';
37
46
 
@@ -64,6 +73,9 @@ export const isConvertChosen = (a) => {
64
73
  CONVERT_JS_TO_JSON,
65
74
  CONVERT_YAML_TO_JSON,
66
75
  CONVERT_JSON_TO_YAML,
76
+ CONVERT_TOML_TO_JSON,
77
+ CONVERT_JSON_TO_TOML,
78
+ CONVERT_TOML_TO_YAML,
67
79
  CONVERT_RC_TO_FLAT,
68
80
  ].includes(a);
69
81
  };
@@ -74,6 +86,9 @@ export const isConvertChosenDebug = (a) => [
74
86
  CONVERT_JSON_TO_JS_DEBUG,
75
87
  CONVERT_YAML_TO_JSON_DEBUG,
76
88
  CONVERT_JSON_TO_YAML_DEBUG,
89
+ CONVERT_TOML_TO_JSON_DEBUG,
90
+ CONVERT_JSON_TO_TOML_DEBUG,
91
+ CONVERT_TOML_TO_YAML_DEBUG,
77
92
  ].includes(a);
78
93
 
79
94
  export const isConvertRCToFlat = (a) => a === CONVERT_RC_TO_FLAT;
@@ -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.7.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",