redlint 3.5.0 β†’ 3.6.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,13 @@
1
+ 2023.12.26, v3.6.0
2
+
3
+ feature:
4
+ - 3adb918 redlint: add support of async rules
5
+
6
+ 2023.12.22, v3.5.1
7
+
8
+ fix:
9
+ - 0f9aa9c redlint: args
10
+
1
11
  2023.12.22, v3.5.0
2
12
 
3
13
  feature:
package/bin/redlint.js CHANGED
@@ -21,23 +21,24 @@ import {lint} from '../lib/lint/lint.js';
21
21
  import {pack} from '../lib/pack/pack.js';
22
22
  import {extract} from '../lib/extract/extract.js';
23
23
  import {debug} from '../lib/debug.js';
24
+ import {logo} from '../lib/help/logo.js';
24
25
  import {version} from '../lib/cli/version.js';
25
26
  import {
26
- SCAN,
27
- SCAN_DEBUG,
28
- FIX,
29
- FIX_DEBUG,
30
- PACK,
31
- PACK_DEBUG,
32
- EXTRACT,
33
- EXTRACT_DEBUG,
34
- GENERATE,
35
- GENERATE_SIMPLE,
36
- HELP,
37
- VERSION,
38
- DEBUG,
39
- BACK,
40
- EXIT,
27
+ isScan,
28
+ isScanDebug,
29
+ isFix,
30
+ isFixDebug,
31
+ isPack,
32
+ isPackDebug,
33
+ isExtract,
34
+ isExtractDebug,
35
+ isGenerate,
36
+ isGenerateSimple,
37
+ isHelp,
38
+ isVersion,
39
+ isDebug,
40
+ isBack,
41
+ isExit,
41
42
  } from '../lib/menu.js';
42
43
 
43
44
  const {log} = console;
@@ -52,6 +53,12 @@ await uiLoop(arg);
52
53
 
