Skip to content

Commit

Permalink
Use ESLint to add more checks (#4)
Browse files Browse the repository at this point in the history
* Update `check` to include all project specifiers when calling TypeScript

Because TypeScript automatically finds all dependencies, this doesn't
have any impact on TypeScript's diagnostics

* Update `check` to include diagnostics with ESLint

* Tweak runtime package to use esbuild using a build script

* Update ESLint to use TypeScript parser

To use the TypeScript ESLint parser, the ESBuild build script needed to
be updated to shim multiple NodeJS APIs

* Switch to using `eslint` package directly instead of `eslint-linter-browserify`

* Use TypeScript parser when using ESLint in LSP diagnostics

* Fix column offsets in LSP for ESLint rules

* Move ESLint config to a common module

* Reduce "no-unused-vars" rule to a warning

* Update LSP and `brioche check` to use ESLint diagnostic levels

* Switch to custom `path` NodeJS compatibility module implementation

* Fix more errors in `brioche check`

* Set up `@typescript-eslint/plugin`

* Enable a bunch of ESLint rules from `@typescript-eslint`

* Set esbuild script log level to "info"

* Enable and tweak some ESLint rules

* Switch to `esbuild-plugin-alias-path`

The repo for `esbuild-plugin-alias` no longer exists, so it seems like
it's no longer supported. `esbuild-plugin-alias-path` also seems to work
and produced no actual build changes!

* Use `node --loader=ts-node/esm` instead `ts-node-esm`

* Enable some optimizations in debug builds

This fixes a stack overflow when running tests that was apparently
introduced with the new linting rules. It seems to overflow when parsing
JS code (somewhere in `swc`)

* Update "check" tests to fix errors from new lint rules

* Add test for some basic lint rules

* Update "check" tests to check diagnostic levels
  • Loading branch information
kylewlacy authored Jan 20, 2024
1 parent 3ba8119 commit 27b0f15
Show file tree
Hide file tree
Showing 27 changed files with 5,185 additions and 289 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
members = ["crates/brioche", "crates/brioche-ld", "crates/brioche-pack", "crates/brioche-packed-exec", "crates/brioche-packed-userland-exec"]
resolver = "2"

[profile.dev]
# Enable optimizations for debug builds because the JS runs slow without it.
# Also, we end up overflowing the stack without optimizations when parsing JS
opt-level = 2

[profile.release-tiny]
inherits = "release"
opt-level = "z"
Expand Down
33 changes: 33 additions & 0 deletions crates/brioche/runtime/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import * as esbuild from "esbuild";
import { aliasPath } from "esbuild-plugin-alias-path";
import * as path from "node:path";

await esbuild.build({
logLevel: "info",
bundle: true,
entryPoints: ["./src/index.ts"],
format: "esm",
outfile: "dist/index.js",
minifyWhitespace: true,
define: {
global: "globalThis",
"__filename": "\"\"",
},
plugins: [
aliasPath({
alias: {
assert: path.resolve("./src/compat/node/assert.cjs"),
buffer: path.resolve("./src/compat/node/buffer.cjs"),
crypto: path.resolve("./src/compat/node/crypto.cjs"),
events: path.resolve("./src/compat/node/events.cjs"),
fs: path.resolve("./src/compat/node/fs.cjs"),
module: path.resolve("./src/compat/node/module.cjs"),
os: path.resolve("./src/compat/node/os.cjs"),
path: path.resolve("./src/compat/node/path.cjs"),
stream: path.resolve("./src/compat/node/stream.cjs"),
url: path.resolve("./src/compat/node/url.cjs"),
util: path.resolve("./src/compat/node/util.cjs"),
},
}),
],
});
317 changes: 294 additions & 23 deletions crates/brioche/runtime/dist/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 27b0f15

Please sign in to comment.