@puruslang/linter 0.2.1 → 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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/cli.js +17 -25
  3. package/src/index.js +3 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puruslang/linter",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Linter for the Purus language",
5
5
  "license": "Apache-2.0",
6
6
  "main": "src/index.js",
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...] Lint specific files");
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
- let directory = null;
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
- files.push(args[i]);
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 = files;
71
+ let filesToLint = [];
89
72
 
90
- if (filesToLint.length === 0 && directory) {
91
- filesToLint = findPurusFiles(path.resolve(directory));
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...] Lint specific files");
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", "mod", "pub", "all",
11
- "add", "sub", "mul", "div", "mod", "neg",
12
- "eq", "ne", "lt", "gt", "le", "ge",
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",