redlint 3.0.0 → 3.0.1
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 +7 -0
- package/bin/redlint.js +62 -12
- package/lib/help.js +15 -11
- package/lib/start.js +21 -0
- package/package.json +5 -2
package/ChangeLog
CHANGED
package/bin/redlint.js
CHANGED
|
@@ -3,23 +3,41 @@
|
|
|
3
3
|
import {lintJSON} from 'putout/lint/json';
|
|
4
4
|
import process from 'node:process';
|
|
5
5
|
import {writeFile} from 'node:fs/promises';
|
|
6
|
+
import stripAnsi from 'strip-ansi';
|
|
6
7
|
import formatterCodeFrame from '@putout/formatter-codeframe';
|
|
8
|
+
import formatterDump from '@putout/formatter-dump';
|
|
7
9
|
import ora from 'ora';
|
|
8
10
|
import {help} from '../lib/help.js';
|
|
11
|
+
import {start} from '../lib/start.js';
|
|
9
12
|
import {buildTree} from '../lib/redlint.js';
|
|
10
13
|
import {convertToSimple} from '../lib/simple.js';
|
|
11
14
|
import {masterLint} from '../lib/master.js';
|
|
12
15
|
import {lint} from '../lib/lint.js';
|
|
16
|
+
import {logo} from '../lib/logo.js';
|
|
13
17
|
|
|
14
18
|
const {stringify} = JSON;
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
let [arg] = process.argv.slice(2);
|
|
21
|
+
let header = true;
|
|
17
22
|
|
|
18
|
-
if (!arg
|
|
19
|
-
|
|
23
|
+
if (!arg) {
|
|
24
|
+
const cmd = await start();
|
|
25
|
+
|
|
26
|
+
if (!cmd)
|
|
27
|
+
process.exit(1);
|
|
28
|
+
|
|
29
|
+
[arg] = stripAnsi(cmd).split(' ');
|
|
30
|
+
header = false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (arg === 'help') {
|
|
34
|
+
help({
|
|
35
|
+
header,
|
|
36
|
+
});
|
|
20
37
|
process.exit();
|
|
21
38
|
}
|
|
22
39
|
|
|
40
|
+
console.log('Running:');
|
|
23
41
|
const spinner = ora('index filesystem').start();
|
|
24
42
|
const result = await buildTree(process.cwd());
|
|
25
43
|
|
|
@@ -33,31 +51,55 @@ if (arg === 'simple') {
|
|
|
33
51
|
const filesystem = lintJSON(stringify(result));
|
|
34
52
|
|
|
35
53
|
if (arg === 'scan') {
|
|
36
|
-
const
|
|
54
|
+
const places = await masterLint(filesystem, {
|
|
37
55
|
fix: false,
|
|
38
56
|
});
|
|
39
57
|
|
|
40
|
-
if (!
|
|
58
|
+
if (!places.length)
|
|
41
59
|
process.exit();
|
|
42
60
|
|
|
43
|
-
console.
|
|
61
|
+
console.log('');
|
|
62
|
+
const dump = await formatterDump({
|
|
63
|
+
name: '.filesystem.json',
|
|
64
|
+
source: filesystem,
|
|
65
|
+
places,
|
|
66
|
+
index: 0,
|
|
67
|
+
count: places.length,
|
|
68
|
+
filesCount: 1,
|
|
69
|
+
errorsCount: places.length,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
process.stderr.write(dump);
|
|
73
|
+
|
|
44
74
|
process.exit(1);
|
|
45
75
|
}
|
|
46
76
|
|
|
47
|
-
if (arg === '
|
|
48
|
-
const
|
|
77
|
+
if (arg === 'scan:frame') {
|
|
78
|
+
const places = await masterLint(filesystem, {
|
|
49
79
|
fix: true,
|
|
50
80
|
});
|
|
51
81
|
|
|
82
|
+
const result = await formatterCodeFrame({
|
|
83
|
+
name: '.filesystem.json',
|
|
84
|
+
source: filesystem,
|
|
85
|
+
places,
|
|
86
|
+
index: 0,
|
|
87
|
+
count: places.length,
|
|
88
|
+
filesCount: 1,
|
|
89
|
+
errorsCount: places.length,
|
|
90
|
+
});
|
|
91
|
+
|
|
52
92
|
process.stderr.write(result);
|
|
53
|
-
process.exit();
|
|
93
|
+
process.exit(1);
|
|
54
94
|
}
|
|
55
95
|
|
|
56
|
-
if (arg === '
|
|
57
|
-
const places =
|
|
96
|
+
if (arg === 'lint') {
|
|
97
|
+
const places = lint(filesystem, {
|
|
58
98
|
fix: true,
|
|
59
99
|
});
|
|
60
100
|
|
|
101
|
+
console.log(logo);
|
|
102
|
+
|
|
61
103
|
const result = await formatterCodeFrame({
|
|
62
104
|
name: '.filesystem.json',
|
|
63
105
|
source: filesystem,
|
|
@@ -68,7 +110,15 @@ if (arg === 'fix') {
|
|
|
68
110
|
errorsCount: places.length,
|
|
69
111
|
});
|
|
70
112
|
|
|
71
|
-
process.
|
|
113
|
+
process.stderr.write(result);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (arg === 'fix') {
|
|
118
|
+
await masterLint(filesystem, {
|
|
119
|
+
fix: true,
|
|
120
|
+
});
|
|
121
|
+
|
|
72
122
|
process.exit();
|
|
73
123
|
}
|
|
74
124
|
|
package/lib/help.js
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import {logo} from './logo.js';
|
|
2
|
-
import chalk from 'chalk';
|
|
3
2
|
import process from 'node:process';
|
|
4
3
|
|
|
5
|
-
export const help = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export const help = ({header = true}) => {
|
|
5
|
+
if (header) {
|
|
6
|
+
console.log('Lint your files according to 🐊Putout rules.\n');
|
|
7
|
+
process.stdout.write(logo);
|
|
8
|
+
console.log('');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
console.log(`Usage: redlint [command]`);
|
|
12
|
+
|
|
10
13
|
console.log(`Commands:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
scan - scan files according to 🐊Putout rules
|
|
15
|
+
scan:frame - scan files, show results in code frame
|
|
16
|
+
fix - fix files according to 🐊Putout rules
|
|
17
|
+
help - show help screen and exit
|
|
18
|
+
generate - generate .filesystem.json file and exit
|
|
15
19
|
`);
|
|
16
20
|
|
|
17
|
-
console.log('
|
|
21
|
+
console.log('');
|
|
18
22
|
};
|
package/lib/start.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {logo} from './logo.js';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import {choose} from '@putout/cli-choose';
|
|
4
|
+
|
|
5
|
+
export const start = async () => {
|
|
6
|
+
console.log('Lint your files according to 🐊Putout rules.\n');
|
|
7
|
+
process.stdout.write(logo);
|
|
8
|
+
console.log('');
|
|
9
|
+
|
|
10
|
+
const command = await choose('Command:', [
|
|
11
|
+
'scan',
|
|
12
|
+
'scan:frame',
|
|
13
|
+
'fix',
|
|
14
|
+
'help',
|
|
15
|
+
'generate',
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
console.log('');
|
|
19
|
+
|
|
20
|
+
return command;
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redlint",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Lint Filesystem with 🐊Putout",
|
|
@@ -30,14 +30,17 @@
|
|
|
30
30
|
"report": "madrun report"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@putout/cli-choose": "^1.1.1",
|
|
33
34
|
"@putout/engine-runner": "^20.1.0",
|
|
34
35
|
"@putout/formatter-codeframe": "^6.0.0",
|
|
36
|
+
"@putout/formatter-dump": "^4.0.1",
|
|
35
37
|
"@putout/processor-filesystem": "^3.0.0",
|
|
36
38
|
"chalk": "^5.3.0",
|
|
37
39
|
"fullstore": "^3.0.0",
|
|
38
40
|
"ignore": "^5.2.4",
|
|
39
41
|
"ora": "^7.0.1",
|
|
40
|
-
"putout": "^34.0.0"
|
|
42
|
+
"putout": "^34.0.0",
|
|
43
|
+
"strip-ansi": "^7.1.0"
|
|
41
44
|
},
|
|
42
45
|
"keywords": [
|
|
43
46
|
"putout",
|