redlint 5.0.4 โ 5.1.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 +12 -0
- package/README.md +3 -5
- package/bin/redlint.js +12 -0
- package/lib/choose.js +2 -0
- package/lib/edit/edit.js +1 -3
- package/lib/edit/rename-files/rename-files-plugin/index.js +3 -3
- package/lib/menu.js +2 -0
- package/lib/view/parse-files/get-file-names-with-content/index.js +28 -0
- package/lib/view/parse-files/index.js +44 -0
- package/lib/view/view.js +27 -0
- package/package.json +5 -4
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2026.01.22, v5.1.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- a2d9c57 redlint: view: add
|
|
5
|
+
- d2dbad3 redlint: do not rename when different lengths
|
|
6
|
+
- a7fe951 redlint: eslint-plugin-putout v30.0.0
|
|
7
|
+
|
|
8
|
+
2026.01.18, v5.0.5
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- 9be0ae3 redlint: @putout/plugin-nodejs v19.1.0
|
|
12
|
+
|
|
1
13
|
2026.01.11, v5.0.4
|
|
2
14
|
|
|
3
15
|
feature:
|
package/README.md
CHANGED
|
@@ -60,16 +60,14 @@ You can also generate `.filesystem.json` file with `putout generate`.
|
|
|
60
60
|
|
|
61
61
|
To add new rule `create-file` located in plugin `custom` for **RedLint** write a new ๐**Putout** rule [Scanner](https://github.com/coderaiser/putout/tree/master/packages/engine-runner#scanner). And add it to `.putout.json`:
|
|
62
62
|
|
|
63
|
-
```
|
|
63
|
+
```json
|
|
64
64
|
{
|
|
65
65
|
"match": {
|
|
66
66
|
".filesystem": {
|
|
67
67
|
"custom/create-file": "on"
|
|
68
68
|
}
|
|
69
|
-
}
|
|
70
|
-
"plugins": [
|
|
71
|
-
"custom"
|
|
72
|
-
]
|
|
69
|
+
},
|
|
70
|
+
"plugins": ["custom"]
|
|
73
71
|
}
|
|
74
72
|
```
|
|
75
73
|
|
package/bin/redlint.js
CHANGED
|
@@ -29,6 +29,7 @@ import {masterConvert} from '../lib/convert/master.js';
|
|
|
29
29
|
import {askFilename} from '../lib/dialog.js';
|
|
30
30
|
import {masterRename} from '../lib/rename/master.js';
|
|
31
31
|
import {edit} from '../lib/edit/edit.js';
|
|
32
|
+
import {view} from '../lib/view/view.js';
|
|
32
33
|
import {
|
|
33
34
|
isScan,
|
|
34
35
|
isScanDebug,
|
|
@@ -54,6 +55,7 @@ import {
|
|
|
54
55
|
isBundleDebug,
|
|
55
56
|
isConvertRCToFlat,
|
|
56
57
|
isEdit,
|
|
58
|
+
isView,
|
|
57
59
|
} from '../lib/menu.js';
|
|
58
60
|
|
|
59
61
|
const {log} = console;
|
|
@@ -128,6 +130,16 @@ async function uiLoop(arg) {
|
|
|
128
130
|
|
|
129
131
|
const filesystem = lintJSON(stringify(result));
|
|
130
132
|
|
|
133
|
+
if (isView(arg)) {
|
|
134
|
+
const spinner = ora(`๐ฎ view`).start();
|
|
135
|
+
const filename = argOptions.join('');
|
|
136
|
+
|
|
137
|
+
spinner.succeed();
|
|
138
|
+
|
|
139
|
+
console.log(`\n${view(filename)}`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
131
143
|
if (isEdit(arg)) {
|
|
132
144
|
const spinner = ora(`๐ชถedit filesystem`).start();
|
|
133
145
|
const args = argOptions.join('');
|
package/lib/choose.js
CHANGED
|
@@ -2,6 +2,7 @@ import {choose as chooseDialog} from '@putout/cli-choose';
|
|
|
2
2
|
import {
|
|
3
3
|
SCAN,
|
|
4
4
|
FIX,
|
|
5
|
+
VIEW,
|
|
5
6
|
PACK,
|
|
6
7
|
EXTRACT,
|
|
7
8
|
GENERATE,
|
|
@@ -19,6 +20,7 @@ export const choose = async () => {
|
|
|
19
20
|
const command = await chooseDialog('Command:', [
|
|
20
21
|
SCAN,
|
|
21
22
|
FIX,
|
|
23
|
+
VIEW,
|
|
22
24
|
EDIT,
|
|
23
25
|
RENAME,
|
|
24
26
|
CONVERT,
|
package/lib/edit/edit.js
CHANGED
|
@@ -22,6 +22,9 @@ export const scan = (path, {push, trackFile, options}) => {
|
|
|
22
22
|
dir = '/',
|
|
23
23
|
} = options;
|
|
24
24
|
|
|
25
|
+
if (from.length !== to.length)
|
|
26
|
+
return;
|
|
27
|
+
|
|
25
28
|
if (isEqual(from, to))
|
|
26
29
|
return;
|
|
27
30
|
|
|
@@ -67,9 +70,6 @@ function getRenamedFiles(dir, a, b) {
|
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
function isEqual(a, b) {
|
|
70
|
-
if (a.length !== b.length)
|
|
71
|
-
return false;
|
|
72
|
-
|
|
73
73
|
let i = a.length;
|
|
74
74
|
|
|
75
75
|
while (--i >= 0) {
|
package/lib/menu.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const SCAN = '๐ scan';
|
|
2
2
|
export const SCAN_DEBUG = '๐ scan: debug';
|
|
3
|
+
export const VIEW = '๐ฎ view';
|
|
3
4
|
export const BUNDLE = 'bundle';
|
|
4
5
|
export const BUNDLE_DEBUG = '๐งบ bundle';
|
|
5
6
|
export const FIX = '๐จ fix';
|
|
@@ -49,6 +50,7 @@ export const isExit = (a) => a === EXIT || a === 'exit';
|
|
|
49
50
|
export const isConvert = (a) => a === CONVERT || a === 'convert';
|
|
50
51
|
export const isRename = (a) => a === RENAME || a === 'rename';
|
|
51
52
|
export const isEdit = (a) => a === EDIT || a === 'edit';
|
|
53
|
+
export const isView = (a) => a === VIEW || a === 'view';
|
|
52
54
|
export const isConvertChosen = (a) => {
|
|
53
55
|
return [
|
|
54
56
|
CONVERT_JSON_TO_JS,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
getFileType,
|
|
5
|
+
readFileContent,
|
|
6
|
+
getFilename,
|
|
7
|
+
} = operator;
|
|
8
|
+
|
|
9
|
+
export const report = (file, {line}) => {
|
|
10
|
+
const name = getFilename(file);
|
|
11
|
+
const content = readFileContent(file);
|
|
12
|
+
|
|
13
|
+
return `${line} -> ${name} -> ${content}`;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const isFile = (a) => getFileType(a) === 'file';
|
|
17
|
+
|
|
18
|
+
export const fix = () => {};
|
|
19
|
+
export const scan = (root, {push, trackFile}) => {
|
|
20
|
+
const files = trackFile(root, '*').filter(isFile);
|
|
21
|
+
const {line} = root.node.loc.start;
|
|
22
|
+
|
|
23
|
+
for (const file of files) {
|
|
24
|
+
push(file, {
|
|
25
|
+
line,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {parse, transform} from 'putout';
|
|
2
|
+
import * as getFileNamesWithContent from './get-file-names-with-content/index.js';
|
|
3
|
+
|
|
4
|
+
const {assign} = Object;
|
|
5
|
+
|
|
6
|
+
export const parseFiles = (source) => {
|
|
7
|
+
const ast = parse(source);
|
|
8
|
+
const places = transform(ast, source, {
|
|
9
|
+
fix: false,
|
|
10
|
+
plugins: [
|
|
11
|
+
['get-filenames-with-content', getFileNamesWithContent],
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const files = places.map(getNameWithContent);
|
|
16
|
+
|
|
17
|
+
return nest(files);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function nest(files) {
|
|
21
|
+
const result = {};
|
|
22
|
+
|
|
23
|
+
for (const [line, name, content] of files) {
|
|
24
|
+
result[line] = result[line] || {};
|
|
25
|
+
assign(result[line], {
|
|
26
|
+
[name]: content,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getNameWithContent = ({message}) => {
|
|
34
|
+
const [line, name] = message.split(' -> ', 2);
|
|
35
|
+
const arrowLength = ' -> '.length * 2;
|
|
36
|
+
const content = message.slice(name.length + line.length + arrowLength);
|
|
37
|
+
|
|
38
|
+
return [
|
|
39
|
+
line,
|
|
40
|
+
name,
|
|
41
|
+
content,
|
|
42
|
+
];
|
|
43
|
+
};
|
|
44
|
+
|
package/lib/view/view.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {readFileSync as _readFileSync} from 'node:fs';
|
|
2
|
+
import {codeFrameColumns} from '@putout/babel';
|
|
3
|
+
import dedent from 'dedent';
|
|
4
|
+
import {parseFiles} from './parse-files/index.js';
|
|
5
|
+
|
|
6
|
+
const {entries} = Object;
|
|
7
|
+
|
|
8
|
+
export const view = (filename, overrides = {}) => {
|
|
9
|
+
const {
|
|
10
|
+
readFileSync = _readFileSync,
|
|
11
|
+
} = overrides;
|
|
12
|
+
|
|
13
|
+
const lines = [];
|
|
14
|
+
const filesystem = readFileSync(filename, 'utf8');
|
|
15
|
+
const files = parseFiles(filesystem);
|
|
16
|
+
|
|
17
|
+
for (const [line, nameWithContent] of entries(files)) {
|
|
18
|
+
for (const [name, content] of entries(nameWithContent)) {
|
|
19
|
+
lines.push(codeFrameColumns(dedent(content), {}, {
|
|
20
|
+
forceColor: true,
|
|
21
|
+
message: `${name}:${line}`,
|
|
22
|
+
}) + '\n');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return lines.join('\n');
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redlint",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Lint Filesystem with ๐Putout",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"report": "madrun report"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@putout/babel": "^5.2.3",
|
|
33
34
|
"@putout/bundler": "^4.0.0",
|
|
34
35
|
"@putout/cli-choose": "^3.0.0",
|
|
35
36
|
"@putout/cli-filesystem": "^3.0.0",
|
|
@@ -40,11 +41,12 @@
|
|
|
40
41
|
"@putout/operator-json": "^3.1.0",
|
|
41
42
|
"@putout/plugin-eslint": "^15.0.0",
|
|
42
43
|
"@putout/plugin-filesystem": "^12.0.0",
|
|
43
|
-
"@putout/plugin-nodejs": "^
|
|
44
|
+
"@putout/plugin-nodejs": "^19.1.0",
|
|
44
45
|
"@putout/plugin-react": "^3.0.0",
|
|
45
46
|
"@putout/processor-filesystem": "^7.0.1",
|
|
46
47
|
"chalk": "^5.3.0",
|
|
47
48
|
"ci-info": "^4.0.0",
|
|
49
|
+
"dedent": "^1.7.1",
|
|
48
50
|
"enquirer": "^2.4.1",
|
|
49
51
|
"fullstore": "^4.0.0",
|
|
50
52
|
"ignore": "^7.0.0",
|
|
@@ -64,11 +66,10 @@
|
|
|
64
66
|
"generate"
|
|
65
67
|
],
|
|
66
68
|
"devDependencies": {
|
|
67
|
-
"@putout/eslint-flat": "^3.0.0",
|
|
68
69
|
"@putout/test": "^15.0.0",
|
|
69
70
|
"c8": "^10.1.2",
|
|
70
71
|
"eslint": "^9.0.0",
|
|
71
|
-
"eslint-plugin-putout": "^
|
|
72
|
+
"eslint-plugin-putout": "^30.0.0",
|
|
72
73
|
"just-kebab-case": "^4.2.0",
|
|
73
74
|
"madrun": "^12.0.0",
|
|
74
75
|
"montag": "^1.0.0",
|