Skip to content

Commit

Permalink
Update eslint & prettier
Browse files Browse the repository at this point in the history
Also migrate to the new config format of eslint
  • Loading branch information
vogelsgesang committed Oct 19, 2024
1 parent c15bf8a commit 117050b
Show file tree
Hide file tree
Showing 13 changed files with 2,090 additions and 2,254 deletions.
52 changes: 0 additions & 52 deletions .eslintrc.js

This file was deleted.

10 changes: 5 additions & 5 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
semi: true,
trailingComma: "all",
printWidth: 132,
tabWidth: 4,
bracketSpacing: false
semi: true,
trailingComma: "all",
printWidth: 132,
tabWidth: 4,
bracketSpacing: false,
};
68 changes: 68 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import reactPlugin from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";
import path from "node:path";
import {fileURLToPath} from "node:url";
import {includeIgnoreFile} from "@eslint/compat";
import {fixupPluginRules} from "@eslint/compat";
import globals from "globals";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, ".gitignore");

export default [
includeIgnoreFile(gitignorePath),
eslint.configs.recommended,
reactPlugin.configs.flat["jsx-runtime"],
eslintPluginPrettierRecommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
{
...reactPlugin.configs.flat.recommended,
settings: {
...reactPlugin.configs.flat.recommended.settings,
react: {version: "detect"},
},
},
{
files: ["**/*.ts", "**/*.tsx", "**/*.js"],
languageOptions: {
globals: {
...globals.node,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"react-hooks": fixupPluginRules(reactHooks),
},
rules: {
// We don't consider those rules helpful
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": ["error", {vars: "all", argsIgnorePattern: "^_", caughtErrorsIgnorePattern: "^_"}],
// We use `react-jsx` and there `React` does not need to be in scope
"react/react-in-jsx-scope": "off",
// The following rules should be enabled, but aren't yet due to legacy code which still needs
// to be adapted
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-prototype-builtins": "off",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
},
},
{
files: ["**/*.js"],

rules: {
"@typescript-eslint/no-require-imports": 0,
},
},
];
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
"upload-server"
],
"scripts": {
"lint": "eslint . --ignore-path .gitignore --ext .ts,.tsx,.js --fix",
"lint-test": "eslint . --ignore-path .gitignore --ext .ts,.tsx,.js"
"lint": "eslint . --fix",
"lint-test": "eslint ."
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"eslint": "^8.56.0",
"@eslint/compat": "^1.2.1",
"eslint": "^9.13.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.2.4",
"typescript": "^5.6.3"
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^5.0.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3",
"typescript-eslint": "^8.10.0"
}
}
3 changes: 1 addition & 2 deletions query-graphs/src/hyper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ function convertOptimizerSteps(node: Json): LinkedNodes | undefined {
// Transform the optimizer steps
const crosslinks: Crosslink[] = [];
const children: TreeNode[] = [];
for (let i = 0; i < steps.length; ++i) {
const step = steps[i];
for (const step of steps) {
// Check that our step has two subproperties: "name" and "plan"
if (typeof step !== "object" || Array.isArray(step) || step === null) return undefined;
if (Object.getOwnPropertyNames(step).length != 2) return undefined;
Expand Down
2 changes: 1 addition & 1 deletion query-graphs/src/loader-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type Json = JsonPrimitive | JsonObject | JsonArray;
export interface JsonObject {
[x: string]: JsonPrimitive | JsonObject | JsonArray;
}
type JsonArray = Array<Json>;
type JsonArray = Json[];

// Checks if an object has a given key
// In contrast to a raw call, this function
Expand Down
2 changes: 1 addition & 1 deletion standalone-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0",
"webpack-merge": "^6.0.1",
"workbox-webpack-plugin": "^7.0.0"
"workbox-webpack-plugin": "^7.1.1"
}
}
2 changes: 1 addition & 1 deletion standalone-app/src/QueryGraphsApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function QueryGraphsApp() {
});
assert(uploadResult.ok);
url = new URL(await uploadResult.text());
} catch (e) {
} catch (_e) {
throw new Error(`Upload to ${uploadServer} failed!`);
}
}
Expand Down
2 changes: 1 addition & 1 deletion standalone-app/src/browserUrlHooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// `prettier` does not yet support `import type`
// eslint-disable-next-line prettier/prettier

import type React from "react";
import {useCallback, useEffect, useState} from "react";

Expand Down
4 changes: 1 addition & 3 deletions standalone-app/webpack/common.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// `prettier` does not yet support `import type`
// eslint-disable-next-line prettier/prettier
import type { Configuration } from "webpack";
import type {Configuration} from "webpack";
import path from "path";
import CopyPlugin from "copy-webpack-plugin";
import {CreateExamplesListPlugin} from "./webpack-create-examples-list";
Expand Down
4 changes: 1 addition & 3 deletions standalone-app/webpack/dev.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// `prettier` does not yet support `import type`
// eslint-disable-next-line prettier/prettier
import { merge } from 'webpack-merge';
import {merge} from "webpack-merge";
import commonConfig from "./common.config";

const devConfig = merge(commonConfig, {
Expand Down
4 changes: 1 addition & 3 deletions standalone-app/webpack/webpack-create-examples-list.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// `prettier` does not yet support `import type`
// eslint-disable-next-line prettier/prettier
import type webpack from 'webpack';
import type webpack from "webpack";
import fs from "fs/promises";
import path from "path";

Expand Down
Loading

0 comments on commit 117050b

Please sign in to comment.