|
1 |
| -# ESlint plugins for assemblyscript |
| 1 | +# ESLint Plugin for AssemblyScript |
2 | 2 |
|
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. |
4 | 4 |
|
5 |
| -### Plugins included: |
| 5 | +## Overview |
6 | 6 |
|
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: |
9 | 8 |
|
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 |
11 | 11 |
|
12 |
| -Refer sample_config/eslint.config.mjs to example usage |
| 12 | +## Plugins Included |
13 | 13 |
|
14 |
| -### Test |
| 14 | +### Standard Rules (`as-plugin.ts`) |
15 | 15 |
|
16 |
| -```bash |
17 |
| -/bin/bash "/home/meow/assemblyscript-eslint-plugin/sanity-check.sh" |
18 |
| -``` |
| 16 | +Enforces AssemblyScript language compatibility: |
19 | 17 |
|
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`) |
21 | 21 |
|
22 |
| -### Known issues: |
| 22 | +### Performance Rules (`perf-plugin.ts`) |
23 | 23 |
|
24 |
| -Auto fixer is still problematic for cases like: |
| 24 | +Optimizes code for better WebAssembly performance: |
25 | 25 |
|
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. |
0 commit comments