ci: repair lint setup and run it in CI (#15720)

Co-authored-by: Don Isaac <don@bun.sh>
This commit is contained in:
Don Isaac
2025-01-08 01:12:18 -06:00
committed by GitHub
parent a3cbf974eb
commit 81ecf7556c
16 changed files with 85 additions and 34 deletions

26
.github/workflows/lint.yml vendored Normal file
View File

@@ -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

View File

@@ -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} />;
};

View File

@@ -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",
});
});

51
oxlint.json Normal file
View File

@@ -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"
}
}
]
}

View File

@@ -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",

View File

@@ -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;
},
};

View File

@@ -182,9 +182,6 @@ function generate(ssl) {
fn: "reload",
length: 1,
},
bytesWritten: {
getter: "getBytesWritten",
},
setServername: {
fn: "setServername",
length: 1,

View File

@@ -112,7 +112,6 @@ export default {
DatePrototypeToString: uncurryThis(Date.prototype.toString),
ErrorCaptureStackTrace,
ErrorPrototypeToString: uncurryThis(Error.prototype.toString),
FunctionPrototypeToString: uncurryThis(Function.prototype.toString),
JSONStringify: JSON.stringify,
MapPrototypeGetSize: getGetter(Map, "size"),
MapPrototypeEntries: uncurryThis(Map.prototype.entries),

View File

@@ -2419,7 +2419,7 @@ class ServerHttp2Session extends Http2Session {
// throwNotImplemented("ServerHttp2Stream.prototype.origin()");
}
constructor(socket: TLSSocket | Socket, options?: Http2ConnectOptions, server: Http2Server) {
constructor(socket: TLSSocket | Socket, options?: Http2ConnectOptions, server?: Http2Server) {
super();
this[kServer] = server;
this.#connected = true;

View File

@@ -1342,7 +1342,6 @@ class Server extends EventEmitter {
});
} else {
this._handle = Bun.listen({
exclusive,
port,
hostname,
tls,

View File

@@ -813,7 +813,6 @@ body {
// Test that sourcemap comments are not included in HTML and CSS files
itBundled("html/no-sourcemap-comments", {
outdir: "out/",
sourceMap: "linked",
files: {
"/index.html": `
<!DOCTYPE html>

View File

@@ -2,9 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { describe, expect, test } from "bun:test";
import { describe, test } from "bun:test";
import "harness";
import path from "path";
import { attrTest, cssTest, indoc, minify_test, minifyTest, prefix_test } from "./util";
describe("css tests", () => {

View File

@@ -927,14 +927,6 @@ const libSymbols = {
returns: "int",
args: ["ptr", "ptr", "usize"],
},
pthread_attr_getguardsize: {
returns: "int",
args: ["ptr", "ptr"],
},
pthread_attr_setguardsize: {
returns: "int",
args: ["ptr", "usize"],
},
login_tty: {
returns: "int",
args: ["int"],

View File

@@ -1,12 +1,8 @@
import { it, expect } from "bun:test";
import { mkdirSync, writeFileSync } from "fs";
import { join } from "path";
import { join, sep } from "path";
import { bunExe, bunEnv, tempDirWithFiles, isWindows } from "harness";
import { pathToFileURL } from "bun";
import { expect, it } from "bun:test";
import { mkdirSync, writeFileSync } from "fs";
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
import { join, sep } from "path";
it("spawn test file", () => {
writePackageJSONImportsFixture();

View File

@@ -210,8 +210,7 @@ it("fetch() with a gzip response works (multiple chunks, TCP server)", async don
await write("\r\n");
socket.flush();
},
drain(socket) {},
}
},
});
await 1;

View File

@@ -10,7 +10,7 @@ const ContextProvider = ({ children }) => {
return <Context.Provider value={cb}>{children(foo)}</Context.Provider>;
};
const ContextValue = ({}) => (
const ContextValue = () => (
<Context.Consumer>
{foo => {
if (foo) {