Skip to content

Commit

Permalink
update eslint to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Aug 20, 2024
1 parent 1fc80ca commit ab966dd
Show file tree
Hide file tree
Showing 15 changed files with 396 additions and 443 deletions.
4 changes: 1 addition & 3 deletions build/wd_ts_bundle.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")
load("@npm//:eslint/package_json.bzl", eslint_bin = "bin")
load("@workerd//:build/wd_js_bundle.bzl", "wd_js_bundle_capnp")
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")

def _to_js(file_name):
if file_name.endswith(".ts"):
Expand Down Expand Up @@ -90,7 +90,6 @@ def wd_ts_bundle_capnp(
data = srcs + [
eslintrc_json,
tsconfig_json,
"//:node_modules/@typescript-eslint/eslint-plugin",
],
tags = ["lint"],
target_compatible_with = select({
Expand All @@ -100,7 +99,6 @@ def wd_ts_bundle_capnp(
)
return data


def wd_ts_bundle(name, import_name, *args, **kwargs):
data = wd_ts_bundle_capnp(name + ".capnp", import_name, *args, **kwargs)
cc_capnp_library(
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,23 @@
},
"dependencies": {
"capnp-ts": "^0.7.0",
"prettier": "^3.2.5",
"prettier": "^3.3.3",
"typescript": "5.5.4"
},
"devDependencies": {
"@bazel/bazelisk": "~1.19.0",
"@eslint/js": "^9.9.0",
"@types/debug": "^4.1.10",
"@types/eslint__js": "^8.42.3",
"@types/node": "^20.14.8",
"@types/prettier": "^2.7.1",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"capnpc-ts": "^0.7.0",
"chrome-remote-interface": "^0.33.2",
"esbuild": "^0.15.18",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint": "^9.9.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"expect-type": "^0.18.0"
"eslint-plugin-prettier": "^5.2.1",
"expect-type": "^0.18.0",
"typescript-eslint": "^8.2.0"
},
"pnpm": {
"overrides": {
Expand Down
540 changes: 256 additions & 284 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

41 changes: 0 additions & 41 deletions src/cloudflare/.eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/cloudflare/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@workerd//:build/wd_ts_bundle.bzl", "wd_ts_bundle")

wd_ts_bundle(
name = "cloudflare",
eslintrc_json = ".eslintrc.json",
eslintrc_json = "eslint.config.mjs",
import_name = "cloudflare",
internal_modules = glob(
[
Expand Down
4 changes: 4 additions & 0 deletions src/cloudflare/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { baseConfig } from "../../tools/base.eslint.config.mjs";

// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
export default [...baseConfig({ tsconfigRootDir: import.meta.dirname })];
41 changes: 0 additions & 41 deletions src/node/.eslintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ load("@workerd//:build/wd_ts_bundle.bzl", "wd_ts_bundle")

wd_ts_bundle(
name = "node",
eslintrc_json = ".eslintrc.json",
eslintrc_json = "eslint.config.mjs",
import_name = "node",
internal_modules = glob([
"internal/*.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/node/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { baseConfig } from "../../tools/base.eslint.config.mjs";

export default [...baseConfig({ tsconfigRootDir: import.meta.dirname })];
6 changes: 0 additions & 6 deletions src/pyodide/.eslintrc.json

This file was deleted.

63 changes: 35 additions & 28 deletions src/pyodide/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
load("@bazel_skylib//rules:write_file.bzl", "write_file")
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")
load("//:build/capnp_embed.bzl", "capnp_embed")
load("//:build/pyodide_bucket.bzl", "PYODIDE_PACKAGE_BUCKET_URL")
load("//:build/wd_ts_bundle.bzl", "wd_ts_bundle_capnp")

copy_file(
Expand All @@ -20,7 +21,7 @@ capnp_embed(
copy_file(
name = "python_entrypoint_file",
src = "python-entrypoint.js",
out = "generated/python-entrypoint.js"
out = "generated/python-entrypoint.js",
)

capnp_embed(
Expand Down Expand Up @@ -53,9 +54,9 @@ cc_capnp_library(
visibility = ["//visibility:public"],
deps = [
":pyodide_extra_file_embed",
":pyodide_lock_file_embed",
":pyodide_packages_archive_embed",
":python_entrypoint_file_embed",
":pyodide_lock_file_embed"
],
)

Expand Down Expand Up @@ -119,16 +120,14 @@ REPLACEMENTS = [
],
[
"reportUndefinedSymbols()",
"reportUndefinedSymbolsNoOp()"
"reportUndefinedSymbolsNoOp()",
],
[
"crypto.getRandomValues(",
"getRandomValues(Module, ",
]
],
]

load("//:build/pyodide_bucket.bzl", "PYODIDE_PACKAGE_BUCKET_URL")

PYODIDE_BUCKET_MODULE = json.encode({
"PYODIDE_PACKAGE_BUCKET_URL": PYODIDE_PACKAGE_BUCKET_URL,
})
Expand All @@ -148,55 +147,61 @@ expand_template(

data = wd_ts_bundle_capnp(
name = "pyodide.capnp",
modules = ["python-entrypoint-helper.ts"],
eslintrc_json = "eslint.config.mjs",
import_name = "pyodide",
internal_data_modules = ["generated/python_stdlib.zip"] + glob([
"internal/*.py",
"internal/patches/*.py",
"internal/topLevelEntropy/*.py",
]),
internal_json_modules = ["generated/pyodide-lock.json", "generated/pyodide-bucket.json"],
internal_json_modules = [
"generated/pyodide-lock.json",
"generated/pyodide-bucket.json",
],
internal_modules = [
"generated/pyodide.asm.js",
] + glob([
"internal/*.ts",
"internal/*.js",
"internal/topLevelEntropy/*.ts",
"internal/topLevelEntropy/*.js",
"types/*.ts",
"types/*/*.ts",
], allow_empty = True),
] + glob(
[
"internal/*.ts",
"internal/*.js",
"internal/topLevelEntropy/*.ts",
"internal/topLevelEntropy/*.js",
"types/*.ts",
"types/*/*.ts",
],
allow_empty = True,
),
internal_wasm_modules = ["generated/pyodide.asm.wasm"],
schema_id = "0xbcc8f57c63814005",
tsconfig_json = "tsconfig.json",
eslintrc_json = ".eslintrc.json",
lint = False,
js_deps = [
"pyodide.asm.js@rule",
"pyodide.asm.wasm@rule",
"pyodide-lock.js@rule",
"python_stdlib.zip@rule",
"pyodide-bucket.json@rule",
],
lint = False,
modules = ["python-entrypoint-helper.ts"],
schema_id = "0xbcc8f57c63814005",
tsconfig_json = "tsconfig.json",
)

cc_capnp_library(
name = "pyodide",
srcs = ["pyodide.capnp"],
data = data,
include_prefix = "pyodide",
strip_include_prefix = "",
visibility = ["//visibility:public"],
data = data,
deps = ["@workerd//src/workerd/jsg:modules_capnp"],
include_prefix = "pyodide",
)


genrule(
name = "pyodide.capnp.bin@rule",
tools = ["@capnp-cpp//src/capnp:capnp_tool"],
srcs = ["pyodide.capnp", "//src/workerd/jsg:modules.capnp"] + data,
srcs = [
"pyodide.capnp",
"//src/workerd/jsg:modules.capnp",
] + data,
outs = ["pyodide.capnp.bin"],
visibility = ["//visibility:public"],
cmd = " ".join([
# Annoying logic to deal with different paths in workerd vs downstream.
# Either need "-I src" in workerd or -I external/workerd/src downstream
Expand All @@ -208,5 +213,7 @@ genrule(
"-I $$INCLUDE",
"-o binary",
"> $@",
])
]),
tools = ["@capnp-cpp//src/capnp:capnp_tool"],
visibility = ["//visibility:public"],
)
49 changes: 49 additions & 0 deletions tools/base.eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import prettierPlugin from "eslint-plugin-prettier/recommended";

/**
* @param {string} tsconfigRootDir
* @returns {FlatConfig.ConfigArray}
*/
export function baseConfig({ tsconfigRootDir }) {
return tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
{
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
projectService: true,
tsconfigRootDir,
},
},
rules: {
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/explicit-member-accessibility": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/prefer-enum-initializers": "error",
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-extraneous-class": "off",
"@typescript-eslint/unified-signatures": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
prettierPlugin,
)
}
29 changes: 0 additions & 29 deletions types/.eslintrc.js

This file was deleted.

Loading

0 comments on commit ab966dd

Please sign in to comment.