Skip to content

Commit 963f461

Browse files
committed
add cspell, mocha to test, c8 for coverage, prettier for format, add eslint config for project itself; remove repeatedMember rule & test as its current implementation has foundamental issues not resolved
1 parent 02d1cb1 commit 963f461

14 files changed

+431
-810
lines changed

.c8rc.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"all": true,
3+
"include": [
4+
"dist/plugins/**/*.js"
5+
],
6+
"exclude": [
7+
"tests/**",
8+
"node_modules/**"
9+
],
10+
"reporter": ["text", "html", "lcov"],
11+
"report-dir": "./coverage",
12+
"check-coverage": true,
13+
"branches": 80,
14+
"lines": 80,
15+
"functions": 80,
16+
"statements": 80
17+
}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ package-lock.json
22
node_modules
33
dist/
44
sample_cases/
5-
wasm-toolchain
5+
wasm-toolchain
6+
coverage

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/node_modules/**
2+
dist/**
3+
reference/**
4+
sample_cases/**
5+
sample_config/**
6+
build/**
7+
wasm-toolchain/**
8+
coverage/**
9+
.github/**
10+
**/*.json

.prettierrc.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
arrowParens: always
2+
bracketSpacing: true
3+
endOfLine: lf
4+
htmlWhitespaceSensitivity: css
5+
insertPragma: false
6+
singleAttributePerLine: false
7+
bracketSameLine: false
8+
jsxSingleQuote: false
9+
printWidth: 80
10+
proseWrap: preserve
11+
quoteProps: as-needed
12+
requirePragma: false
13+
semi: true
14+
singleQuote: false
15+
tabWidth: 2
16+
trailingComma: es5
17+
useTabs: false
18+
embeddedLanguageFormatting: auto

Readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# ESlint plugins for assemblyscript
22

3-
*Disclaimer: This repo is still work-in-progress and not ready for production usage!!*
3+
_Disclaimer: This repo is still work-in-progress and not ready for production usage!!_
44

55
### Plugins included:
66

7-
* plugins/as-plugin.ts —— Addresses assemblyscript language related issues
8-
* plugins/perf-plugin.ts —— Addresses assemblyscript related issues
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
99

1010
### Example Usage
1111

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

1414
### Test
1515

1616
```bash
17-
/bin/bash "/home/meow/assemblyscript-eslint-plugin/sanity-check.sh"
17+
/bin/bash "/home/meow/assemblyscript-eslint-plugin/sanity-check.sh"
1818
```
1919

2020
Should output all tests passed.

cspell.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": "0.2",
3+
"language": "en",
4+
"words": [],
5+
"dictionaries": ["typescript", "node", "npm", "project-words"],
6+
"dictionaryDefinitions": [
7+
{
8+
"name": "project-words",
9+
"path": "cspell/project-words.txt",
10+
"description": "Project specific words"
11+
}
12+
],
13+
"ignorePaths": [
14+
"/node_modules/**",
15+
"dist/**",
16+
"reference/**",
17+
"sample_cases/**",
18+
"sample_config/**",
19+
"build/**",
20+
"tests/**",
21+
"wasm-toolchain/**",
22+
"coverage/**",
23+
".github/**",
24+
"**/*.json",
25+
"**/*.md"
26+
]
27+
}

cspell/project-words.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
assemblyscript
2+
wasm
3+
webassembly
4+
eslint
5+
linter
6+
linting
7+
ruleset
8+
rulename
9+
messageId
10+
autofix
11+
autofixer
12+
codefix
13+
ast
14+
sourcecode
15+
parserservices
16+
typechecker
17+
tsconfig
18+
tseslint
19+
tses
20+
21+
// AssemblyScript types and keywords
22+
i8
23+
i16
24+
i32
25+
i64
26+
27+
// Performance optimization terms
28+
perf
29+
benchmarking
30+
memcpy
31+
32+
// Common variable/function name abbreviations
33+
ctx
34+
params
35+
args
36+
37+
// Tools and frameworks
38+
mocha
39+
tsx
40+
tester
41+
42+
// Project directories and files
43+
dist
44+
plugins
45+
cspell
46+
47+
// rule keywords
48+
dont

