@puruslang/linter 0.3.0 → 0.4.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 CHANGED
@@ -8,8 +8,12 @@
8
8
 
9
9
  ---
10
10
 
11
+ [![CI](https://github.com/otoneko1102/purus/actions/workflows/ci.yml/badge.svg)](https://github.com/otoneko1102/purus/actions/workflows/ci.yml)
11
12
  [![npm](https://img.shields.io/npm/v/purus)](https://www.npmjs.com/package/purus)
12
13
  [![npm downloads](https://img.shields.io/npm/dm/purus)](https://www.npmjs.com/package/purus)
14
+ [![License](https://img.shields.io/github/license/otoneko1102/purus)](https://github.com/otoneko1102/purus/blob/main/LICENSE)
15
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org/)
16
+ [![VS Code Extension](https://img.shields.io/visual-studio-marketplace/i/otoneko1102.purus)](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
13
17
  [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/otoneko1102/purus)](https://github.com/otoneko1102/purus/pulse)
14
18
  [![GitHub last commit](https://img.shields.io/github/last-commit/otoneko1102/purus)](https://github.com/otoneko1102/purus/commits/main)
15
19
  ![US layout](https://img.shields.io/badge/US_layout-Supported-green)
@@ -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
+ [![CI](https://github.com/otoneko1102/purus/actions/workflows/ci.yml/badge.svg)](https://github.com/otoneko1102/purus/actions/workflows/ci.yml)
11
12
  [![npm](https://img.shields.io/npm/v/purus)](https://www.npmjs.com/package/purus)
12
13
  [![npm downloads](https://img.shields.io/npm/dm/purus)](https://www.npmjs.com/package/purus)
14
+ [![License](https://img.shields.io/github/license/otoneko1102/purus)](https://github.com/otoneko1102/purus/blob/main/LICENSE)
15
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org/)
16
+ [![VS Code Extension](https://img.shields.io/visual-studio-marketplace/i/otoneko1102.purus)](https://marketplace.visualstudio.com/items?itemName=otoneko1102.purus)
13
17
  [![GitHub commit activity](https://img.shields.io/github/commit-activity/m/otoneko1102/purus)](https://github.com/otoneko1102/purus/pulse)
14
18
  [![GitHub last commit](https://img.shields.io/github/last-commit/otoneko1102/purus)](https://github.com/otoneko1102/purus/commits/main)
15
19
  ![US layout](https://img.shields.io/badge/US_layout-Supported-green)
@@ -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.0",
3
+ "version": "0.4.0",
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/index.js CHANGED
@@ -10,7 +10,7 @@ const KEYWORDS = new Set([
10
10
  "import", "from", "export", "default", "require", "use", "namespace", "pub", "all",
11
11
  "add", "sub", "mul", "div", "mod", "neg", "pow",
12
12
  "eq", "neq", "lt", "gt", "le", "ge",
13
- "and", "or", "not", "pipe",
13
+ "and", "or", "not", "pipe", "coal",
14
14
  "is", "as", "of", "typeof", "instanceof", "type",
15
15
  "new", "delete", "this", "await",
16
16
  "true", "false", "null", "nil", "undefined",
@@ -80,16 +80,37 @@ function tokenize(source) {
80
80
  }
81
81
 
82
82
  // Punctuation
83
- if ("[],;.".includes(source[i])) {
83
+ if ("[],;".includes(source[i])) {
84
+ tokens.push({ type: "punct", value: source[i], line: startLine, col: startCol });
85
+ i++; col++;
86
+ continue;
87
+ }
88
+
89
+ // Optional chaining \.
90
+ if (source[i] === "\\" && source[i + 1] === ".") {
91
+ tokens.push({ type: "punct", value: "\\.", line: startLine, col: startCol });
92
+ i += 2; col += 2;
93
+ continue;
94
+ }
95
+
96
+ // Backslash (computed access prefix)
97
+ if (source[i] === "\\") {
98
+ tokens.push({ type: "punct", value: "\\", line: startLine, col: startCol });
99
+ i++; col++;
100
+ continue;
101
+ }
102
+
103
+ // Dot
104
+ if (source[i] === ".") {
84
105
  tokens.push({ type: "punct", value: source[i], line: startLine, col: startCol });
85
106
  i++; col++;
86
107
  continue;
87
108
  }
88
109
 
89
110
  // Word
90
- if (/[a-zA-Z]/.test(source[i])) {
111
+ if (/[a-zA-Z_]/.test(source[i])) {
91
112
  let start = i;
92
- while (i < len && /[a-zA-Z0-9-]/.test(source[i])) { i++; col++; }
113
+ while (i < len && /[a-zA-Z0-9_-]/.test(source[i])) { i++; col++; }
93
114
  const word = source.slice(start, i);
94
115
  tokens.push({ type: KEYWORDS.has(word) ? "keyword" : "ident", value: word, line: startLine, col: startCol });
95
116
  continue;
@@ -167,11 +188,8 @@ function lint(source, ruleOverrides = {}) {
167
188
  if (style === "kebab-case") {
168
189
  // Identifiers should be kebab-case (lowercase with hyphens)
169
190
  // Allow PascalCase for class names (starts with uppercase)
191
+ // Allow underscores (they are equivalent to hyphens)
170
192
  if (/[A-Z]/.test(tok.value[0])) continue; // Allow PascalCase
171
- if (/_/.test(tok.value)) {
172
- report("consistent-naming", tok.line, tok.col,
173
- `Use kebab-case instead of snake_case: '${tok.value}'`);
174
- }
175
193
  }
176
194
  }
177
195
  }