Skip to content

Commit

Permalink
Merge branch 'main' into don/test/dequeue
Browse files Browse the repository at this point in the history
  • Loading branch information
DonIsaac authored Jan 8, 2025
2 parents 000be1d + 76800b0 commit 911b2e1
Show file tree
Hide file tree
Showing 39 changed files with 235 additions and 165 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
pull_request:
workflow_dispatch:

env:
BUN_VERSION: "1.1.38"
OXLINT_VERSION: "0.15.0"

jobs:
lint-js:
name: "Lint JavaScript"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: ./.github/actions/setup-bun
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Lint
run: bunx oxlint --config oxlint.json --quiet --format github




19 changes: 19 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Typos

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Spellcheck
uses: crate-ci/typos@v1.29.4
with:
files: docs/**/*
2 changes: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[type.md]
extend-ignore-words-re = ["^ba"]
22 changes: 10 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,29 @@ $ brew install llvm@18

```bash#Ubuntu/Debian
$ # LLVM has an automatic installation script that is compatible with all versions of Ubuntu
$ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 16 all
$ wget https://apt.llvm.org/llvm.sh -O - | sudo bash -s -- 18 all
```

```bash#Arch
$ sudo pacman -S llvm clang lld
```

```bash#Fedora
$ sudo dnf install 'dnf-command(copr)'
$ sudo dnf copr enable -y @fedora-llvm-team/llvm17
$ sudo dnf install llvm16 clang16 lld16-devel
$ sudo dnf install llvm18 clang18 lld18-devel
```

```bash#openSUSE Tumbleweed
$ sudo zypper install clang16 lld16 llvm16
$ sudo zypper install clang18 lld18 llvm18
```

{% /codetabs %}

