Unverified Commit d7fa64ea authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Update eslint and restore `.eslintrc.cli.json` being used for CLI/CI-based linting (#81553)

This will allow us (again) to selectively use type-checked rules
internally, as stipulated in #67689. In a follow-up, we'll likely add
https://typescript-eslint.io/rules/switch-exhaustiveness-check/ as a
first type-checked rule.
parent f1b95e04
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
"parserOptions": { "parserOptions": {
"project": true "project": true
}, },
// These rules are added on top of the rules that are declared in
// .eslintrc.json for the matching files.
"rules": { "rules": {
// TODO: enable in follow-up PR // TODO: enable in follow-up PR
"@typescript-eslint/no-floating-promises": "off" "@typescript-eslint/no-floating-promises": "off"
......
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
// This is the default eslint config that is used by IDEs. It does not use // This is the default eslint config that is used by IDEs. It does not use
// computation-heavy type-checked rules to ensure maximum responsiveness while // computation-heavy type-checked rules to ensure maximum responsiveness while
// writing code. In addition, there is .eslintrc.cli.json that does use // writing code. In addition, there is .eslintrc.cli.json that does use
// type-checked rules, and it is used when running `pnpm lint-eslint`. // type-checked rules in addition to the rules defined here, and it is used
// when running `pnpm lint-eslint` locally or in CI.
"$schema": "https://json.schemastore.org/eslintrc", "$schema": "https://json.schemastore.org/eslintrc",
"root": true, "root": true,
"parser": "@babel/eslint-parser", "parser": "@babel/eslint-parser",
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
"overrides": [ "overrides": [
{ {
"files": ["test/**/*.js", "test/**/*.ts", "**/*.test.ts"], "files": ["test/**/*.js", "test/**/*.ts", "**/*.test.ts"],
"excludedFiles": ["test/tmp/**"],
"extends": ["plugin:jest/recommended"], "extends": ["plugin:jest/recommended"],
"rules": { "rules": {
"jest/expect-expect": "off", "jest/expect-expect": "off",
......
...@@ -16,7 +16,7 @@ export async function POST(req: Request) { ...@@ -16,7 +16,7 @@ export async function POST(req: Request) {
} catch (err) { } catch (err) {
const errorMessage = err instanceof Error ? err.message : "Unknown error"; const errorMessage = err instanceof Error ? err.message : "Unknown error";
// On error, log and return the error message. // On error, log and return the error message.
if (err! instanceof Error) console.log(err); if (!(err instanceof Error)) console.log(err);
console.log(`❌ Error message: ${errorMessage}`); console.log(`❌ Error message: ${errorMessage}`);
return NextResponse.json( return NextResponse.json(
{ message: `Webhook Error: ${errorMessage}` }, { message: `Webhook Error: ${errorMessage}` },
......
module.exports = { module.exports = {
'*.{js,jsx,mjs,ts,tsx,mts,mdx}': [ '*.{js,jsx,mjs,ts,tsx,mts,mdx}': [
'prettier --with-node-modules --ignore-path .prettierignore --write', 'prettier --with-node-modules --ignore-path .prettierignore --write',
'cross-env ESLINT_USE_FLAT_CONFIG=false eslint --config .eslintrc.json --no-eslintrc --fix', 'cross-env ESLINT_USE_FLAT_CONFIG=false eslint --config .eslintrc.cli.json --no-eslintrc --fix',
], ],
'*.{json,md,css,html,yml,yaml,scss}': [ '*.{json,md,css,html,yml,yaml,scss}': [
'prettier --with-node-modules --ignore-path .prettierignore --write', 'prettier --with-node-modules --ignore-path .prettierignore --write',
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"git-clean": "git clean -d -x -e node_modules -e packages -f", "git-clean": "git clean -d -x -e node_modules -e packages -f",
"typescript": "tsc --noEmit", "typescript": "tsc --noEmit",
"lint-typescript": "turbo run typescript", "lint-typescript": "turbo run typescript",
"lint-eslint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint . --ext js,jsx,mjs,ts,tsx,mts,mdx --config .eslintrc.json --no-eslintrc", "lint-eslint": "cross-env ESLINT_USE_FLAT_CONFIG=false eslint . --ext js,jsx,mjs,ts,tsx,mts,mdx --config .eslintrc.cli.json --no-eslintrc",
"lint-ast-grep": "ast-grep scan", "lint-ast-grep": "ast-grep scan",
"lint-no-typescript": "run-p prettier-check lint-eslint lint-language", "lint-no-typescript": "run-p prettier-check lint-eslint lint-language",
"types-and-precompiled": "run-p lint-typescript check-compiler-fixtures types:test-lib && pnpm check-precompiled", "types-and-precompiled": "run-p lint-typescript check-compiler-fixtures types:test-lib && pnpm check-precompiled",
...@@ -142,8 +142,8 @@ ...@@ -142,8 +142,8 @@
"@types/relay-runtime": "14.1.13", "@types/relay-runtime": "14.1.13",
"@types/string-hash": "1.1.1", "@types/string-hash": "1.1.1",
"@types/trusted-types": "2.0.3", "@types/trusted-types": "2.0.3",
"@typescript-eslint/eslint-plugin": "8.0.0", "@typescript-eslint/eslint-plugin": "^8.36.0",
"@typescript-eslint/parser": "8.0.0", "@typescript-eslint/parser": "^8.36.0",
"@vercel/devlow-bench": "workspace:*", "@vercel/devlow-bench": "workspace:*",
"@vercel/fetch": "6.1.1", "@vercel/fetch": "6.1.1",
"@vercel/og": "0.7.2", "@vercel/og": "0.7.2",
......
...@@ -22,10 +22,6 @@ declare namespace NodeJS { ...@@ -22,10 +22,6 @@ declare namespace NodeJS {
// TODO: Should be optional and possibly undefined // TODO: Should be optional and possibly undefined
readonly NODE_ENV: 'development' | 'production' | 'test' readonly NODE_ENV: 'development' | 'production' | 'test'
} }
interface RequestInit extends globalThis.RequestInit {
next?: NextFetchRequestConfig | undefined
}
} }
declare module '*.module.css' { declare module '*.module.css' {
......
This diff is collapsed.
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
"test/**/*.util.ts", "test/**/*.util.ts",
"test/e2e/app-dir/use-cache-custom-handler/*.js", "test/e2e/app-dir/use-cache-custom-handler/*.js",
"test/lib/**/*.ts", "test/lib/**/*.ts",
"scripts/*.js", "scripts/**/*.js",
"scripts/*.cjs", "scripts/**/*.cjs",
"scripts/*.mjs", "scripts/**/*.mjs",
"scripts/*.ts", "scripts/**/*.ts",
"turbo/**/*.ts" "turbo/**/*.ts"
], ],
"exclude": ["scripts/minimal-server.js"] "exclude": ["scripts/minimal-server.js"]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment