Skip to content

Commit

Permalink
chore(ESLint): Migrate to flatConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
philipbrembeck committed Oct 27, 2024
1 parent 45ba41c commit fd7b693
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 48 deletions.
45 changes: 0 additions & 45 deletions .eslintrc.json

This file was deleted.

4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
}
],
"eslint.options": {
"overrideConfigFile": ".eslintrc.json"
"overrideConfigFile": "eslint.config.mjs"
},
"eslint.useFlatConfig": true,
"eslint.enable": true,
"typescript.tsdk": "node_modules/typescript",
"typescript.enablePromptUseWorkspaceTsdk": true
}
60 changes: 60 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import nextPlugin from "@next/eslint-plugin-next";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import importPlugin from "eslint-plugin-import";
import reactCompiler from 'eslint-plugin-react-compiler'

export default [
{
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
parser: tsParser,
parserOptions: {
project: "./tsconfig.json"
}
},
plugins: {
"@typescript-eslint": tsPlugin,
"import": importPlugin,
"@next/next": nextPlugin,
'react-compiler': reactCompiler,
},
files: ["**/*.{js,jsx,ts,tsx}"],
settings: {
"import/resolver": {
"typescript": {
"project": "./tsconfig.json"
},
"node": true
}
},
rules: {
...nextPlugin.configs["core-web-vitals"].rules,
...nextPlugin.configs["recommended"].rules,
...tsPlugin.configs["strict"].rules,
...tsPlugin.configs["stylistic"].rules,
...importPlugin.configs["recommended"].rules,
...importPlugin.configs["typescript"].rules,
'react-compiler/react-compiler': 'warn',
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
}
}
];
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"eslint-config-sznm": "^2.0.3",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react-compiler": "19.0.0-beta-8a03594-20241020",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"ts-node": "^10.9.2"
Expand Down
61 changes: 61 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/components/Scanner/ViewportScanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export function ViewportScanner({ onDetected, setScanning }: ScannerProps) {
Quagga.offDetected(onDetected);
Quagga.stop();
};
// Disabled here, as we only want to run this once
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

if (isHidden) return null;
Expand Down
2 changes: 2 additions & 0 deletions src/components/elements/modalwrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable react-compiler/react-compiler */
"use client";

import React, {
Expand Down Expand Up @@ -82,6 +83,7 @@ const ModalWrapper = ({

return (
<>
z
<ButtonComponent
data-target={id}
data-toggle="modal"
Expand Down
1 change: 1 addition & 0 deletions src/components/elements/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const ShareButton = ({
const url = `https://veganify.app/?ean=${barcode}`;

const handleShareClick = (shareUrl: string) => {
// eslint-disable-next-line react-compiler/react-compiler
window.location.href = shareUrl;
document.querySelector<HTMLElement>(".btn-dark")?.click();
};
Expand Down

0 comments on commit fd7b693

Please sign in to comment.