Skip to content

Commit ed9b4cb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into issue/201
2 parents 3c3bb27 + a73141f commit ed9b4cb

File tree

768 files changed

+280324
-244572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

768 files changed

+280324
-244572
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
dist/
2+
docs/
3+
lib/parse/index.js
4+
out/
5+
raw/
6+
tests/parser/

.eslintrc.js

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

.github/ISSUE_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!--
2+
Thanks for submitting an issue to AssemblyScript! Please take a moment to
3+
read the contributing guidelines linked below to get off to a good start 🙂
4+
-->

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--
2+
Thanks for submitting a pull request to AssemblyScript! Please take a moment to
3+
review the contributing guidelines linked below, and confirm with an [x] 🙂
4+
-->
5+
6+
7+
8+
9+
10+
- [ ] I've read the contributing guidelines

.github/stale.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ daysUntilClose: 7
55
exemptLabels:
66
- bug
77
- enhancement
8+
- compatibility
89
exemptProjects: true
910
exemptMilestones: true
1011
exemptAssignees: true

.github/workflows/publish.yml

Lines changed: 17 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,17 @@ on:
33
schedule:
44
- cron: '0 0 * * *'
55
jobs:
6-
publish:
7-
name: "Publish packages"
6+
release:
7+
name: Packages
8+
if: github.repository == 'AssemblyScript/assemblyscript'
89
runs-on: ubuntu-latest
910
steps:
1011
- uses: actions/checkout@v1
1112
with:
12-
ref: release
13-
- uses: dcodeIO/setup-node-nvm@v1.0.0
13+
ref: master
14+
- uses: dcodeIO/setup-node-nvm@master
1415
with:
15-
node-version: node
16-
- name: Merge master
17-
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
run: |
20-
git config user.name "GitHub Actions"
21-
git config user.email "[email protected]"
22-
git remote set-url origin "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
23-
git fetch origin
24-
git merge origin/master
16+
node-version: current
2517
- name: Install dependencies
2618
run: npm ci
2719
- name: Build distribution files
@@ -30,53 +22,18 @@ jobs:
3022
npm run build
3123
- name: Test distribution files
3224
run: npm test
33-
- name: Set up version
34-
run: |
35-
VERSION=$(node -e "console.log(require('./package.json').version)")
36-
git add --force dist/*
37-
if git rev-parse v$VERSION >/dev/null 2>&1; then
38-
VERSION=$VERSION-nightly.$(date "+%Y%m%d")
39-
if git rev-parse v$VERSION >/dev/null 2>&1; then
40-
echo "Nightly $VERSION does already exist."
41-
exit 1
42-
fi
43-
echo ::set-env name=CHANNEL::nightly
44-
echo "Committing nightly ($VERSION) ..."
45-
git commit -m "Nightly v$VERSION"
46-
npm version $VERSION --no-git-tag-version --force
47-
else
48-
echo ::set-env name=CHANNEL::latest
49-
echo "Committing release ($VERSION) ..."
50-
git commit --allow-empty -m "Release v$VERSION"
51-
fi
52-
echo ::set-env name=VERSION::$VERSION
53-
cd lib/loader
54-
npm version $VERSION --no-git-tag-version --force
55-
cd ../..
56-
- name: Create tag and push distribution files
57-
run: |
58-
git tag v$VERSION
59-
git push origin release
60-
git push origin v$VERSION
61-
- name: Publish to npm
25+
- name: Make semantic release
6226
env:
63-
NPM_REGISTRY: "registry.npmjs.org"
64-
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
65-
run: |
66-
npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}"
67-
npm publish --tag $CHANNEL
68-
cd lib/loader
69-
npm publish --tag $CHANNEL --access public
70-
cd ../..
71-
- name: Publish to gpr
72-
env:
73-
NPM_REGISTRY: "npm.pkg.github.com"
74-
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
29+
# On success, semantic-release will update the version and publish,
30+
# triggering the postversion script that'll update the loader's version
31+
# as well. If nothing was published, the version will still be '0.0.0'.
7532
run: |
76-
npm config set "//${NPM_REGISTRY}/:_authToken=${NPM_AUTH_TOKEN}"
77-
sed -i 's/"assemblyscript"/"@assemblyscript\/assemblyscript"/' package.json
78-
sed -i 's/"assemblyscript"/"@assemblyscript\/assemblyscript"/' package-lock.json
79-
npm publish --registry=https://${NPM_REGISTRY}
33+
node node_modules/semantic-release/bin/semantic-release.js --unstable
8034
cd lib/loader
81-
npm publish --registry=https://${NPM_REGISTRY}
35+
if [ $(node -pe "require('./package.json').version") != "0.0.0" ]; then
36+
npm config set "//registry.npmjs.org/:_authToken=${NPM_TOKEN}"
37+
npm publish --access public
38+
fi
8239
cd ../..

0 commit comments

Comments
 (0)