@puruslang/linter 0.2.1 → 0.3.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/README-ja.md +14 -0
- package/README.md +14 -0
- package/package.json +2 -3
- package/src/cli.js +17 -25
- package/src/index.js +3 -3
package/README-ja.md
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
[](https://github.com/otoneko1102/purus/actions/workflows/ci.yml)
|
|
11
12
|
[](https://www.npmjs.com/package/purus)
|
|
12
13
|
[](https://www.npmjs.com/package/purus)
|
|
14
|
+
[](https://github.com/otoneko1102/purus/blob/main/LICENSE)
|
|
15
|
+
[](https://nodejs.org/)
|
|
16
|
+
[](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
|
|
13
17
|
[](https://github.com/otoneko1102/purus/pulse)
|
|
14
18
|
[](https://github.com/otoneko1102/purus/commits/main)
|
|
15
19
|

|
|
@@ -49,6 +53,16 @@ npm install -D purus
|
|
|
49
53
|
|
|
50
54
|
ドキュメントは [purus.work](https://purus.work) で確認できます。
|
|
51
55
|
|
|
56
|
+
## 貢献
|
|
57
|
+
|
|
58
|
+
ガイドは [コチラ](https://github.com/otoneko1102/purus/blob/main/CONTRIBUTING-ja.md) !
|
|
59
|
+
|
|
60
|
+
<a href="https://github.com/otoneko1102/purus/graphs/contributors">
|
|
61
|
+
<img src="https://contrib.rocks/image?repo=otoneko1102/purus" />
|
|
62
|
+
</a>
|
|
63
|
+
|
|
64
|
+
Made with [contrib.rocks](https://contrib.rocks).
|
|
65
|
+
|
|
52
66
|
## 著者
|
|
53
67
|
|
|
54
68
|
otoneko. https://github.com/otoneko1102
|
package/README.md
CHANGED
|
@@ -8,8 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
+
[](https://github.com/otoneko1102/purus/actions/workflows/ci.yml)
|
|
11
12
|
[](https://www.npmjs.com/package/purus)
|
|
12
13
|
[](https://www.npmjs.com/package/purus)
|
|
14
|
+
[](https://github.com/otoneko1102/purus/blob/main/LICENSE)
|
|
15
|
+
[](https://nodejs.org/)
|
|
16
|
+
[](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
|
|
13
17
|
[](https://github.com/otoneko1102/purus/pulse)
|
|
14
18
|
[](https://github.com/otoneko1102/purus/commits/main)
|
|
15
19
|

|
|
@@ -49,6 +53,16 @@ npm install -D purus
|
|
|
49
53
|
|
|
50
54
|
The documentation is available on [purus.work](https://purus.work).
|
|
51
55
|
|
|
56
|
+
## Contribute
|
|
57
|
+
|
|
58
|
+
The guide is [here](https://github.com/otoneko1102/purus/blob/main/CONTRIBUTING.md)!
|
|
59
|
+
|
|
60
|
+
<a href="https://github.com/otoneko1102/purus/graphs/contributors">
|
|
61
|
+
<img src="https://contrib.rocks/image?repo=otoneko1102/purus" />
|
|
62
|
+
</a>
|
|
63
|
+
|
|
64
|
+
Made with [contrib.rocks](https://contrib.rocks).
|
|
65
|
+
|
|
52
66
|
## Author
|
|
53
67
|
|
|
54
68
|
otoneko. https://github.com/otoneko1102
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puruslang/linter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Linter for the Purus language",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"altjs",
|
|
15
15
|
"lang",
|
|
16
16
|
"language",
|
|
17
|
-
"noshift"
|
|
18
|
-
"noshift.js"
|
|
17
|
+
"noshift"
|
|
19
18
|
],
|
|
20
19
|
"author": "otoneko1102 (https://github.com/otoneko1102)",
|
|
21
20
|
"homepage": "https://purus.work",
|
package/src/cli.js
CHANGED
|
@@ -12,13 +12,11 @@ if (args.includes("--help") || args.includes("-h")) {
|
|
|
12
12
|
console.log("purus-lint - Linter for the Purus language");
|
|
13
13
|
console.log("");
|
|
14
14
|
console.log("Usage:");
|
|
15
|
-
console.log(" purus-lint [file...]
|
|
16
|
-
console.log(" purus-lint --directory <dir> Lint all files in directory");
|
|
15
|
+
console.log(" purus-lint [file|dir...] Lint specific files or directories");
|
|
17
16
|
console.log(" purus-lint Lint using config.purus");
|
|
18
17
|
console.log("");
|
|
19
18
|
console.log("Options:");
|
|
20
19
|
console.log(" --config <file> Path to config JSON file");
|
|
21
|
-
console.log(" --directory, -d Directory to lint");
|
|
22
20
|
console.log(" --fix (not yet implemented)");
|
|
23
21
|
console.log(" --help Show this help");
|
|
24
22
|
process.exit(0);
|
|
@@ -26,16 +24,13 @@ if (args.includes("--help") || args.includes("-h")) {
|
|
|
26
24
|
|
|
27
25
|
// Collect files and options
|
|
28
26
|
let configPath = null;
|
|
29
|
-
|
|
30
|
-
const files = [];
|
|
27
|
+
const inputPaths = [];
|
|
31
28
|
|
|
32
29
|
for (let i = 0; i < args.length; i++) {
|
|
33
30
|
if (args[i] === "--config" && i + 1 < args.length) {
|
|
34
31
|
configPath = args[++i];
|
|
35
|
-
} else if ((args[i] === "--directory" || args[i] === "-d") && i + 1 < args.length) {
|
|
36
|
-
directory = args[++i];
|
|
37
32
|
} else if (!args[i].startsWith("-")) {
|
|
38
|
-
|
|
33
|
+
inputPaths.push(args[i]);
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
|
|
@@ -70,25 +65,23 @@ if (configPath) {
|
|
|
70
65
|
}
|
|
71
66
|
}
|
|
72
67
|
}
|
|
73
|
-
|
|
74
|
-
// Also check for .puruslint.json in cwd
|
|
75
|
-
if (Object.keys(ruleOverrides).length === 0) {
|
|
76
|
-
const defaultConfig = path.join(process.cwd(), ".puruslint.json");
|
|
77
|
-
if (fs.existsSync(defaultConfig)) {
|
|
78
|
-
try {
|
|
79
|
-
ruleOverrides = JSON.parse(fs.readFileSync(defaultConfig, "utf8"));
|
|
80
|
-
} catch {
|
|
81
|
-
// ignore
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
68
|
}
|
|
86
69
|
|
|
87
70
|
// Determine files to lint
|
|
88
|
-
let filesToLint =
|
|
71
|
+
let filesToLint = [];
|
|
89
72
|
|
|
90
|
-
|
|
91
|
-
|
|
73
|
+
for (const p of inputPaths) {
|
|
74
|
+
const resolved = path.resolve(p);
|
|
75
|
+
if (!fs.existsSync(resolved)) {
|
|
76
|
+
console.error(`Error: '${p}' not found`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
const stat = fs.statSync(resolved);
|
|
80
|
+
if (stat.isDirectory()) {
|
|
81
|
+
filesToLint.push(...findPurusFiles(resolved));
|
|
82
|
+
} else {
|
|
83
|
+
filesToLint.push(resolved);
|
|
84
|
+
}
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
if (filesToLint.length === 0) {
|
|
@@ -106,8 +99,7 @@ if (filesToLint.length === 0) {
|
|
|
106
99
|
console.log("purus-lint - Linter for the Purus language");
|
|
107
100
|
console.log("");
|
|
108
101
|
console.log("Usage:");
|
|
109
|
-
console.log(" purus-lint [file...]
|
|
110
|
-
console.log(" purus-lint --directory <dir> Lint all files in directory");
|
|
102
|
+
console.log(" purus-lint [file|dir...] Lint specific files or directories");
|
|
111
103
|
console.log(" purus-lint Lint using config.purus");
|
|
112
104
|
process.exit(0);
|
|
113
105
|
}
|
package/src/index.js
CHANGED
|
@@ -7,9 +7,9 @@ const KEYWORDS = new Set([
|
|
|
7
7
|
"while", "until", "for", "in", "range",
|
|
8
8
|
"match", "when",
|
|
9
9
|
"try", "catch", "finally", "throw",
|
|
10
|
-
"import", "from", "export", "default", "require", "use", "
|
|
11
|
-
"add", "sub", "mul", "div", "mod", "neg",
|
|
12
|
-
"eq", "
|
|
10
|
+
"import", "from", "export", "default", "require", "use", "namespace", "pub", "all",
|
|
11
|
+
"add", "sub", "mul", "div", "mod", "neg", "pow",
|
|
12
|
+
"eq", "neq", "lt", "gt", "le", "ge",
|
|
13
13
|
"and", "or", "not", "pipe",
|
|
14
14
|
"is", "as", "of", "typeof", "instanceof", "type",
|
|
15
15
|
"new", "delete", "this", "await",
|