redlint 2.1.2 β†’ 3.0.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 CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.12.18, v3.0.0
2
+
3
+ feature:
4
+ - 0a8d5f1 redlint: move generate to separete option, show help by default
5
+
1
6
  2023.12.18, v2.1.2
2
7
 
3
8
  fix:
package/README.md CHANGED
@@ -13,11 +13,13 @@
13
13
  >
14
14
  > **(c) The Book of Kon, PoKon and ZaKon**
15
15
 
16
- ![image](https://github.com/putoutjs/redlint/assets/1573141/120df37e-cc7d-420d-a73d-777455335c9c)
16
+ ![image](https://github.com/putoutjs/redlint/assets/1573141/ec0efee1-0bfc-4595-ba85-aaaabe274a34)
17
17
 
18
- Lint Filesystem with 🐊[**Putout**](https://github.com/coderaiser/putout). Creates [`.filesystem.json`](https://github.com/putoutjs/redlint/blob/master/.filesystem.json) file for further lint.
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
- ## Usage Example
30
+ ## Scan
29
31
 
30
- To produce `.filesystem.json` file use:
32
+ To scan your files use `redlint scan`:
31
33
 
32
- ```sh
33
- redlint
34
- ```
34
+ ![image](https://github.com/putoutjs/redlint/assets/1573141/c17de523-66ea-49a1-b65d-4872ff1ecb37)
35
35
 
36
- Scan filesystem:
36
+ ## Scan
37
37
 
38
- ```sh
39
- redlint scan
40
- ```
38
+ To fix your files use `redlint fix`:
41
39
 
42
- Fix filesystem:
40
+ ![image](https://github.com/putoutjs/redlint/assets/1573141/5ce7a8de-b5c1-44b7-8302-918b9e58b185)
43
41
 
44
- ```sh
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
- ![image](https://github.com/putoutjs/redlint/assets/1573141/cad02be5-f1b9-43da-a55c-a58ff16cad42)
44
+ You can also generate `.filesystem.json` file with `putout generate`.
55
45
 
56
46
  ## License
57
47
 
package/bin/redlint.js CHANGED
@@ -3,8 +3,9 @@
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 formatterCodeFrame from '@putout/formatter-codeframe';
6
7
  import ora from 'ora';
7
- import logo from '../lib/logo.js';
8
+ import {help} from '../lib/help.js';
8
9
  import {buildTree} from '../lib/redlint.js';
9
10
  import {convertToSimple} from '../lib/simple.js';
10
11
  import {masterLint} from '../lib/master.js';
@@ -14,8 +15,8 @@ const {stringify} = JSON;
14
15
 
15
16
  const [arg] = process.argv.slice(2);
16
17
 
17
- if (arg === 'help') {
18
- logo();
18
+ if (!arg || arg === 'help') {
19
+ help();
19
20
  process.exit();
20
21
  }
21
22
 
@@ -36,8 +37,11 @@ if (arg === 'scan') {
36
37
  fix: false,
37
38
  });
38
39
 
39
- console.log(result);
40
- process.exit();
40
+ if (!result.length)
41
+ process.exit();
42
+
43
+ console.error(result);
44
+ process.exit(1);
41
45
  }
42
46
 
43
47
  if (arg === 'lint') {
@@ -45,16 +49,28 @@ if (arg === 'lint') {
45
49
  fix: true,
46
50
  });
47
51
 
48
- console.log(result);
52
+ process.stderr.write(result);
49
53
  process.exit();
50
54
  }
51
55
 
52
56
  if (arg === 'fix') {
53
- await masterLint(filesystem, {
57
+ const places = await masterLint(filesystem, {
54
58
  fix: true,
55
59
  });
56
60
 
61
+ const result = await formatterCodeFrame({
62
+ name: '.filesystem.json',
63
+ source: filesystem,
64
+ places,
65
+ index: 0,
66
+ count: places.length,
67
+ filesCount: 1,
68
+ errorsCount: places.length,
69
+ });
70
+
71
+ process.stdout.write(result);
57
72
  process.exit();
58
73
  }
59
74
 
60
- await writeFile('.filesystem.json', filesystem);
75
+ if (arg === 'generate')
76
+ await writeFile('.filesystem.json', filesystem);
package/lib/help.js ADDED
@@ -0,0 +1,18 @@
1
+ import {logo} from './logo.js';
2
+ import chalk from 'chalk';
3
+ import process from 'node:process';
4
+
5
+ export const help = () => {
6
+ console.log('Lint your files according to 🐊Putout rules.\n');
7
+ process.stdout.write(logo);
8
+ console.log('');
9
+ console.log(`Usage: redlint ${chalk.bgBlue('command')}`);
10
+ console.log(`Commands:
11
+ ${chalk.bgBlue('scan')} - scan files according to 🐊Putout rules
12
+ ${chalk.bgBlue('fix')} - fix files according to 🐊Putout rules
13
+ ${chalk.bgBlue('help')} - show help screen and exit
14
+ ${chalk.bgBlue('generate')} - generate .filesystem.json file and exit
15
+ `);
16
+
17
+ console.log('(c) https://github.com/putoutjs/redlint');
18
+ };
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 default () => process.stdout.write(`
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redlint",
3
- "version": "2.1.2",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Lint Filesystem with 🐊Putout",
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@putout/engine-runner": "^20.1.0",
34
+ "@putout/formatter-codeframe": "^6.0.0",
34
35
  "@putout/processor-filesystem": "^3.0.0",
35
36
  "chalk": "^5.3.0",
36
37
  "fullstore": "^3.0.0",