@puruslang/linter 0.2.0 → 0.3.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/README-ja.md +1 -1
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/cli.js +17 -25
- package/src/index.js +3 -3
package/README-ja.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://purus.work)
|
|
4
4
|
|
|
5
|
-
[English](https://
|
|
5
|
+
[English](https://github.com/otoneko1102/purus#readme) | **日本語**
|
|
6
6
|
|
|
7
7
|
</div>
|
|
8
8
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://purus.work)
|
|
4
4
|
|
|
5
|
-
**English** | [日本語](https://
|
|
5
|
+
**English** | [日本語](https://github.com/otoneko1102/purus/blob/main/README-ja.md)
|
|
6
6
|
|
|
7
7
|
</div>
|
|
8
8
|
|
|
@@ -55,4 +55,4 @@ otoneko. https://github.com/otoneko1102
|
|
|
55
55
|
|
|
56
56
|
## License
|
|
57
57
|
|
|
58
|
-
Distributed under the Apache 2.0 License. See [LICENSE](https://
|
|
58
|
+
Distributed under the Apache 2.0 License. See [LICENSE](https://github.com/otoneko1102/purus/blob/main/LICENSE) for more information.
|
package/package.json
CHANGED
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",
|