53
54
  async function uiLoop(arg) {
54
55
  if (!arg) {
56
+ if (header) {
57
+ console.log('Lint your files according to 🐊Putout rules.\n');
58
+ process.stdout.write(logo);
59
+ console.log('');
60
+ }
61
+
55
62
  arg = await choose();
56
63
 
57
64
  if (!arg)
@@ -60,24 +67,24 @@ async function uiLoop(arg) {
60
67
  header = false;
61
68
  }
62
69
 
63
- if (arg === DEBUG) {
70
+ if (isDebug(arg)) {
64
71
  arg = await debug();
65
72
 
66
- if (arg === BACK)
73
+ if (isBack(arg))
67
74
  return await uiLoop();
68
75
  }
69
76
 
70
- if (arg === EXIT)
77
+ if (isExit(arg))
71
78
  process.exit();
72
79
 
73
- if (arg === VERSION)
80
+ if (isVersion(arg))
74
81
  return version({
75
82
  log,
76
83
  exit,
77
84
  readFile,
78
85
  });
79
86
 
80
- if (arg === HELP) {
87
+ if (isHelp(arg)) {
81
88
  help({
82
89
  header,
83
90
  });
@@ -91,14 +98,14 @@ async function uiLoop(arg) {
91
98
 
92
99
  spinner.succeed();
93
100
 
94
- if (arg === GENERATE_SIMPLE) {
101
+ if (isGenerateSimple(arg)) {
95
102
  await writeFile('.filesystem.json', lintJSON(stringify(convertToSimple(result))));
96
103
  process.exit(0);
97
104
  }
98
105
 
99
106
  const filesystem = lintJSON(stringify(result));
100
107
 
101
- if (arg === SCAN) {
108
+ if (isScan(arg)) {
102
109
  const places = await masterLint(filesystem, {
103
110
  fix: false,
104
111
  });
@@ -122,7 +129,7 @@ async function uiLoop(arg) {
122
129
  process.exit(1);
123
130
  }
124
131
 
125
- if (arg === PACK) {
132
+ if (isPack(arg)) {
126
133
  const result = await masterPack(CWD, filesystem);
127
134
  await writeFile(join(CWD, 'filesystem.red'), result);
128
135
  const spinner = ora(`pack 'filesystem.red'`).start();
@@ -131,7 +138,7 @@ async function uiLoop(arg) {
131
138
  process.exit();
132
139
  }
133
140
 
134
- if (arg === EXTRACT) {
141
+ if (isExtract(arg)) {
135
142
  const filesystem = await readFile(join(CWD, 'filesystem.red'), 'utf8');
136
143
  await masterExtract(CWD, filesystem);
137
144
  const spinner = ora(`extract 'filesystem.red'`).start();
@@ -140,7 +147,7 @@ async function uiLoop(arg) {
140
147
  process.exit();
141
148
  }
142
149
 
143
- if (arg === EXTRACT_DEBUG) {
150
+ if (isExtractDebug(arg)) {
144
151
  const filesystem = await readFile(join(CWD, 'filesystem.red'), 'utf8');
145
152
  await extract(CWD, filesystem);
146
153
  const spinner = ora(`extract 'filesystem.red'`).start();
@@ -149,7 +156,7 @@ async function uiLoop(arg) {
149
156
  process.exit();
150
157
  }
151
158
 
152
- if (arg === PACK_DEBUG) {
159
+ if (isPackDebug(arg)) {
153
160
  const result = pack(CWD, filesystem);
154
161
  await writeFile(join(CWD, 'filesystem.red'), result);
155
162
 
@@ -157,8 +164,8 @@ async function uiLoop(arg) {
157
164
  process.exit();
158
165
  }
159
166
 
160
- if (arg === SCAN_DEBUG) {
161
- const places = lint(filesystem, {
167
+ if (isScanDebug(arg)) {
168
+ const places = await lint(filesystem, {
162
169
  fix: false,
163
170
  });
164
171
 
@@ -176,7 +183,7 @@ async function uiLoop(arg) {
176
183
  process.exit(1);
177
184
  }
178
185
 
179
- if (arg === FIX_DEBUG) {
186
+ if (isFixDebug(arg)) {
180
187
  const places = lint(filesystem, {
181
188
  fix: true,
182
189
  });
@@ -195,7 +202,7 @@ async function uiLoop(arg) {
195
202
  process.exit();
196
203
  }
197
204
 
198
- if (arg === FIX) {
205
+ if (isFix(arg)) {
199
206
  await masterLint(filesystem, {
200
207
  fix: true,
201
208
  });
@@ -203,7 +210,7 @@ async function uiLoop(arg) {
203
210
  process.exit();
204
211
  }
205
212
 
206
- if (arg === GENERATE)
213
+ if (isGenerate(arg))
207
214
  await writeFile('.filesystem.json', filesystem);
208
215
 
209
216
  done(`generate '.filesystem.json'`);
package/lib/choose.js CHANGED
@@ -1,5 +1,3 @@
1
- import {logo} from './help/logo.js';
2
- import process from 'node:process';
3
1
  import {choose as chooseDialog} from '@putout/cli-choose';
4
2
  import {
5
3
  SCAN,
@@ -15,10 +13,6 @@ import {
15
13
  } from './menu.js';
16
14
 
17
15
  export const choose = async () => {
18
- console.log('Lint your files according to 🐊Putout rules.\n');
19
- process.stdout.write(logo);
20
- console.log('');
21
-
22
16
  const command = await chooseDialog('Command:', [
23
17
  SCAN,
24
18
  FIX,
@@ -1,7 +1,7 @@
1
1
  const {parse} = JSON;
2
2
 
3
3
  export const version = async ({log, exit, readFile}) => {
4
- const packagePath = new URL('../package.json', import.meta.url);
4
+ const packagePath = new URL('../../package.json', import.meta.url);
5
5
  const packageData = await readFile(packagePath);
6
6
  const {version} = parse(packageData);
7
7
 
package/lib/lint/lint.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import {
2
- transform,
2
+ transformAsync,
3
3
  parse,
4
4
  } from 'putout';
5
5
  import parseOptions from 'putout/parse-options';
@@ -9,15 +9,14 @@ import {
9
9
  merge,
10
10
  } from '@putout/processor-filesystem';
11
11
 
12
- export const lint = (filesystem, {fix, progress = createProgress()} = {}) => {
12
+ export const lint = async (filesystem, {fix, progress = createProgress()} = {}) => {
13
13
  const [{source}] = branch(filesystem);
14
14
  const options = parseOptions({
15
15
  name: '.filesystem.json',
16
16
  });
17
17
 
18
18
  const ast = parse(source);
19
-
20
- const places = transform(ast, source, {
19
+ const places = await transformAsync(ast, source, {
21
20
  fix,
22
21
  fixCount: 1,
23
22
  ...options,
package/lib/lint/slave.js CHANGED
@@ -28,7 +28,7 @@ progress.on('file', ({rule, i, n}) => {
28
28
  }]);
29
29
  });
30
30
 
31
- parentPort.postMessage(['end', lint(filesystem, {
31
+ parentPort.postMessage(['end', await lint(filesystem, {
32
32
  fix,
33
33
  progress,
34
34
  })]);
package/lib/menu.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const SCAN = 'βœ… scan';
2
2
  export const SCAN_DEBUG = 'βœ… scan: debug';
3
- export const FIX = '❌ fix';
4
- export const FIX_DEBUG = '❌ fix: debug';
3
+ export const FIX = 'πŸ”¨ fix';
4
+ export const FIX_DEBUG = 'πŸ”¨ fix: debug';
5
5
  export const PACK = 'πŸ”¬ pack';
6
6
  export const PACK_DEBUG = 'πŸ”¬ pack';
7
7
  export const EXTRACT = 'πŸ”­ extract';
@@ -13,3 +13,19 @@ export const VERSION = '⁋ version';
13
13
  export const DEBUG = 'πŸ“Ώ debug';
14
14
  export const BACK = 'πŸ”™ back';
15
15
  export const EXIT = 'πŸšͺ exit';
16
+
17
+ export const isScan = (a) => a === SCAN || a === 'scan';
18
+ export const isScanDebug = (a) => a === SCAN_DEBUG || a === 'scan:debug';
19
+ export const isFix = (a) => a === FIX || a === 'fix';
20
+ export const isFixDebug = (a) => a === FIX_DEBUG || a === 'fix:debug';
21
+ export const isPack = (a) => a === PACK || a === 'debug';
22
+ export const isPackDebug = (a) => a === PACK_DEBUG || a === 'pack:debug';
23
+ export const isExtract = (a) => a === EXTRACT || a === 'extract';
24
+ export const isExtractDebug = (a) => a === EXTRACT_DEBUG || a === 'extract:debug';
25
+ export const isGenerate = (a) => a === GENERATE || a === 'generate';
26
+ export const isGenerateSimple = (a) => a === GENERATE_SIMPLE || a === 'generate:simple';
27
+ export const isHelp = (a) => a === HELP || a === 'help';
28
+ export const isVersion = (a) => a === VERSION || a === 'version';
29
+ export const isDebug = (a) => a === DEBUG || a === 'debug';
30
+ export const isBack = (a) => a === BACK || a === 'back';
31
+ export const isExit = (a) => a === EXIT || a === 'exit';
package/lib/pack/slave.js CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  workerData,
4
4
  } from 'node:worker_threads';
5
5
  import {createProgress} from '@putout/engine-runner/progress';
6
-
7
6
  import {pack} from './pack.js';
8
7
 
9
8
  const {filesystem, cwd} = workerData;
package/lib/run.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {Worker} from 'node:worker_threads';
2
2
  import fullstore from 'fullstore';
3
3
 
4
- export function run({test,workerData, slave, push, fix, start, end, fail, success, suffix}) {
4
+ export function run({test, workerData, slave, push, fix, start, end, fail, success, suffix}) {
5
5
  return new Promise((resolve, reject) => {
6
6
  const worker = new Worker(slave, {
7
7
  workerData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redlint",
3
- "version": "3.5.0",
3
+ "version": "3.6.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Lint Filesystem with 🐊Putout",