Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: typescript eslint + up eslint #904

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const path = require("path");

const buildNextEslintCommand = (filenames) =>
`yarn next:lint --fix --file ${filenames
`yarn next:lint --fix ${filenames
.map((f) => path.relative(path.join("packages", "nextjs"), f))
.join(" --file ")}`;
.join(" ")}`;

const checkTypesNextCommand = () => "yarn next:check-types";

Expand Down
11 changes: 0 additions & 11 deletions packages/nextjs/.eslintignore

This file was deleted.

15 changes: 0 additions & 15 deletions packages/nextjs/.eslintrc.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const isJsonString = (str: string) => {
JSON.parse(str);
return true;
} catch (e) {
console.log(e);
return false;
}
};
Expand All @@ -24,6 +25,7 @@ const isBigInt = (str: string) => {
BigInt(str);
return true;
} catch (e) {
console.log(e);
return false;
}
};
Expand Down
4 changes: 3 additions & 1 deletion packages/nextjs/components/scaffold-eth/Input/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export const isValidInteger = (dataType: IntegerVariant, value: bigint | string,
let valueAsBigInt;
try {
valueAsBigInt = BigInt(value);
} catch (e) {}
} catch (e) {
console.log(e);
}
if (typeof valueAsBigInt !== "bigint") {
if (strict) {
return false;
Expand Down
71 changes: 71 additions & 0 deletions packages/nextjs/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// @ts-check
import { fixupPluginRules } from "@eslint/compat";
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import prettierConfigRecommended from "eslint-plugin-prettier/recommended";
import path from "node:path";
import { fileURLToPath } from "node:url";
import ts from "typescript-eslint";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

const pluginsToPatch = ["@next/next", "react-hooks"];

const compatConfig = [...compat.extends("next/core-web-vitals")];

const patchedConfig = compatConfig.map(entry => {
const plugins = entry.plugins;
for (const key in plugins) {
if (plugins.hasOwnProperty(key) && pluginsToPatch.includes(key)) {
plugins[key] = fixupPluginRules(plugins[key]);
}
}
return entry;
});

const config = [
...patchedConfig,
...ts.configs.recommended,
{
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ["*.js", "*.mjs"],
},
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "error",
},
},

prettierConfigRecommended, // Last since it disables some previously set rules
{
ignores: [
".next/*",
"out/*",
"node_modules/*",
"**/*.less",
"**/*.css",
"**/*.scss",
"**/*.json",
"**/*.png",
"**/*.svg",
"**/generated/**/*",
],
},
];

export default config;
2 changes: 1 addition & 1 deletion packages/nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const nextConfig = {
ignoreBuildErrors: process.env.NEXT_PUBLIC_IGNORE_BUILD_ERROR === "true",
},
eslint: {
ignoreDuringBuilds: process.env.NEXT_PUBLIC_IGNORE_BUILD_ERROR === "true",
ignoreDuringBuilds: true,
},
webpack: config => {
config.resolve.fallback = { fs: false, net: false, tls: false };
Expand Down
26 changes: 18 additions & 8 deletions packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"scripts": {
"dev": "next dev",
"start": "next dev",
"build": "next build",
"build": "yarn lint && next build",
"serve": "next start",
"lint": "next lint",
"lint": "eslint .",
Comment on lines +8 to +10
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically instead of running next lint we are now doing our own lint, since next lint it broken right with v9?

Not sure if this is gonna affect us vercel/next.js#64409 (comment) or any user future of SE-2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, see also vercel/next.js#64409 (comment). We can wait for next answers though

"format": "prettier --write . '!(node_modules|.next|contracts)/**/*'",
"check-types": "tsc --noEmit --incremental",
"vercel": "vercel",
Expand Down Expand Up @@ -37,23 +37,33 @@
"zustand": "^4.1.2"
},
"devDependencies": {
"@eslint/compat": "^1.1.1",
"@eslint/js": "^9.8.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/node": "^17.0.35",
"@types/eslint": "^9",
"@types/eslint__eslintrc": "^2.1.2",
"@types/eslint__js": "^8.42.3",
"@types/node": "^18",
"@types/nprogress": "^0",
"@types/react": "^18.0.9",
"@types/react-copy-to-clipboard": "^5.0.4",
"@typescript-eslint/eslint-plugin": "^5.39.0",
"@typescript-eslint/eslint-plugin": "^8.0.1",
"abitype": "1.0.5",
"autoprefixer": "^10.4.12",
"eslint": "^8.15.0",
"eslint-config-next": "^14.0.4",
"eslint": "^9.8.0",
"eslint-config-next": "^14.2.5",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react-hooks": "^4.6.2",
"postcss": "^8.4.16",
"prettier": "^3.3.2",
"prettier": "^3.3.3",
"tailwindcss": "^3.4.3",
"type-fest": "^4.6.0",
"typescript": "5.5.3",
"typescript-eslint": "^8.0.1",
"vercel": "^32.4.1"
},
"overrides": {
"eslint": "^9.8.0"
}
}
1 change: 1 addition & 0 deletions packages/nextjs/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./app/**/*.{js,ts,jsx,tsx}", "./components/**/*.{js,ts,jsx,tsx}", "./utils/**/*.{js,ts,jsx,tsx}"],
// eslint-disable-next-line @typescript-eslint/no-require-imports
plugins: [require("daisyui")],
darkTheme: "dark",
darkMode: ["selector", "[data-theme='dark']"],
Expand Down
Loading
Loading