Skip to content

Commit 658cf60

Browse files
authored
Update README.md
1 parent ef72b04 commit 658cf60

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

server/src/rules/README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Documentation for all diagnostics sent back to the client.
44

55
### [No unused variables](ast.ts)
66
**Error message**: `Unused name`
7+
78
Flags variables that are declared but not used within the code.
89
```javascript
910
const pi = 3.14;
@@ -14,13 +15,17 @@ The variable `pi` should have a warning.
1415
## Errors
1516

1617
### [Missing semicolon](ast.ts)
18+
**Error message**: `Missing semicolon`
19+
1720
Identifies statements that are missing semicolons.
1821
```javascript
1922
const x = 1;
2023
```
2124
The line ending should have an error.
2225

2326
### [Trailing comma](ast.ts)
27+
**Error message**: `Trailing comma`
28+
2429
Identifies expressions that have trailing commas.
2530
```javascript
2631
const x = [1,2,3,];
@@ -29,6 +34,7 @@ The comma after `3` should have an error.
2934

3035
### [No namespace/default imports](ast.ts)
3136
**Error message**: `Only normal imports are allowed`
37+
3238
Bans namespace and default imports.
3339
```javascript
3440
import * as rune from "rune";
@@ -38,6 +44,7 @@ Both lines will throw an error around the identifier.
3844

3945
### [Unexpected token in function parameters](ast.ts)
4046
**Error message**: `Unexpected token`
47+
4148
Only allows identifiers as function parameters
4249
```javascript
4350
function foo(a+b) {}
@@ -46,6 +53,7 @@ function foo(a+b) {}
4653

4754
### [Redeclaration of variables](ast.ts)
4855
**Error message**: `Identifier '${name}' has already been declared`
56+
4957
Bans redeclaration of names in the same scope
5058
```javascript
5159
let x = 1;
@@ -55,6 +63,7 @@ The second `x` will throw an error.
5563

5664
### [No array expressions](rules/arrayExpression.ts)
5765
**Error message**: `Array expressions are not allowed`
66+
5867
Bans array expressions before Source 3
5968
```javascript
6069
const x = [1,2,3];
@@ -63,6 +72,7 @@ The array `[1,2,3];` will throw an error.
6372

6473
### [No empty elements](rules/arrayExpression.ts)
6574
**Error message**: `No holes are allowed in array literals`
75+
6676
Bans empty elements in array expressions
6777
```javascript
6878
[1,,3];
@@ -71,6 +81,7 @@ The array `[1,,3]` will throw an error.
7181

7282
### [Constant reassignment](rules/assignmentExpression.ts)
7383
**Error message**: `Cannot assign new value to constant ${name}`
84+
7485
Bans reassignment to constant variable
7586
```javascript
7687
const x = 1;
@@ -80,6 +91,7 @@ The second `x` will throw an error
8091

8192
### [Incomplete binary expression](rules/binaryExpression.ts)
8293
**Error message**: `Incomplete binary expression`
94+
8395
Detects when a binary expression is missing a left/right node
8496
```javascript
8597
10 + ;
@@ -89,13 +101,15 @@ Both lines will throw an error
89101

90102
### [Force strict equality](rules/binaryExpression.ts)
91103
**Error message**: `Use ===/!== instead of ==/!=`
104+
92105
Bans the use of loose equality checks `==` and `!=`
93106
```javascript
94107
true == 1;
95108
```
96109

97110
### [Disallowed operators](rules/binaryExpression.ts)
98111
**Error message**: `${operator} is not allowed`
112+
99113
Only permitted operators defined in Source is allowed. Binary operators like `^` or `instanceof` is banned.
100114
```javascript
101115
100^5;
@@ -104,6 +118,7 @@ The expression `100^5` will throw an error.
104118

105119
### [Only string or number in equality checks](rules/binaryExpression.ts)
106120
**Error message**: `Expected string or number on left/right hand side of operation, got ${type}`
121+
107122
Before Source 3, only strings or numbers can be in equality checks
108123
```javascript
109124
true === 1; // Expected string or number on left hand side of operation, got boolean
@@ -115,6 +130,7 @@ Errors are shown in the comments.
115130

116131
### [No break statements](rules/breakStatement.ts)
117132
**Error message**: `Break statements are not allowed;`
133+
118134
No break statements before Source 3
119135
```javascript
120136
break;
@@ -123,6 +139,7 @@ break;
123139

124140
### [Calling a non function](rules/callExpression.ts)
125141
**Error message**: `${name} is not a function`
142+
126143
Cannot call identifiers that are not a function
127144
```javascript
128145
const x = 1;
@@ -135,11 +152,9 @@ can be reassigned, hence it will be a runtime error.
135152

136153
### [Not enough parameters](rules/callExpression.ts)
137154
**Error message**: `Expected ${num_args} or more arguments, but got ${num_supplied_args}`
155+
138156
Detects when a function application has not enough parameters.
139157
```javascript
140158
display();
141159
```
142160
The call to `display` needs at least 1 element.
143-
144-
```javascript
145-
```

0 commit comments

Comments
 (0)