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 22, 2024
1 parent 3114d6d commit 229bc3d
Show file tree
Hide file tree
Showing 17 changed files with 384 additions and 414 deletions.
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
Expand Down Expand Up @@ -89,3 +90,10 @@ selects.config_setting_group(
":not_dbg_build",
],
)

# prettier
js_library(
name = "prettierrc",
srcs = [".prettierrc.json"],
visibility = ["//visibility:public"],
)
3 changes: 2 additions & 1 deletion build/wd_ts_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def wd_ts_bundle_capnp(
data = srcs + [
eslintrc_json,
tsconfig_json,
"//:node_modules/@typescript-eslint/eslint-plugin",
"//tools:base-eslint",
"//:prettierrc",
],
tags = ["lint"],
target_compatible_with = select({
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.

3 changes: 2 additions & 1 deletion src/pyodide/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ expand_template(

data = wd_ts_bundle_capnp(
name = "pyodide.capnp",
eslintrc_json = ".eslintrc.json",
eslintrc_json = "eslint.config.mjs",
import_name = "pyodide",
internal_data_modules = ["generated/python_stdlib.zip"] + glob([
"internal/*.py",
Expand Down Expand Up @@ -181,6 +181,7 @@ data = wd_ts_bundle_capnp(
],
lint = False,
modules = ["python-entrypoint-helper.ts"],
modules = ["python-entrypoint-helper.ts"],
schema_id = "0xbcc8f57c63814005",
tsconfig_json = "tsconfig.json",
)
Expand Down
12 changes: 12 additions & 0 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

js_library(
name = "base-eslint",
srcs = ["base.eslint.config.mjs"],
visibility = ["//visibility:public"],
deps = [
"//:node_modules/@eslint/js",
"//:node_modules/eslint-plugin-prettier",
"//:node_modules/typescript-eslint",
],
)
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.

38 changes: 38 additions & 0 deletions types/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import eslint from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import prettierPlugin from "eslint-plugin-prettier/recommended";
import tseslint from "typescript-eslint";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
{
languageOptions: {
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
},
},
{
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
plugins: { import: importPlugin },
rules: {
"import/order": ["warn", { alphabetize: { order: "asc" } }],
"sort-imports": ["warn", { ignoreDeclarationSort: true }],
},
},
prettierPlugin
);
2 changes: 1 addition & 1 deletion types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"composite": true,
"skipLibCheck": true
},
"include": ["src/**/*.ts", "test/**/*.ts", "scripts/**/*.ts"],
"include": ["src/**/*.ts", "test/**/*.ts", "scripts/**/*.ts", "eslint.config.mjs"],
"exclude": ["test/types/**/*.ts", "src/worker/**"]
}

0 comments on commit 229bc3d

Please sign in to comment.