redlint 3.0.0 → 3.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/bin/redlint.js +66 -13
- package/lib/choose.js +23 -0
- package/lib/help.js +16 -11
- package/lib/master.js +1 -2
- package/package.json +5 -2
package/ChangeLog
CHANGED
package/bin/redlint.js
CHANGED
|
@@ -3,29 +3,50 @@
|
|
|
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 {choose} from '../lib/choose.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 choose();
|
|
25
|
+
|
|
26
|
+
if (!cmd)
|
|
27
|
+
process.exit(1);
|
|
28
|
+
|
|
29
|
+
[arg] = stripAnsi(cmd).split(' ');
|
|
30
|
+
header = false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (arg === 'exit')
|
|
34
|
+
process.exit();
|
|
35
|
+
|
|
36
|
+
if (arg === 'help') {
|
|
37
|
+
help({
|
|
38
|
+
header,
|
|
39
|
+
});
|
|
20
40
|
process.exit();
|
|
21
41
|
}
|
|
22
42
|
|
|
43
|
+
console.log('Running:');
|
|
23
44
|
const spinner = ora('index filesystem').start();
|
|
24
45
|
const result = await buildTree(process.cwd());
|
|
25
46
|
|
|
26
47
|
spinner.succeed();
|
|
27
48
|
|
|
28
|
-
if (arg === 'simple') {
|
|
49
|
+
if (arg === 'generate:simple') {
|
|
29
50
|
await writeFile('.filesystem.json', lintJSON(stringify(convertToSimple(result))));
|
|
30
51
|
process.exit(0);
|
|
31
52
|
}
|
|
@@ -33,31 +54,55 @@ if (arg === 'simple') {
|
|
|
33
54
|
const filesystem = lintJSON(stringify(result));
|
|
34
55
|
|
|
35
56
|
if (arg === 'scan') {
|
|
36
|
-
const
|
|
57
|
+
const places = await masterLint(filesystem, {
|
|
37
58
|
fix: false,
|
|
38
59
|
});
|
|
39
60
|
|
|
40
|
-
if (!
|
|
61
|
+
if (!places.length)
|
|
41
62
|
process.exit();
|
|
42
63
|
|
|
43
|
-
console.
|
|
64
|
+
console.log('');
|
|
65
|
+
const dump = await formatterDump({
|
|
66
|
+
name: '.filesystem.json',
|
|
67
|
+
source: filesystem,
|
|
68
|
+
places,
|
|
69
|
+
index: 0,
|
|
70
|
+
count: places.length,
|
|
71
|
+
filesCount: 1,
|
|
72
|
+
errorsCount: places.length,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
process.stderr.write(dump);
|
|
76
|
+
|
|
44
77
|
process.exit(1);
|
|
45
78
|
}
|
|
46
79
|
|
|
47
|
-
if (arg === '
|
|
48
|
-
const
|
|
80
|
+
if (arg === 'scan:frame') {
|
|
81
|
+
const places = await masterLint(filesystem, {
|
|
49
82
|
fix: true,
|
|
50
83
|
});
|
|
51
84
|
|
|
85
|
+
const result = await formatterCodeFrame({
|
|
86
|
+
name: '.filesystem.json',
|
|
87
|
+
source: filesystem,
|
|
88
|
+
places,
|
|
89
|
+
index: 0,
|
|
90
|
+
count: places.length,
|
|
91
|
+
filesCount: 1,
|
|
92
|
+
errorsCount: places.length,
|
|
93
|
+
});
|
|
94
|
+
|
|
52
95
|
process.stderr.write(result);
|
|
53
|
-
process.exit();
|
|
96
|
+
process.exit(1);
|
|
54
97
|
}
|
|
55
98
|
|
|
56
|
-
if (arg === '
|
|
57
|
-
const places =
|
|
99
|
+
if (arg === 'lint') {
|
|
100
|
+
const places = lint(filesystem, {
|
|
58
101
|
fix: true,
|
|
59
102
|
});
|
|
60
103
|
|
|
104
|
+
console.log(logo);
|
|
105
|
+
|
|
61
106
|
const result = await formatterCodeFrame({
|
|
62
107
|
name: '.filesystem.json',
|
|
63
108
|
source: filesystem,
|
|
@@ -68,7 +113,15 @@ if (arg === 'fix') {
|
|
|
68
113
|
errorsCount: places.length,
|
|
69
114
|
});
|
|
70
115
|
|
|
71
|
-
process.
|
|
116
|
+
process.stderr.write(result);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (arg === 'fix') {
|
|
121
|
+
await masterLint(filesystem, {
|
|
122
|
+
fix: true,
|
|
123
|
+
});
|
|
124
|
+
|
|
72
125
|
process.exit();
|
|
73
126
|
}
|
|
74
127
|
|
package/lib/choose.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {logo} from './logo.js';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import {choose as chooseDialog} from '@putout/cli-choose';
|
|
4
|
+
|
|
5
|
+
export const choose = 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 chooseDialog('Command:', [
|
|
11
|
+
'scan',
|
|
12
|
+
'scan:frame',
|
|
13
|
+
'fix',
|
|
14
|
+
'help',
|
|
15
|
+
'generate',
|
|
16
|
+
'generate:simple',
|
|
17
|
+
'exit',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
console.log('');
|
|
21
|
+
|
|
22
|
+
return command;
|
|
23
|
+
};
|
package/lib/help.js
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
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
|
|
19
|
+
generate:simple - generate simple .filesystem.json file and exit
|
|
15
20
|
`);
|
|
16
21
|
|
|
17
|
-
console.log('
|
|
22
|
+
console.log('');
|
|
18
23
|
};
|
package/lib/master.js
CHANGED
|
@@ -130,8 +130,7 @@ function run(filesystem, {fix, start, end, push, fail, success}) {
|
|
|
130
130
|
});
|
|
131
131
|
worker.on('error', reject);
|
|
132
132
|
worker.on('exit', (code) => {
|
|
133
|
-
|
|
134
|
-
reject(Error(`Worker stopped with exit code ${code}`));
|
|
133
|
+
reject(Error(`Worker stopped with exit code ${code}`));
|
|
135
134
|
});
|
|
136
135
|
});
|
|
137
136
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redlint",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.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,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",
|