Skip to content

Commit 58679bc

Browse files
committed
Merge branch 'main' into v0.29
2 parents 60793e6 + bf7f959 commit 58679bc

27 files changed

Lines changed: 733 additions & 818 deletions

.eslintignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 271 deletions
Original file line numberDiff line numberDiff line change
@@ -1,271 +0,0 @@
1-
/* global module */
2-
3-
module.exports = {
4-
root: true,
5-
parser: "@typescript-eslint/parser",
6-
plugins: [
7-
"@typescript-eslint",
8-
],
9-
extends: [
10-
"eslint:recommended",
11-
"plugin:@typescript-eslint/eslint-recommended",
12-
"plugin:@typescript-eslint/recommended",
13-
],
14-
parserOptions: {
15-
ecmaVersion: 2020,
16-
sourceType: "module",
17-
ecmaFeatures: {}
18-
},
19-
globals: {
20-
"globalThis": "readonly",
21-
"BigInt64Array": "readonly",
22-
"BigUint64Array": "readonly",
23-
"WebAssembly": "readonly",
24-
"FinalizationRegistry": "readonly",
25-
"fetch": "readonly",
26-
"URL": "readonly",
27-
"console": "readonly"
28-
},
29-
30-
// === General rules =========================================================
31-
32-
rules: {
33-
// Omitted semicolons are hugely popular, yet within the compiler it makes
34-
// sense to be better safe than sorry.
35-
"semi": "error",
36-
37-
// Our code bases uses 2 spaces for indentation, and we enforce it here so
38-
// files don't mix spaces, tabs or different indentation levels.
39-
"indent": ["error", 2, {
40-
"SwitchCase": 1,
41-
"VariableDeclarator": "first",
42-
"offsetTernaryExpressions": true,
43-
"ignoredNodes": [ // FIXME: something's odd here
44-
"ConditionalExpression > *",
45-
"ConditionalExpression > * > *",
46-
"ConditionalExpression > * > * > *"
47-
]
48-
}],
49-
50-
// This is mostly visual style, making comments look uniform.
51-
"spaced-comment": ["error", "always", {
52-
"markers": ["/"], // triple-slash
53-
"exceptions": ["/"] // all slashes
54-
}],
55-
56-
// This tends to be annoying as it encourages developers to make everything
57-
// that is never reassigned a 'const', sometimes semantically incorrect so,
58-
// typically leading to huge diffs in follow-up PRs modifying affected code.
59-
"prefer-const": "off",
60-
61-
// It is perfectly fine to declare top-level variables with `var`, yet this
62-
// rule doesn't provide configuration options that would help.
63-
"no-var": "off",
64-
65-
// Quite often, dealing with multiple related cases at once or otherwise
66-
// falling through is exactly the point of using a switch.
67-
"no-fallthrough": "off",
68-
"no-useless-assignment": "off",
69-
"no-unassigned-vars": "off",
70-
"preserve-caught-error": "off",
71-
72-
// Typical false-positives here are `do { ... } while (true)` statements or
73-
// similar, but the only option provided here is not checking any loops.
74-
"no-constant-condition": ["error", { checkLoops: false }],
75-
76-
// Functions are nested in blocks occasionally, and there haven't been any
77-
// problems with this so far, so turning the check off.
78-
"no-inner-declarations": "off",
79-
80-
// Quite common in scenarios where an iteration starts at `current = this`.
81-
"@typescript-eslint/no-this-alias": "off",
82-
83-
// Interferes with tests and 64-bit literals
84-
"@typescript-eslint/no-loss-of-precision": "off",
85-
86-
// Disabled here, but enabled again for JavaScript files.
87-
"no-unused-vars": "off",
88-
89-
// Disabled here, but enabled again for TypeScript files.
90-
"@typescript-eslint/no-unused-vars": "off"
91-
},
92-
overrides: [
93-
94-
// === JavaScript rules ====================================================
95-
96-
{
97-
env: {
98-
"browser": true,
99-
"amd": true,
100-
"node": true,
101-
"es6": true
102-
},
103-
files: [
104-
"**/*.js",
105-
"bin/*"
106-
],
107-
rules: {
108-
// We are testing both ESM and UMD, so don't limit us.
109-
"@typescript-eslint/no-var-requires": "off",
110-
111-
// This rule does not behave well in JS files.
112-
"@typescript-eslint/explicit-module-boundary-types": "off",
113-
114-
// Enforcing to remove function parameters on stubs makes code less
115-
// maintainable, so we instead allow unused function parameters.
116-
"no-unused-vars": [
117-
"warn", {
118-
"vars": "local",
119-
"args": "none",
120-
"ignoreRestSiblings": false
121-
}
122-
],
123-
124-
"@typescript-eslint/no-loss-of-precision": "error",
125-
}
126-
},
127-
128-
// === TypeScript rules ====================================================
129-
130-
{
131-
files: [
132-
"**/*.ts"
133-
],
134-
rules: {
135-
// Enforcing to remove function parameters on stubs makes code less
136-
// maintainable, so we instead allow unused function parameters.
137-
"@typescript-eslint/no-unused-vars": [
138-
"warn", {
139-
"vars": "local",
140-
"varsIgnorePattern": "^[A-Z](?:From|To)?$", // ignore type params
141-
"args": "none",
142-
"ignoreRestSiblings": false
143-
}
144-
]
145-
}
146-
},
147-
148-
// === AssemblyScript rules (extends TypeScript rules) =====================
149-
150-
{
151-
files: [
152-
"**/assembly/**/*.ts",
153-
"src/**/*.ts",
154-
"lib/parse/src/**/*.ts"
155-
],
156-
rules: {
157-
// Namespaces are quite useful in AssemblyScript
158-
"@typescript-eslint/no-namespace": "off",
159-
160-
// There is actually codegen difference here
161-
"@typescript-eslint/no-array-constructor": "off",
162-
163-
// Sometimes it can't be avoided to add a @ts-ignore
164-
"@typescript-eslint/ban-ts-comment": "off",
165-
166-
// Utilized to achieve portability in some cases
167-
"@typescript-eslint/no-non-null-assertion": "off",
168-
}
169-
},
170-
171-
// === Compiler rules (extends AssemblyScript rules) =======================
172-
173-
{
174-
files: [
175-
"src/**/*.ts",
176-
"std/assembly/**/*.ts"
177-
],
178-
rules: {
179-
// There is an actual codegen difference here - TODO: revisit
180-
"no-cond-assign": "off",
181-
182-
// Not all types can be omitted in AS yet - TODO: revisit
183-
"@typescript-eslint/no-inferrable-types": "off",
184-
185-
// Used rarely to reference internals that are not user-visible
186-
"@typescript-eslint/triple-slash-reference": "off",
187-
188-
// The compiler has its own `Function` class for example
189-
"no-shadow-restricted-names": "off",
190-
"@typescript-eslint/ban-types": "off"
191-
}
192-
},
193-
194-
// === Standard Library rules (extends AssemblyScript rules) ===============
195-
196-
{
197-
files: [
198-
"std/assembly/**/*.ts"
199-
],
200-
rules: {
201-
// We are implementing with --noLib, so we shadow all the time
202-
"no-shadow-restricted-names": "off",
203-
204-
// Similarly, sometimes we need the return type to be String, not string
205-
"@typescript-eslint/ban-types": "off"
206-
}
207-
},
208-
209-
// === Standard Definition rules (extends TypeScript rules) ================
210-
211-
{
212-
files: [
213-
"std/**/*.d.ts"
214-
],
215-
rules: {
216-
// Often required to achieve compatibility with TypeScript
217-
"@typescript-eslint/no-explicit-any": "off",
218-
219-
// Interfaces can be stubs here, i.e. not yet fully implemented
220-
"@typescript-eslint/no-empty-interface": "off",
221-
222-
// Definitions make use of `object` to model rather unusual constraints
223-
"@typescript-eslint/ban-types": "off"
224-
}
225-
},
226-
227-
// === Compiler Definition rules (extends TypeScript rules) ================
228-
229-
{
230-
files: [
231-
"./dist/*.d.ts"
232-
],
233-
rules: {
234-
// Our definitions are complicated, and all attempts to describe them
235-
// as modules have failed so far. As such, we re-export namespaces.
236-
"@typescript-eslint/no-namespace": "off",
237-
"@typescript-eslint/triple-slash-reference": "off"
238-
}
239-
},
240-
241-
// === Test rules (extends TypeScript rules) ===============================
242-
243-
{
244-
files: [
245-
"./tests/compiler/**/*.ts",
246-
"./lib/loader/tests/assembly/**/*.ts"
247-
],
248-
rules: {
249-
// Tests typically include unusual code patterns on purpose. This is
250-
// very likely not an extensive list, but covers what's there so far.
251-
"no-empty": "off",
252-
"no-cond-assign": "off",
253-
"no-compare-neg-zero": "off",
254-
"no-inner-declarations": "off",
255-
"no-constant-condition": "off",
256-
"use-isnan": "off",
257-
"@typescript-eslint/no-namespace": "off",
258-
"@typescript-eslint/no-unused-vars": "off",
259-
"@typescript-eslint/no-empty-function": "off",
260-
"@typescript-eslint/no-non-null-assertion": "off",
261-
"@typescript-eslint/no-extra-semi": "off",
262-
"@typescript-eslint/no-inferrable-types": "off",
263-
"@typescript-eslint/ban-types": "off",
264-
"@typescript-eslint/triple-slash-reference": "off",
265-
"@typescript-eslint/ban-ts-comment": "off",
266-
"@typescript-eslint/no-extra-non-null-assertion": "off",
267-
"@typescript-eslint/no-empty-interface": "off"
268-
}
269-
},
270-
]
271-
};

