redlint 3.21.2 → 3.21.3

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
+ 2025.03.13, v3.21.3
2
+
3
+ feature:
4
+ - 9a1e2ba redlint: read-directory
5
+
1
6
  2025.03.13, v3.21.2
2
7
 
3
8
  feature:
@@ -1,11 +1,17 @@
1
- import {basename, dirname} from 'node:path';
1
+ import {basename} from 'node:path';
2
2
  import {operator} from 'putout';
3
3
 
4
- const {getFilename} = operator;
4
+ const {
5
+ getFilename,
6
+ readDirectory,
7
+ findFile,
8
+ } = operator;
5
9
 
6
10
  export const report = (path, {name}) => name;
7
11
  export const fix = () => {};
8
- export const scan = (path, {push, trackFile, options}) => {
12
+ export const scan = (rootPath, {push, options}) => {
13
+ console.time('scan');
14
+
9
15
  const {
10
16
  dir = '/',
11
17
  full,
@@ -13,28 +19,22 @@ export const scan = (path, {push, trackFile, options}) => {
13
19
  } = options;
14
20
 
15
21
  const names = [];
22
+ const [dirPath] = findFile(rootPath, dir);
23
+
24
+ const files = recursive ? findFile(dirPath, '*') : readDirectory(dirPath);
16
25
 
17
- for (const file of trackFile(path, '*')) {
26
+ for (const file of files) {
18
27
  const path = getFilename(file);
19
- const currentDir = dirname(path);
20
28
 
21
29
  if (dir === path)
22
30
  continue;
23
31
 
24
- if (!recursive && currentDir !== dir)
25
- continue;
26
-
27
32
  if (!full && recursive) {
28
33
  const name = path
29
34
  .replace(dir, '')
30
35
  .replace(/^\//, '');
31
36
 
32
- if (!name)
33
- continue;
34
-
35
- push(file, {
36
- name,
37
- });
37
+ names.push(name);
38
38
  continue;
39
39
  }
40
40
 
@@ -46,7 +46,7 @@ export const scan = (path, {push, trackFile, options}) => {
46
46
  const sorted = names.sort();
47
47
 
48
48
  for (const name of sorted) {
49
- push(path, {
49
+ push(dirPath, {
50
50
  name,
51
51
  });
52
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redlint",
3
- "version": "3.21.2",
3
+ "version": "3.21.3",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Lint Filesystem with 🐊Putout",