Skip to content

Commit

Permalink
chore(eslint-config)!: Update linting rules (#774)
Browse files Browse the repository at this point in the history
This changes our linting rules to remove eslint-config-next and eslint-config-react since we don't need those in the SDK monorepo. I also added various other linting and made sure we were linting our TypeScript code, which caught a few mistakes but nothing consequential.

This is breaking because we'll need to update code that consumes the linting rules to now pull in the removed configs.

Closes #337
  • Loading branch information
blaine-arcjet committed May 17, 2024
1 parent 81d1078 commit c223ba0
Show file tree
Hide file tree
Showing 9 changed files with 271 additions and 2,104 deletions.
2 changes: 1 addition & 1 deletion arcjet-next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export function createMiddleware(
request: NextRequest,
event: NextFetchEvent,
): Promise<NextMiddlewareResult> {
let decision = await arcjet.protect(request);
const decision = await arcjet.protect(request);

if (decision.isDenied()) {
// TODO(#222): Content type negotiation using `Accept` header
Expand Down
2 changes: 1 addition & 1 deletion arcjet/test/index.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function assertIsLocalRule(rule: ArcjetRule): asserts rule is ArcjetLocalRule {
function deferred(): [Promise<void>, () => void, (reason?: unknown) => void] {
let resolve: () => void;
let reject: (reason?: unknown) => void;
let promise = new Promise<void>((res, rej) => {
const promise = new Promise<void>((res, rej) => {
resolve = res;
reject = rej;
});
Expand Down
23 changes: 18 additions & 5 deletions eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
module.exports = {
extends: ["next/core-web-vitals", "turbo", "prettier"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"turbo",
"prettier",
],
rules: {
"@next/next/no-html-link-for-pages": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-unused-vars": "off",
},
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
env: {
es2022: true,
},
parserOptions: {
babelOptions: {
presets: [require.resolve("next/babel")],
},
ecmaVersion: "2022",
sourceType: "module",
},
};
9 changes: 4 additions & 5 deletions eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@
"lint": "eslint ."
},
"dependencies": {
"eslint-config-next": "14.2.3",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@typescript-eslint/parser": "7.9.0",
"eslint-config-prettier": "9.1.0",
"eslint-config-turbo": "1.13.3",
"eslint-plugin-react": "7.34.1"
"eslint-config-turbo": "1.13.3"
},
"peerDependencies": {
"eslint": "^8",
"next": ">=14"
"eslint": "^8"
},
"devDependencies": {
"eslint": "8.57.0"
Expand Down
6 changes: 3 additions & 3 deletions ip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Parser {
let digitCount = 0;
const hasLeadingZero = p.peakChar() === "0";

let nextCharAsDigit = () => {
function nextCharAsDigit() {
return p.readAtomically((p) => {
const c = p.readChar();
if (c) {
Expand All @@ -144,7 +144,7 @@ class Parser {
}
}
});
};
}

for (
let digit = nextCharAsDigit();
Expand Down Expand Up @@ -205,7 +205,7 @@ class Parser {
if (i < limit - 1) {
const ipv4 = p.readSeparator(":", i, (p) => p.readIPv4Address());
if (isIPv4Tuple(ipv4)) {
let [one, two, three, four] = ipv4;
const [one, two, three, four] = ipv4;
groups[i + 0] = u16FromBytes([one, two]);
groups[i + 1] = u16FromBytes([three, four]);
return [i + 2, true];
Expand Down
3 changes: 2 additions & 1 deletion logger/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ export class Logger {
case "ERROR":
this.#logLevel = 3;
break;
default:
default: {
const _exhaustiveCheck: never = levelStr;
throw new Error(`Unknown log level: ${levelStr}`);
}
}
}

Expand Down
Loading

0 comments on commit c223ba0

Please sign in to comment.