If none of the above solutions apply, you will have to install it [manually](https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.6).
If none of the above solutions apply, you will have to install it [manually](https://github.com/llvm/llvm-project/releases/tag/llvmorg-18.1.8).

Make sure Clang/LLVM 18 is in your path:

```bash
$ which clang-16
$ which clang-18
```

If not, run this to manually add it:
Expand All @@ -96,13 +94,13 @@ If not, run this to manually add it:

```bash#macOS (Homebrew)
# use fish_add_path if you're using fish
# use path+="$(brew --prefix llvm@16)/bin" if you are using zsh
$ export PATH="$(brew --prefix llvm@16)/bin:$PATH"
# use path+="$(brew --prefix llvm@18)/bin" if you are using zsh
$ export PATH="$(brew --prefix llvm@18)/bin:$PATH"
```

```bash#Arch
# use fish_add_path if you're using fish
$ export PATH="$PATH:/usr/lib/llvm16/bin"
$ export PATH="$PATH:/usr/lib/llvm18/bin"
```

{% /codetabs %}
Expand Down Expand Up @@ -163,7 +161,7 @@ The binary will be located at `./build/release/bun` and `./build/release/bun-pro

### Download release build from pull requests

To save you time spent building a release build locally, we provide a way to run release builds from pull requests. This is useful for manully testing changes in a release build before they are merged.
To save you time spent building a release build locally, we provide a way to run release builds from pull requests. This is useful for manually testing changes in a release build before they are merged.

To run a release build from a pull request, you can use the `bun-pr` npm package:

Expand Down Expand Up @@ -240,7 +238,7 @@ The issue may manifest when initially running `bun setup` as Clang being unable
```
The C++ compiler
"/usr/bin/clang++-16"
"/usr/bin/clang++-18"
is not able to compile a simple test program.
```
Expand Down
2 changes: 1 addition & 1 deletion bench/hot-module-reloading/css-stress-test/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ReactDOM from "react-dom";
import { Main } from "./main";

const Base = ({}) => {
const Base = () => {
const name = typeof location !== "undefined" ? decodeURIComponent(location.search.substring(1)) : null;
return <Main productName={name} />;
};
Expand Down
1 change: 0 additions & 1 deletion bench/snippets/urlsearchparams.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bench("new URLSearchParams(obj)", () => {
"Content-Length": "123",
"User-Agent": "node-fetch/1.0",
"Accept-Encoding": "gzip,deflate",
"Content-Length": "0",
"Content-Range": "bytes 0-9/10",
});
});
Expand Down
2 changes: 1 addition & 1 deletion docs/api/s3.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ If the `S3_*` environment variable is not set, Bun will also check for the `AWS_

These environment variables are read from [`.env` files](/docs/runtime/env) or from the process environment at initialization time (`process.env` is not used for this).

These defaults are overriden by the options you pass to `s3(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3()` helper function without having to specify all the credentials again.
These defaults are overridden by the options you pass to `s3(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3()` helper function without having to specify all the credentials again.

### `S3Client` objects

Expand Down
4 changes: 2 additions & 2 deletions docs/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ const strict = new Database(
// throws error because of the typo:
const query = strict
.query("SELECT $message;")
.all({ messag: "Hello world" });
.all({ message: "Hello world" });

const notStrict = new Database(
":memory:"
);
// does not throw error:
notStrict
.query("SELECT $message;")
.all({ messag: "Hello world" });
.all({ message: "Hello world" });
```

### Load via ES module import
Expand Down
2 changes: 1 addition & 1 deletion docs/api/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const id = randomUUIDv7();

A UUID v7 is a 128-bit value that encodes the current timestamp, a random value, and a counter. The timestamp is encoded using the lowest 48 bits, and the random value and counter are encoded using the remaining bits.

The `timestamp` parameter defaults to the current time in milliseconds. When the timestamp changes, the counter is reset to a psuedo-random integer wrapped to 4096. This counter is atomic and threadsafe, meaning that using `Bun.randomUUIDv7()` in many Workers within the same process running at the same timestamp will not have colliding counter values.
The `timestamp` parameter defaults to the current time in milliseconds. When the timestamp changes, the counter is reset to a pseudo-random integer wrapped to 4096. This counter is atomic and threadsafe, meaning that using `Bun.randomUUIDv7()` in many Workers within the same process running at the same timestamp will not have colliding counter values.

The final 8 bytes of the UUID are a cryptographically secure random value. It uses the same random number generator used by `crypto.randomUUID()` (which comes from BoringSSL, which in turn comes from the platform-specific system random number generator usually provided by the underlying hardware).

Expand Down
2 changes: 1 addition & 1 deletion docs/cli/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ $ bun outdated --filter 'pkg-*'
$ bun outdated --filter './'
```

For more infomation on both these commands, see [`bun install`](https://bun.sh/docs/cli/install) and [`bun outdated`](https://bun.sh/docs/cli/outdated).
For more information on both these commands, see [`bun install`](https://bun.sh/docs/cli/install) and [`bun outdated`](https://bun.sh/docs/cli/outdated).

## Running scripts with `--filter`

Expand Down
2 changes: 1 addition & 1 deletion docs/install/lockfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ $ head -n3 bun.lock
"workspaces": {
```
Once `bun.lock` is generated, Bun will use it for all subsequent installs and updates through commands that read and modify the lockfile. If both lockfiles exist, `bun.lock` will be choosen over `bun.lockb`.
Once `bun.lock` is generated, Bun will use it for all subsequent installs and updates through commands that read and modify the lockfile. If both lockfiles exist, `bun.lock` will be chosen over `bun.lockb`.
Bun v1.2.0 will switch the default lockfile format to `bun.lock`.
Expand Down
2 changes: 1 addition & 1 deletion docs/runtime/shell.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The default handling of non-zero exit codes can be configured by calling `.nothr
import { $ } from "bun";
// shell promises will not throw, meaning you will have to
// check for `exitCode` manually on every shell command.
$.nothrow(); // equivilent to $.throws(false)
$.nothrow(); // equivalent to $.throws(false)

// default behavior, non-zero exit codes will throw an error
$.throws(true);
Expand Down
51 changes: 51 additions & 0 deletions oxlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/refs/heads/main/npm/oxlint/configuration_schema.json",
"categories": {
"correctness": "warn" // TODO: gradually fix bugs and turn this to error
},
"rules": {
"const-comparisons": "off", // TODO: there's a bug when comparing private identifiers. Re-enable once it's fixed.
"no-cond-assign": "error",
"no-const-assign": "error",
"no-debugger": "error",
"no-dupe-class-members": "error",
"no-dupe-keys": "error",
"no-empty-pattern": "error",
"import/no-duplicates": "error",

"no-useless-escape": "off" // there's a lot of these. Should be fixed eventually.
},
"ignorePatterns": [
"vendor",
"build",
"test/snapshots/**",
"bench/react-hello-world/*.js",

"test/js/node/**/parallel/**",
"test/js/node/test/fixtures", // full of JS with intentional syntax errors
"test/snippets/**",
"test/regression/issue/14477/*.tsx",
"test/js/**/*bad.js",
"test/bundler/transpiler/decorators.test.ts", // uses `arguments` as decorator
"test/bundler/native-plugin.test.ts", // parser doesn't handle import metadata
"test/bundler/transpiler/with-statement-works.js" // parser doesn't allow `with` statement
],
"overrides": [
{
"files": ["test/**", "examples/**", "packages/bun-internal/test/runners/**"],
"rules": {
"no-unused-vars": "off",
"no-unused-private-class-members": "off",
"no-unnecessary-await": "off"
}
},
{
"files": ["test/**", "bench/**"],
"rules": {
"no-shadow-restricted-names": "off",
"no-empty-file": "off",
"no-unnecessary-await": "off"
}
}
]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"fmt": "bun run prettier",
"fmt:cpp": "bun run clang-format",
"fmt:zig": "bun run zig-format",
"lint": "eslint './**/*.d.ts' --cache",
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
"lint": "oxlint --config oxlint.json",
"lint:fix": "oxlint --config oxlint.json --fix",
"test": "node scripts/runner.node.mjs --exec-path ./build/debug/bun-debug",
"test:release": "node scripts/runner.node.mjs --exec-path ./build/release/bun",
"banned": "bun packages/bun-internal-test/src/linter.ts",
Expand Down
5 changes: 0 additions & 5 deletions packages/bun-wasm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,20 @@ const Wasi = {
return Date.now();
},
environ_sizes_get() {
debugger;
return 0;
},
environ_get(__environ: unknown, environ_buf: unknown) {
debugger;
return 0;
},

fd_close(fd: number) {
debugger;
return 0;
},
proc_exit() {},

fd_seek(fd: number, offset_bigint: bigint, whence: unknown, newOffset: unknown) {
debugger;
},
fd_write(fd: unknown, iov: unknown, iovcnt: unknown, pnum: unknown) {
debugger;
},
};

Expand Down
3 changes: 2 additions & 1 deletion src/bun.js/RuntimeTranspilerCache.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
/// Version 10: Constant folding for ''.charCodeAt(n)
/// Version 11: Fix \uFFFF printing regression
/// Version 12: "use strict"; makes it CommonJS if we otherwise don't know which one to pick.
const expected_version = 12;
/// Version 13: Hoist `import.meta.require` definition, see #15738
const expected_version = 13;

const bun = @import("root").bun;
const std = @import("std");
Expand Down
4 changes: 0 additions & 4 deletions src/bun.js/api/JSTranspiler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,6 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std
}

transpiler.runtime.allow_runtime = false;
transpiler.runtime.use_import_meta_require = switch (transpiler.transform.target orelse .browser) {
.bun, .bun_macro => true,
else => false,
};

if (try object.getTruthy(globalThis, "macro")) |macros| {
macros: {
Expand Down
3 changes: 0 additions & 3 deletions src/bun.js/api/sockets.classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ function generate(ssl) {
fn: "reload",
length: 1,
},
bytesWritten: {
getter: "getBytesWritten",
},
setServername: {
fn: "setServername",
length: 1,
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/webcore/S3Stat.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const bun = @import("../../bun.zig");
const JSC = @import("../../JSC.zig");
const JSC = @import("../../jsc.zig");

pub const S3Stat = struct {
const log = bun.Output.scoped(.S3Stat, false);
Expand Down
Loading

0 comments on commit 911b2e1

Please sign in to comment.