Skip to content

Commit 2564af0

Browse files
committed
up readme
1 parent ef4e1d3 commit 2564af0

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

Readme.md

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
# ESlint plugins for assemblyscript
1+
# ESLint Plugin for AssemblyScript
22

3-
_Disclaimer: This repo is still work-in-progress and not ready for production usage!!_
3+
An ESLint plugin that helps developers write better AssemblyScript code by enforcing language-specific rules and best practices.
44

5-
### Plugins included:
5+
## Overview
66

7-
- plugins/as-plugin.ts —— Forcing user to comply with assemblyscript language standard
8-
- plugins/perf-plugin.ts —— Optional rules that could lead to performance increase
7+
This plugin provides two sets of rules:
98

10-
### Example Usage
9+
- **Language Standards**: Rules that enforce AssemblyScript language restrictions and prevent errors
10+
- **Performance Optimization**: Rules that help improve code performance in WebAssembly
1111

12-
Refer sample_config/eslint.config.mjs to example usage
12+
## Plugins Included
1313

14-
### Test
14+
### Standard Rules (`as-plugin.ts`)
1515

16-
```bash
17-
/bin/bash "/home/meow/assemblyscript-eslint-plugin/sanity-check.sh"
18-
```
16+
Enforces AssemblyScript language compatibility:
1917

20-
Should output all tests passed.
18+
- `dont-omit-else`: Requires explicit `else` blocks for conditionals that don't have control flow statements
19+
- `no-spread`: Prevents use of spread syntax (`...`) which is not supported in AssemblyScript
20+
- `no-unsupported-keyword`: Disallows TypeScript keywords not supported in AssemblyScript (`any`, `never`, `undefined`)
2121

22-
### Known issues:
22+
### Performance Rules (`perf-plugin.ts`)
2323

24-
Auto fixer is still problematic for cases like:
24+
Optimizes code for better WebAssembly performance:
2525

26-
```js
27-
const x = data[0].value;
28-
data[0].count++;
29-
send(data[0].id); // Last line won't get fixed
30-
```
26+
- `array-init-style`: Recommends using `new Array<T>()` instead of `[]` for initializing empty arrays
27+
28+
## Configuration
29+
30+
See `sample_config/sample_eslint.config.mjs` for a detailed example of how to configure and use this plugin.
31+
32+
## Documentation
33+
34+
For detailed rule documentation, see the [docs/rules](./docs/rules) directory.

docs/rules/no-unsupported-keyword.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This rule has no configuration options.
2121
```ts
2222
// Using 'never' type
2323
function alwaysThrows(): never {
24-
throw new Error('This function never returns');
24+
throw new Error("This function never returns");
2525
}
2626

2727
// Using 'any' type
@@ -38,7 +38,7 @@ let maybeValue: string | undefined;
3838
```ts
3939
// Use specific return types instead of 'never'
4040
function alwaysThrows(): void {
41-
throw new Error('This function never returns');
41+
throw new Error("This function never returns");
4242
}
4343

4444
// Use explicit types instead of 'any'

plugins/rules/no-unsupported-keyword.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import createRule from "../utils/create-rule.js";
44
/**
55
* Rule: No Unsupported Keywords
66
* Reject usage of TypeScript keywords that are not supported in AssemblyScript.
7-
* BAD:
7+
* BAD:
88
* function foo(): never { throw new Error('never'); }
99
* function foo(a: any) {}
1010
* GOOD:

0 commit comments

Comments
 (0)