.github/workflows/stale.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ jobs:
1717
exempt-draft-pr: true
1818
exempt-all-milestones: true
1919
exempt-all-assignees: true
20-
days-before-issue-stale: 30
21-
days-before-pr-stale: 60
20+
days-before-issue-stale: 60
21+
days-before-pr-stale: 120
2222
days-before-close: 7

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,15 @@ Before submitting your pull request, also make sure that the following condition
5151

5252
Please note that if a pull request is rather complicated, i.e. touches lots of internals, or became stale, it is not uncommon that a core contributor performs the final integration to get it done in good conscience while naming you as a co-author.
5353

54+
Guidelines for **AI**-assisted Contributions
55+
--------------------------------------------
56+
57+
**AI** tools are welcome as helpers, not authors. Keep these practices in mind:
58+
59+
* Stay accountable: only submit changes you understand and can justify; be ready to explain behavior, edge cases. If an **AI** suggestion feels unclear, rewrite or drop it.
60+
* Keep humans in the loop: discuss non-trivial ideas early via [Issues](https://github.com/AssemblyScript/assemblyscript/issues) or [Discord](https://discord.gg/assemblyscript), especially when you are unsure about design or impact.
61+
* Use **AI** for acceleration, optimization and verification: treat **AI** output as a draft for code, tests, or docs; run linters/tests and review the logic **yourself**.
62+
* Be transparent in PRs: note briefly if **AI** was used and for what (e.g., initial draft, test scaffolding), and call out any parts where you want extra review.
63+
* Prefer small patches over large dumps; if you cannot confidently explain an **AI**-produced change, open a well-described issue instead.
64+
5465
Thank you!

NOTICE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ under the licensing terms detailed in LICENSE:
6262
* Kam Chehresa <kaz.che@gmail.com>
6363
* Mopsgamer <79159094+Mopsgamer@users.noreply.github.com>
6464
* EDM115 <github@edm115.dev>
65+
* Weixie Cui <cuiweixie@gmail.com>
6566
* Anakun <anakun@opnet.org>
6667

6768
Portions of this software are derived from third-party works licensed under

bin/asinit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ function ensurePackageJson() {
395395
updated = true;
396396
}
397397
if (!scripts["start"]) {
398-
scripts["start"] = "npx serve .",
398+
scripts["start"] = "npx serve .";
399399
pkg["scripts"] = scripts;
400400
updated = true;
401401
}

cli/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ export async function main(argv, options) {
874874
// Prepare output
875875
if (!opts.noEmit) {
876876
if (opts.binaryFile) {
877-
// We catched lagacy field for binary output (before 0.20)
877+
// We caught legacy field for binary output (before 0.20)
878878
return prepareResult(Error("Usage of the --binaryFile compiler option is no longer supported. Use --outFile instead."));
879879
}
880880
let bindings = opts.bindings || [];
@@ -966,7 +966,7 @@ export async function main(argv, options) {
966966
writeFile(opts.textFile, out, baseDir)
967967
);
968968
} else if (!hasStdout) {
969-
hasStdout = true;
969+
// hasStdout = true;
970970
writeStdout(out);
971971
}
972972
}
@@ -1112,8 +1112,8 @@ async function getConfig(file, baseDir, readFile) {
11121112
let config;
11131113
try {
11141114
config = JSON.parse(contents);
1115-
} catch {
1116-
throw new Error(`Asconfig is not valid json: ${location}`);
1115+
} catch(ex) {
1116+
throw new Error(`Asconfig is not valid json: ${location}`, { cause: ex });
11171117
}
11181118

11191119
// validate asconfig shape

0 commit comments

Comments
 (0)