eslint.config.mjs

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,22 @@
1-
// Import necessary modules for flat config
2-
import tsParser from '@typescript-eslint/parser';
3-
// Import the local plugin using ES Module syntax
4-
import localPlugin from './index.js'; // Assumes index.js is the entry point
1+
import eslint from "@eslint/js";
2+
import tseslint from "typescript-eslint";
53

6-
const allPluginRules = {};
7-
const pluginName = 'assemblyscript'; // Use the plugin name defined in bash
8-
9-
// Access rules from the default export of the plugin module
10-
if (localPlugin && localPlugin.rules) {
11-
for (const ruleName in localPlugin.rules) {
12-
// Construct the full rule name: 'plugin-name/rule-name'
13-
allPluginRules[`${pluginName}/${ruleName}`] = 'warn'; // Set default severity
14-
}
15-
} else {
16-
console.warn(`Plugin '${pluginName}' loaded from ./index.js does not seem to export rules correctly.`);
17-
}
18-
19-
// Export the flat config array
20-
export default [
4+
export default tseslint.config(
215
{
22-
// Apply to TypeScript files in the target directory
23-
files: ["sample_cases/**/*.ts"],
24-
languageOptions: {
25-
parser: tsParser,
26-
parserOptions: {
27-
ecmaVersion: 'latest',
28-
sourceType: 'module',
29-
},
30-
},
31-
// Define the plugin using the imported object
32-
plugins: {
33-
[pluginName]: localPlugin,
34-
},
35-
// Apply the dynamically generated rules
36-
rules: allPluginRules,
37-
}
38-
];
6+
ignores: [
7+
"**/node_modules/**",
8+
"dist/**",
9+
"reference/**",
10+
"sample_cases/**",
11+
"sample_config/**",
12+
"build/**",
13+
"wasm-toolchain/**",
14+
"coverage/**",
15+
".github/**",
16+
"**/*.json",
17+
"**/*.md",
18+
],
19+
},
20+
eslint.configs.recommended,
21+
tseslint.configs.recommended
22+
);

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import perfPlugin from './dist/plugins/perf-plugin.js';
2-
import asPlugin from './dist/plugins/as-plugin.js';
1+
import perfPlugin from "./dist/plugins/perf-plugin.js";
2+
import asPlugin from "./dist/plugins/as-plugin.js";
33

44
export default {
55
rules: {
66
...perfPlugin.rules,
77
...asPlugin.rules,
88
},
9-
};
9+
};

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@
2727
],
2828
"scripts": {
2929
"build": "npx tsc --build ./tsconfig.json",
30-
"test": "./test-lint.sh",
30+
"test": "mocha 'dist/tests/**/**.test.js'",
31+
"test:coverage": "c8 npm test",
3132
"lint": "npx eslint sample_cases/",
32-
"watch": "npx tsc --build ./tsconfig.json --watch"
33+
"watch": "npx tsc --build ./tsconfig.json --watch",
34+
"spell-check": "cspell \"**/*.{ts,js,md}\"",
35+
"prettier-fix": "prettier --check --write \"**/*.{ts,js,json,md}\""
3336
},
3437
"peerDependencies": {
3538
"eslint": ">=8.0.0"
3639
},
3740
"devDependencies": {
3841
"@types/eslint": "^9.6.1",
42+
"@types/mocha": "^10.0.10",
3943
"@types/node": "^22.14.1",
4044
"@typescript-eslint/rule-tester": "^8.30.1",
45+
"c8": "^10.1.3",
46+
"cspell": "^9.0.1",
47+
"mocha": "^11.2.2",
48+
"prettier": "^3.5.3",
4149
"ts-node": "^10.9.2",
4250
"tsx": "^4.19.3",
4351
"typescript-eslint": "^8.30.1"

0 commit comments

Comments
 (0)