Skip to content

Commit aa80992

Browse files
author
Willem Wyndham
committed
Merge branch 'fix/toString'
2 parents 892a01c + 8de62fd commit aa80992

Some content is hidden

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

42 files changed

+6702
-1244
lines changed

.eslintrc.js

+197
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
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+
18+
// === General rules =========================================================
19+
20+
rules: {
21+
// Omitted semicolons are hugely popular, yet within the compiler it makes
22+
// sense to be better safe than sorry.
23+
"semi": "error",
24+
25+
// Our code bases uses 2 spaces for indentation, and we enforce it here so
26+
// files don't mix spaces, tabs or different indentation levels.
27+
"indent": ["error", 2, {
28+
"SwitchCase": 1,
29+
"VariableDeclarator": "first",
30+
"offsetTernaryExpressions": true,
31+
"ignoredNodes": [ // FIXME: something's odd here
32+
"ConditionalExpression > *",
33+
"ConditionalExpression > * > *",
34+
"ConditionalExpression > * > * > *"
35+
]
36+
}],
37+
38+
// This is mostly visual style, making comments look uniform.
39+
"spaced-comment": ["error", "always", {
40+
"markers": ["/"], // triple-slash
41+
"exceptions": ["/"] // all slashes
42+
}],
43+
44+
// This tends to be annoying as it encourages developers to make everything
45+
// that is never reassigned a 'const', sometimes semantically incorrect so,
46+
// typically leading to huge diffs in follow-up PRs modifying affected code.
47+
"prefer-const": "off",
48+
49+
// It is perfectly fine to declare top-level variables with `var`, yet this
50+
// rule doesn't provide configuration options that would help.
51+
"no-var": "off",
52+
53+
// Quite often, dealing with multiple related cases at once or otherwise
54+
// falling through is exactly the point of using a switch.
55+
"no-fallthrough": "off",
56+
57+
// Typical false-positives here are `do { ... } while (true)` statements or
58+
// similar, but the only option provided here is not checking any loops.
59+
"no-constant-condition": ["error", { checkLoops: false }],
60+
61+
// Functions are nested in blocks occasionally, and there haven't been any
62+
// problems with this so far, so turning the check off.
63+
"no-inner-declarations": "off",
64+
65+
// Quite common in scenarios where an iteration starts at `current = this`.
66+
"@typescript-eslint/no-this-alias": "off",
67+
68+
// Disabled here, but enabled again for JavaScript files.
69+
"no-unused-vars": "off",
70+
71+
// Disabled here, but enabled again for TypeScript files.
72+
"@typescript-eslint/no-unused-vars": "off",
73+
74+
// Allow emptry functions for some of our base classes
75+
"@typescript-eslint/no-empty-function": "off"
76+
},
77+
overrides: [
78+
79+
// === TypeScript rules ====================================================
80+
81+
{
82+
files: [
83+
"**/assembly/**/*.ts"
84+
],
85+
rules: {
86+
// Enforcing to remove function parameters on stubs makes code less
87+
// maintainable, so we instead allow unused function parameters.
88+
"@typescript-eslint/no-unused-vars": [
89+
"warn", {
90+
"vars": "local",
91+
"varsIgnorePattern": "^_|^[A-Z](?:From|To)?$", // ignore type params
92+
"args": "none",
93+
"ignoreRestSiblings": false
94+
}
95+
],
96+
97+
// Namespaces are quite useful in AssemblyScript
98+
"@typescript-eslint/no-namespace": "off",
99+
100+
// There is actually codegen difference here
101+
"@typescript-eslint/no-array-constructor": "off",
102+
103+
// Sometimes it can't be avoided to add a @ts-ignore
104+
"@typescript-eslint/ban-ts-comment": "off",
105+
106+
// Utilized to achieve portability in some cases
107+
"@typescript-eslint/no-non-null-assertion": "off",
108+
}
109+
},
110+
111+
// === Compiler rules (extends AssemblyScript rules) =======================
112+
113+
{
114+
files: [
115+
"**/assembly/**/*.ts"
116+
],
117+
rules: {
118+
// There is an actual codegen difference here - TODO: revisit
119+
"no-cond-assign": "off",
120+
121+
// Not all types can be omitted in AS yet - TODO: revisit
122+
"@typescript-eslint/no-inferrable-types": "off",
123+
124+
// Used rarely to reference internals that are not user-visible
125+
"@typescript-eslint/triple-slash-reference": "off",
126+
127+
// The compiler has its own `Function` class for example
128+
"no-shadow-restricted-names": "off",
129+
"@typescript-eslint/ban-types": "off"
130+
}
131+
},
132+
133+
// === Standard Library rules (extends AssemblyScript rules) ===============
134+
135+
{
136+
files: [
137+
"**/assembly/**/*.ts"
138+
],
139+
rules: {
140+
// We are implementing with --noLib, so we shadow all the time
141+
"no-shadow-restricted-names": "off",
142+
143+
// Similarly, sometimes we need the return type to be String, not string
144+
"@typescript-eslint/ban-types": "off"
145+
}
146+
},
147+
148+
// === Standard Definition rules (extends TypeScript rules) ================
149+
150+
{
151+
files: [
152+
"**/assembly/**/*.d.ts"
153+
],
154+
rules: {
155+
// Often required to achieve compatibility with TypeScript
156+
"@typescript-eslint/no-explicit-any": "off",
157+
158+
// Interfaces can be stubs here, i.e. not yet fully implemented
159+
"@typescript-eslint/no-empty-interface": "off",
160+
161+
// Definitions make use of `object` to model rather unusual constraints
162+
"@typescript-eslint/ban-types": "off"
163+
}
164+
},
165+
166+
167+
168+
// === Test rules (extends TypeScript rules) ===============================
169+
170+
{
171+
files: [
172+
"**/assembly/__tests__/**/*.ts"
173+
],
174+
rules: {
175+
// Tests typically include unusual code patterns on purpose. This is
176+
// very likely not an extensive list, but covers what's there so far.
177+
"no-empty": "off",
178+
"no-cond-assign": "off",
179+
"no-compare-neg-zero": "off",
180+
"no-inner-declarations": "off",
181+
"no-constant-condition": "off",
182+
"use-isnan": "off",
183+
"@typescript-eslint/no-namespace": "off",
184+
"@typescript-eslint/no-unused-vars": "off",
185+
"@typescript-eslint/no-empty-function": "off",
186+
"@typescript-eslint/no-non-null-assertion": "off",
187+
"@typescript-eslint/no-extra-semi": "off",
188+
"@typescript-eslint/no-inferrable-types": "off",
189+
"@typescript-eslint/ban-types": "off",
190+
"@typescript-eslint/triple-slash-reference": "off",
191+
"@typescript-eslint/ban-ts-comment": "off",
192+
"@typescript-eslint/no-extra-non-null-assertion": "off",
193+
"@typescript-eslint/no-empty-interface": "off"
194+
}
195+
},
196+
]
197+
};

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
node_modules/
22
build/
3+
temp-docs/
34
tests/build
5+
utils/testsuite_helper/build
46
.DS_Store
57

68
*.wat

.travis.yml

+22-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
language: node_js
22
node_js:
3-
- "10"
4-
- "11"
5-
- "12"
3+
- "node"
4+
- "lts/*"
65

7-
script:
8-
- yarn test
6+
jobs:
7+
include:
8+
- name: yarn
9+
script:
10+
- yarn test
11+
- yarn docs
12+
13+
- name: fossa
14+
before_script:
15+
- "curl -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/fossas/fossa-cli/fc60c6631a5d372d5a45fea35e31665b338f260d/install.sh | sudo bash"
16+
script:
17+
- fossa init
18+
- fossa analyze --server-scan
19+
- fossa test
20+
21+
- name: JSON Test Suite
22+
before_script:
23+
- "curl https://wasmtime.dev/install.sh -sSf | bash"
24+
script:
25+
- bash utils/run_testsuite.sh

0 commit comments

Comments
 (0)