redlint 6.9.0 → 6.9.2
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/CONTRIBUTING.md +6 -34
- package/ChangeLog +15 -0
- package/bin/redlint.js +12 -2
- package/lib/convert/converters/convert-yaml-to-toml.js +14 -0
- package/lib/convert/create-options.js +5 -0
- package/lib/convert/dsl/dsl.js +56 -0
- package/lib/convert/dsl/parse-converter.js +13 -0
- package/lib/convert/index.js +2 -0
- package/lib/menu.js +5 -0
- package/lib/test/get-fixture-names/get-fixture-only-names-plugin/index.js +20 -3
- package/package.json +1 -1
package/CONTRIBUTING.md
CHANGED
|
@@ -186,47 +186,19 @@ Used in `bin/redlint.js`:
|
|
|
186
186
|
import {edit, editHelp} from '#edit';
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
## File Tree
|
|
190
|
-
|
|
191
|
-
```
|
|
192
|
-
redlint/
|
|
193
|
-
├── bin/redlint.js # CLI entry point
|
|
194
|
-
├── lib/
|
|
195
|
-
│ ├── convert/ # convert json↔js, rc→flat
|
|
196
|
-
│ ├── edit/ # interactive filesystem editing
|
|
197
|
-
│ ├── extract/ # unpack filesystem.red
|
|
198
|
-
│ ├── help/ # --help output
|
|
199
|
-
│ ├── lint/ # scan & fix filesystem
|
|
200
|
-
│ ├── pack/ # pack to filesystem.red
|
|
201
|
-
│ ├── rename/ # rename js↔jsx
|
|
202
|
-
│ ├── test/ # test runner & plugins
|
|
203
|
-
│ ├── view/ # view file contents
|
|
204
|
-
│ ├── cli/ # version
|
|
205
|
-
│ ├── choose.js # interactive menu
|
|
206
|
-
│ ├── debug.js # debug menu
|
|
207
|
-
│ ├── dialog.js # ask for filename
|
|
208
|
-
│ ├── menu.js # menu constants & predicates
|
|
209
|
-
│ ├── redlint.js # buildTree
|
|
210
|
-
│ ├── run.js # worker runner
|
|
211
|
-
│ ├── simple.js # simple filesystem format
|
|
212
|
-
│ ├── slave.js # worker helper
|
|
213
|
-
│ └── spinner.js # CLI spinner
|
|
214
|
-
├── test/ # integration tests
|
|
215
|
-
├── .nycrc.json # coverage config (100% required)
|
|
216
|
-
├── .madrun.js # task runner scripts
|
|
217
|
-
├── .putout.json # putout rules
|
|
218
|
-
└── package.json
|
|
219
|
-
```
|
|
220
|
-
|
|
221
189
|
## Overrides Pattern
|
|
222
190
|
|
|
223
191
|
When a module calls external dependencies, accept them as optional overrides so tests can inject stubs:
|
|
224
192
|
|
|
225
193
|
```js
|
|
194
|
+
import {operator} from 'putout';
|
|
195
|
+
|
|
196
|
+
const {getFilename} = operator;
|
|
197
|
+
|
|
226
198
|
// run-convert.js
|
|
227
199
|
export const runConvert = async (arg, filesystem, overrides = {}) => {
|
|
228
200
|
const {
|
|
229
|
-
|
|
201
|
+
getFilename = askFilename,
|
|
230
202
|
convert = masterConvert,
|
|
231
203
|
isRCToFlat = isConvertRCToFlat,
|
|
232
204
|
} = overrides;
|
|
@@ -234,7 +206,7 @@ export const runConvert = async (arg, filesystem, overrides = {}) => {
|
|
|
234
206
|
let filename = '.eslintrc.json';
|
|
235
207
|
|
|
236
208
|
if (!isRCToFlat(arg))
|
|
237
|
-
filename = await
|
|
209
|
+
filename = await askFilename();
|
|
238
210
|
|
|
239
211
|
if (filename)
|
|
240
212
|
return await convert(filename, arg, filesystem);
|
package/ChangeLog
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
2026.06.09, v6.9.2
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 4c437c3 redlint: convert: dsl
|
|
5
|
+
- 365da21 redlint: run-convert-with-options: -h
|
|
6
|
+
- 73a02b3 redlint: run-convert-with-options: add
|
|
7
|
+
- aada911 run-convert-with-options: parser-converter
|
|
8
|
+
- 3dc97b9 redlint: convert yaml to toml: add
|
|
9
|
+
- 32d279a redlint: run convert with options
|
|
10
|
+
|
|
11
|
+
2026.06.08, v6.9.1
|
|
12
|
+
|
|
13
|
+
feature:
|
|
14
|
+
- 23baaca test: get-fixture-names: only
|
|
15
|
+
|
|
1
16
|
2026.06.08, v6.9.0
|
|
2
17
|
|
|
3
18
|
feature:
|
package/bin/redlint.js
CHANGED
|
@@ -32,6 +32,7 @@ import {askFilename} from '../lib/dialog.js';
|
|
|
32
32
|
import {masterRename} from '../lib/rename/master.js';
|
|
33
33
|
import {view} from '../lib/view/view.js';
|
|
34
34
|
import {test} from '../lib/test/test.js';
|
|
35
|
+
import {runDSLConverter} from '../lib/convert/dsl/dsl.js';
|
|
35
36
|
import {
|
|
36
37
|
isScan,
|
|
37
38
|
isScanDebug,
|
|
@@ -103,7 +104,7 @@ async function uiLoop(arg) {
|
|
|
103
104
|
return process.exit();
|
|
104
105
|
}
|
|
105
106
|
|
|
106
|
-
if (isConvert(arg))
|
|
107
|
+
if (isConvert(arg) && !argOptions.length)
|
|
107
108
|
arg = await chooseConvert();
|
|
108
109
|
|
|
109
110
|
if (isRename(arg))
|
|
@@ -158,7 +159,7 @@ async function uiLoop(arg) {
|
|
|
158
159
|
const [error, result] = test(filesystem);
|
|
159
160
|
|
|
160
161
|
if (error)
|
|
161
|
-
return console.error(
|
|
162
|
+
return console.error(error.message);
|
|
162
163
|
|
|
163
164
|
stdout.write(result);
|
|
164
165
|
return;
|
|
@@ -188,6 +189,15 @@ async function uiLoop(arg) {
|
|
|
188
189
|
});
|
|
189
190
|
}
|
|
190
191
|
|
|
192
|
+
if (isConvert(arg) && argOptions.length) {
|
|
193
|
+
const [error] = runDSLConverter(filesystem, argOptions);
|
|
194
|
+
|
|
195
|
+
if (error)
|
|
196
|
+
console.error(error.message);
|
|
197
|
+
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
191
201
|
if (isConvertChosen(arg)) {
|
|
192
202
|
await runConvert(arg, filesystem);
|
|
193
203
|
return;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as pluginFilesystem from '@putout/plugin-filesystem';
|
|
2
|
+
|
|
3
|
+
const [, pluginConvertYamlToToml] = pluginFilesystem.rules['convert-yaml-to-toml'];
|
|
4
|
+
|
|
5
|
+
export const convertYamlToToml = (filename) => ({
|
|
6
|
+
rules: {
|
|
7
|
+
'filesystem/convert-yaml-to-toml': ['on', {
|
|
8
|
+
filename,
|
|
9
|
+
}],
|
|
10
|
+
},
|
|
11
|
+
plugins: [
|
|
12
|
+
['filesystem/convert-yaml-to-toml', pluginConvertYamlToToml],
|
|
13
|
+
],
|
|
14
|
+
});
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
CONVERT_TOML_TO_JSON_DEBUG,
|
|
12
12
|
CONVERT_JSON_TO_TOML,
|
|
13
13
|
CONVERT_JSON_TO_TOML_DEBUG,
|
|
14
|
+
CONVERT_YAML_TO_TOML,
|
|
15
|
+
CONVERT_YAML_TO_TOML_DEBUG,
|
|
14
16
|
CONVERT_TOML_TO_YAML,
|
|
15
17
|
CONVERT_TOML_TO_YAML_DEBUG,
|
|
16
18
|
CONVERT_RC_TO_FLAT,
|
|
@@ -22,6 +24,7 @@ import {convertJSToJson} from './converters/convert-js-to-json.js';
|
|
|
22
24
|
import {convertTomlToJson} from './converters/convert-toml-to-json.js';
|
|
23
25
|
import {convertJsonToToml} from './converters/convert-json-to-toml.js';
|
|
24
26
|
import {convertTomlToYaml} from './converters/convert-toml-to-yaml.js';
|
|
27
|
+
import {convertYamlToToml} from './converters/convert-yaml-to-toml.js';
|
|
25
28
|
import {convertRCToFlat} from './converters/convert-rc-to-flat.js';
|
|
26
29
|
|
|
27
30
|
const CONVERTERS = {
|
|
@@ -37,6 +40,8 @@ const CONVERTERS = {
|
|
|
37
40
|
[CONVERT_TOML_TO_JSON_DEBUG]: convertTomlToJson,
|
|
38
41
|
[CONVERT_JSON_TO_TOML]: convertJsonToToml,
|
|
39
42
|
[CONVERT_JSON_TO_TOML_DEBUG]: convertJsonToToml,
|
|
43
|
+
[CONVERT_YAML_TO_TOML]: convertYamlToToml,
|
|
44
|
+
[CONVERT_YAML_TO_TOML_DEBUG]: convertYamlToToml,
|
|
40
45
|
[CONVERT_TOML_TO_YAML]: convertTomlToYaml,
|
|
41
46
|
[CONVERT_TOML_TO_YAML_DEBUG]: convertTomlToYaml,
|
|
42
47
|
[CONVERT_RC_TO_FLAT]: convertRCToFlat,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import {convert as convertFile} from '../convert.js';
|
|
2
|
+
import {
|
|
3
|
+
CONVERT_JSON_TO_JS,
|
|
4
|
+
CONVERT_JS_TO_JSON,
|
|
5
|
+
CONVERT_YAML_TO_JSON,
|
|
6
|
+
CONVERT_JSON_TO_YAML,
|
|
7
|
+
CONVERT_TOML_TO_JSON,
|
|
8
|
+
CONVERT_JSON_TO_TOML,
|
|
9
|
+
CONVERT_YAML_TO_TOML,
|
|
10
|
+
CONVERT_TOML_TO_YAML,
|
|
11
|
+
} from '../../menu.js';
|
|
12
|
+
import {parseConverter} from './parse-converter.js';
|
|
13
|
+
|
|
14
|
+
const CONVERT_TYPE_MAP = new Map([
|
|
15
|
+
['json -> js', CONVERT_JSON_TO_JS],
|
|
16
|
+
['js -> json', CONVERT_JS_TO_JSON],
|
|
17
|
+
['yaml -> json', CONVERT_YAML_TO_JSON],
|
|
18
|
+
['json -> yaml', CONVERT_JSON_TO_YAML],
|
|
19
|
+
['toml -> json', CONVERT_TOML_TO_JSON],
|
|
20
|
+
['json -> toml', CONVERT_JSON_TO_TOML],
|
|
21
|
+
['yaml -> toml', CONVERT_YAML_TO_TOML],
|
|
22
|
+
['toml -> yaml', CONVERT_TOML_TO_YAML],
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
export const runDSLConverter = (filesystem, argOptions, overrides = {}) => {
|
|
26
|
+
const {
|
|
27
|
+
convert = convertFile,
|
|
28
|
+
branch,
|
|
29
|
+
merge,
|
|
30
|
+
} = overrides;
|
|
31
|
+
|
|
32
|
+
const [first] = argOptions;
|
|
33
|
+
|
|
34
|
+
if (['-h', '--help'].includes(first))
|
|
35
|
+
return [Error('a -> b: c, toml -> json: bunfig.toml')];
|
|
36
|
+
|
|
37
|
+
const [from, to, filename] = parseConverter(argOptions);
|
|
38
|
+
const typeStr = `${from} -> ${to}`;
|
|
39
|
+
const type = CONVERT_TYPE_MAP.get(typeStr);
|
|
40
|
+
|
|
41
|
+
if (!type)
|
|
42
|
+
return [Error(`Unknown conversion '${typeStr}'`)];
|
|
43
|
+
|
|
44
|
+
if (!filename)
|
|
45
|
+
return [Error('Filename is required')];
|
|
46
|
+
|
|
47
|
+
const result = convert(filename, type, filesystem, {
|
|
48
|
+
branch,
|
|
49
|
+
merge,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (result === filesystem)
|
|
53
|
+
return [Error('No files matched')];
|
|
54
|
+
|
|
55
|
+
return [null, result];
|
|
56
|
+
};
|
package/lib/convert/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
CONVERT_JSON_TO_YAML,
|
|
10
10
|
CONVERT_TOML_TO_JSON,
|
|
11
11
|
CONVERT_JSON_TO_TOML,
|
|
12
|
+
CONVERT_YAML_TO_TOML,
|
|
12
13
|
CONVERT_TOML_TO_YAML,
|
|
13
14
|
} from '../menu.js';
|
|
14
15
|
|
|
@@ -21,6 +22,7 @@ export const chooseConvert = async () => {
|
|
|
21
22
|
CONVERT_JSON_TO_YAML,
|
|
22
23
|
CONVERT_TOML_TO_JSON,
|
|
23
24
|
CONVERT_JSON_TO_TOML,
|
|
25
|
+
CONVERT_YAML_TO_TOML,
|
|
24
26
|
CONVERT_TOML_TO_YAML,
|
|
25
27
|
CONVERT_RC_TO_FLAT,
|
|
26
28
|
BACK,
|
package/lib/menu.js
CHANGED
|
@@ -38,6 +38,9 @@ export const CONVERT_TOML_TO_JSON_DEBUG = '🦏 convert toml to json: debug';
|
|
|
38
38
|
export const CONVERT_JSON_TO_TOML = '🦏 convert json to toml';
|
|
39
39
|
export const CONVERT_JSON_TO_TOML_DEBUG = '🦏 convert json to toml: debug';
|
|
40
40
|
|
|
41
|
+
export const CONVERT_YAML_TO_TOML = '🦏 convert yaml to toml';
|
|
42
|
+
export const CONVERT_YAML_TO_TOML_DEBUG = '🦏 convert yaml to toml: debug';
|
|
43
|
+
|
|
41
44
|
export const CONVERT_TOML_TO_YAML = '🦏 convert toml to yaml';
|
|
42
45
|
export const CONVERT_TOML_TO_YAML_DEBUG = '🦏 convert toml to yaml: debug';
|
|
43
46
|
|
|
@@ -75,6 +78,7 @@ export const isConvertChosen = (a) => {
|
|
|
75
78
|
CONVERT_JSON_TO_YAML,
|
|
76
79
|
CONVERT_TOML_TO_JSON,
|
|
77
80
|
CONVERT_JSON_TO_TOML,
|
|
81
|
+
CONVERT_YAML_TO_TOML,
|
|
78
82
|
CONVERT_TOML_TO_YAML,
|
|
79
83
|
CONVERT_RC_TO_FLAT,
|
|
80
84
|
].includes(a);
|
|
@@ -88,6 +92,7 @@ export const isConvertChosenDebug = (a) => [
|
|
|
88
92
|
CONVERT_JSON_TO_YAML_DEBUG,
|
|
89
93
|
CONVERT_TOML_TO_JSON_DEBUG,
|
|
90
94
|
CONVERT_JSON_TO_TOML_DEBUG,
|
|
95
|
+
CONVERT_YAML_TO_TOML_DEBUG,
|
|
91
96
|
CONVERT_TOML_TO_YAML_DEBUG,
|
|
92
97
|
].includes(a);
|
|
93
98
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {operator} from 'putout';
|
|
2
2
|
|
|
3
|
+
const {stringify} = JSON;
|
|
4
|
+
|
|
3
5
|
const {
|
|
4
6
|
getTemplateValues,
|
|
5
7
|
compare,
|
|
@@ -7,18 +9,24 @@ const {
|
|
|
7
9
|
|
|
8
10
|
const TRANSFORM = 't.transform(__a)';
|
|
9
11
|
const TRANSFORM_COUPLE = 't.transform(__a, __b)';
|
|
12
|
+
const TRANSFORM_WITH_OPTIONS = 't.transformWithOptions(__a, __b)';
|
|
10
13
|
|
|
11
|
-
export const report =
|
|
14
|
+
export const report = (path) => {
|
|
15
|
+
const name = parseName(path);
|
|
16
|
+
const options = parseOptions(path);
|
|
17
|
+
|
|
18
|
+
return `${name} -> ${options}`;
|
|
19
|
+
};
|
|
12
20
|
|
|
13
21
|
export const fix = () => {};
|
|
14
22
|
|
|
15
|
-
export const include = () => [TRANSFORM, TRANSFORM_COUPLE];
|
|
23
|
+
export const include = () => [TRANSFORM, TRANSFORM_COUPLE, TRANSFORM_WITH_OPTIONS];
|
|
16
24
|
|
|
17
25
|
export const filter = (path) => {
|
|
18
26
|
return compare(path.parentPath.parentPath, 'test.only(__a, __b)');
|
|
19
27
|
};
|
|
20
28
|
|
|
21
|
-
function
|
|
29
|
+
function parseName(path) {
|
|
22
30
|
const {length} = path.node.arguments;
|
|
23
31
|
|
|
24
32
|
if (length === 1) {
|
|
@@ -30,3 +38,12 @@ function parseValue(path) {
|
|
|
30
38
|
|
|
31
39
|
return __a.value;
|
|
32
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
|
+
}
|