redlint 1.0.1 β 1.0.2
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 +6 -0
- package/README.md +1 -1
- package/bin/redlint.js +3 -1
- package/lib/redlint.js +15 -21
- package/package.json +3 -10
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
[CoverageURL]: https://coveralls.io/github/putoutjs/printer?branch=master
|
|
10
10
|
[CoverageIMGURL]: https://coveralls.io/repos/putoutjs/printer/badge.svg?branch=master&service=github
|
|
11
11
|
|
|
12
|
-
Lint Filesystem with π[**Putout**](https://github.com/coderaiser/putout). Creates `.filesystem.json` file for further lint.
|
|
12
|
+
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.
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
package/bin/redlint.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import process from 'node:process';
|
|
2
2
|
import {writeFile} from 'node:fs/promises';
|
|
3
3
|
import {buildTree} from '../lib/redlint.js';
|
|
4
|
+
import {lintJSON} from 'putout/lint/json';
|
|
4
5
|
|
|
6
|
+
const {stringify} = JSON;
|
|
5
7
|
const result = await buildTree(process.cwd());
|
|
6
|
-
const filesystem =
|
|
8
|
+
const filesystem = lintJSON(stringify(result));
|
|
7
9
|
|
|
8
10
|
await writeFile('.filesystem.json', filesystem);
|
package/lib/redlint.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import ignore from 'ignore';
|
|
1
2
|
import {opendir} from 'node:fs/promises';
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
+
const resolveName = (name, cwd) => name.replace(`${cwd}/`, '');
|
|
5
|
+
|
|
6
|
+
const ignoreList = [
|
|
4
7
|
'node_modules',
|
|
5
8
|
'coverage',
|
|
6
9
|
'.git',
|
|
@@ -8,28 +11,28 @@ const ignore = [
|
|
|
8
11
|
'fixture',
|
|
9
12
|
];
|
|
10
13
|
|
|
11
|
-
|
|
14
|
+
const ig = ignore().add(ignoreList);
|
|
15
|
+
|
|
16
|
+
export const buildTree = async (cwd) => ({
|
|
12
17
|
type: 'directory',
|
|
13
|
-
filename,
|
|
14
|
-
files: await walk(
|
|
18
|
+
filename: cwd,
|
|
19
|
+
files: await walk(cwd, cwd),
|
|
15
20
|
});
|
|
16
21
|
|
|
17
|
-
async function walk(cwd, files = []) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
for await (const dirent of dir) {
|
|
22
|
+
async function walk(cwd, dir, files = []) {
|
|
23
|
+
for await (const dirent of await opendir(dir)) {
|
|
21
24
|
const {path, name} = dirent;
|
|
25
|
+
const filename = `${path}/${name}`;
|
|
26
|
+
const resolved = resolveName(filename, cwd);
|
|
22
27
|
|
|
23
|
-
if (
|
|
28
|
+
if (resolved && ig.ignores(resolved))
|
|
24
29
|
continue;
|
|
25
30
|
|
|
26
|
-
const filename = `${path}/${name}`;
|
|
27
|
-
|
|
28
31
|
if (dirent.isDirectory()) {
|
|
29
32
|
files.push({
|
|
30
33
|
type: 'directory',
|
|
31
34
|
filename,
|
|
32
|
-
files: await walk(filename),
|
|
35
|
+
files: await walk(cwd, filename),
|
|
33
36
|
});
|
|
34
37
|
continue;
|
|
35
38
|
}
|
|
@@ -42,12 +45,3 @@ async function walk(cwd, files = []) {
|
|
|
42
45
|
|
|
43
46
|
return files;
|
|
44
47
|
}
|
|
45
|
-
|
|
46
|
-
function isIgnored(name) {
|
|
47
|
-
for (const current of ignore) {
|
|
48
|
-
if (RegExp(current).test(name))
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return false;
|
|
53
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redlint",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Lint Filesystem with πPutout",
|
|
@@ -27,14 +27,8 @@
|
|
|
27
27
|
"report": "madrun report"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"@putout/operate": "^11.0.0",
|
|
33
|
-
"@putout/processor-json": "^7.0.0",
|
|
34
|
-
"fullstore": "^3.0.0",
|
|
35
|
-
"just-snake-case": "^3.2.0",
|
|
36
|
-
"parse-import-specifiers": "^1.0.1",
|
|
37
|
-
"rendy": "^4.0.0"
|
|
30
|
+
"ignore": "^5.2.4",
|
|
31
|
+
"putout": "^32.15.1"
|
|
38
32
|
},
|
|
39
33
|
"keywords": [
|
|
40
34
|
"putout",
|
|
@@ -56,7 +50,6 @@
|
|
|
56
50
|
"mock-require": "^3.0.3",
|
|
57
51
|
"montag": "^1.0.0",
|
|
58
52
|
"nodemon": "^3.0.1",
|
|
59
|
-
"putout": "^32.0.4",
|
|
60
53
|
"supertape": "^8.0.0",
|
|
61
54
|
"try-catch": "^3.0.0"
|
|
62
55
|
},
|