redlint 2.1.2 β 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 +12 -0
- package/README.md +13 -23
- package/bin/redlint.js +76 -10
- package/lib/help.js +22 -0
- package/lib/logo.js +2 -3
- package/lib/start.js +21 -0
- package/package.json +6 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
2023.12.18, v3.0.1
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 0afe4be redlint: scan:frame
|
|
5
|
+
- 62a8307 redlint: improve formatter
|
|
6
|
+
- 5d62840 redlint: strip-ansi v7.1.0
|
|
7
|
+
|
|
8
|
+
2023.12.18, v3.0.0
|
|
9
|
+
|
|
10
|
+
feature:
|
|
11
|
+
- 0a8d5f1 redlint: move generate to separete option, show help by default
|
|
12
|
+
|
|
1
13
|
2023.12.18, v2.1.2
|
|
2
14
|
|
|
3
15
|
fix:
|
package/README.md
CHANGED
|
@@ -13,11 +13,13 @@
|
|
|
13
13
|
>
|
|
14
14
|
> **(c) The Book of Kon, PoKon and ZaKon**
|
|
15
15
|
|
|
16
|
-

|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
What if **Filesystem** was a simple **JSON** file [`.filesystem.json`](https://github.com/putoutjs/redlint/blob/master/.filesystem.json). What if you can transform **JSON** file with π[**Putout**](https://github.com/coderaiser/putout) code transformer and this changes modify **Filesystem**?
|
|
19
19
|
|
|
20
|
-
Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/0614c2da35a1864b59ac284f18656328/695a9960c401d4e8f6744f58eac591d8f9185235).
|
|
20
|
+
What if I tell you it is possible? π± Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/0614c2da35a1864b59ac284f18656328/695a9960c401d4e8f6744f58eac591d8f9185235).
|
|
21
|
+
|
|
22
|
+
First time ever! Linter for you **Filesystem** ππΎ.
|
|
21
23
|
|
|
22
24
|
## Install
|
|
23
25
|
|
|
@@ -25,33 +27,21 @@ Checkout in π[**Putout Editor**](https://putout.cloudcmd.io/#/gist/0614c2da35
|
|
|
25
27
|
npm i redlint -g
|
|
26
28
|
```
|
|
27
29
|
|
|
28
|
-
##
|
|
30
|
+
## Scan
|
|
29
31
|
|
|
30
|
-
To
|
|
32
|
+
To scan your files use `redlint scan`:
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
redlint
|
|
34
|
-
```
|
|
34
|
+

|
|
35
35
|
|
|
36
|
-
Scan
|
|
36
|
+
## Scan
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
redlint scan
|
|
40
|
-
```
|
|
38
|
+
To fix your files use `redlint fix`:
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+

|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
redlint fix
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
When you want `simple filesystem` format use:
|
|
49
|
-
|
|
50
|
-
```sh
|
|
51
|
-
redlint simple
|
|
52
|
-
```
|
|
42
|
+
## Generate
|
|
53
43
|
|
|
54
|
-
|
|
44
|
+
You can also generate `.filesystem.json` file with `putout generate`.
|
|
55
45
|
|
|
56
46
|
## License
|
|
57
47
|
|
package/bin/redlint.js
CHANGED
|
@@ -3,22 +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';
|
|
7
|
+
import formatterCodeFrame from '@putout/formatter-codeframe';
|
|
8
|
+
import formatterDump from '@putout/formatter-dump';
|
|
6
9
|
import ora from 'ora';
|
|
7
|
-
import
|
|
10
|
+
import {help} from '../lib/help.js';
|
|
11
|
+
import {start} from '../lib/start.js';
|
|
8
12
|
import {buildTree} from '../lib/redlint.js';
|
|
9
13
|
import {convertToSimple} from '../lib/simple.js';
|
|
10
14
|
import {masterLint} from '../lib/master.js';
|
|
11
15
|
import {lint} from '../lib/lint.js';
|
|
16
|
+
import {logo} from '../lib/logo.js';
|
|
12
17
|
|
|
13
18
|
const {stringify} = JSON;
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
let [arg] = process.argv.slice(2);
|
|
21
|
+
let header = true;
|
|
22
|
+
|
|
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
|
+
}
|
|
16
32
|
|
|
17
33
|
if (arg === 'help') {
|
|
18
|
-
|
|
34
|
+
help({
|
|
35
|
+
header,
|
|
36
|
+
});
|
|
19
37
|
process.exit();
|
|
20
38
|
}
|
|
21
39
|
|
|
40
|
+
console.log('Running:');
|
|
22
41
|
const spinner = ora('index filesystem').start();
|
|
23
42
|
const result = await buildTree(process.cwd());
|
|
24
43
|
|
|
@@ -32,21 +51,67 @@ if (arg === 'simple') {
|
|
|
32
51
|
const filesystem = lintJSON(stringify(result));
|
|
33
52
|
|
|
34
53
|
if (arg === 'scan') {
|
|
35
|
-
const
|
|
54
|
+
const places = await masterLint(filesystem, {
|
|
36
55
|
fix: false,
|
|
37
56
|
});
|
|
38
57
|
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
if (!places.length)
|
|
59
|
+
process.exit();
|
|
60
|
+
|
|
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
|
+
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (arg === 'scan:frame') {
|
|
78
|
+
const places = await masterLint(filesystem, {
|
|
79
|
+
fix: true,
|
|
80
|
+
});
|
|
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
|
+
|
|
92
|
+
process.stderr.write(result);
|
|
93
|
+
process.exit(1);
|
|
41
94
|
}
|
|
42
95
|
|
|
43
96
|
if (arg === 'lint') {
|
|
44
|
-
const
|
|
97
|
+
const places = lint(filesystem, {
|
|
45
98
|
fix: true,
|
|
46
99
|
});
|
|
47
100
|
|
|
48
|
-
console.log(
|
|
49
|
-
|
|
101
|
+
console.log(logo);
|
|
102
|
+
|
|
103
|
+
const result = await formatterCodeFrame({
|
|
104
|
+
name: '.filesystem.json',
|
|
105
|
+
source: filesystem,
|
|
106
|
+
places,
|
|
107
|
+
index: 0,
|
|
108
|
+
count: places.length,
|
|
109
|
+
filesCount: 1,
|
|
110
|
+
errorsCount: places.length,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
process.stderr.write(result);
|
|
114
|
+
process.exit(1);
|
|
50
115
|
}
|
|
51
116
|
|
|
52
117
|
if (arg === 'fix') {
|
|
@@ -57,4 +122,5 @@ if (arg === 'fix') {
|
|
|
57
122
|
process.exit();
|
|
58
123
|
}
|
|
59
124
|
|
|
60
|
-
|
|
125
|
+
if (arg === 'generate')
|
|
126
|
+
await writeFile('.filesystem.json', filesystem);
|
package/lib/help.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {logo} from './logo.js';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
|
|
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
|
+
|
|
13
|
+
console.log(`Commands:
|
|
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
|
+
`);
|
|
20
|
+
|
|
21
|
+
console.log('');
|
|
22
|
+
};
|
package/lib/logo.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import process from 'node:process';
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
console.log(`
|
|
@@ -10,10 +9,10 @@ ${chalk.red('ββ ββ ββ ββ ββ')} ${chalk.white('β
|
|
|
10
9
|
${chalk.red('ββ ββ βββββββ ββββββ ')} ${chalk.white('βββββββ ββ ββ ββββ ββ ')}
|
|
11
10
|
`);
|
|
12
11
|
*/
|
|
13
|
-
export
|
|
12
|
+
export const logo = `
|
|
14
13
|
${chalk.red('ββββββ βββββββ ββββββ ')} ββ ββ βββ ββ ββββββββ
|
|
15
14
|
${chalk.red('ββ ββ ββ ββ ββ')} ββ ββ ββββ ββ ββ
|
|
16
15
|
${chalk.red('ββββββ βββββ ββ ββ')} ββ ββ ββ ββ ββ ββ
|
|
17
16
|
${chalk.red('ββ ββ ββ ββ ββ')} ββ ββ ββ ββ ββ ββ
|
|
18
17
|
${chalk.red('ββ ββ βββββββ ββββββ ')} βββββββ ββ ββ ββββ ββ
|
|
19
|
-
`.slice(1)
|
|
18
|
+
`.slice(1);
|
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
|
+
"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,13 +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",
|
|
35
|
+
"@putout/formatter-codeframe": "^6.0.0",
|
|
36
|
+
"@putout/formatter-dump": "^4.0.1",
|
|
34
37
|
"@putout/processor-filesystem": "^3.0.0",
|
|
35
38
|
"chalk": "^5.3.0",
|
|
36
39
|
"fullstore": "^3.0.0",
|
|
37
40
|
"ignore": "^5.2.4",
|
|
38
41
|
"ora": "^7.0.1",
|
|
39
|
-
"putout": "^34.0.0"
|
|
42
|
+
"putout": "^34.0.0",
|
|
43
|
+
"strip-ansi": "^7.1.0"
|
|
40
44
|
},
|
|
41
45
|
"keywords": [
|
|
42
46
|
"putout",
|