Skip to content

Commit

Permalink
style: adopt ESM and ESLint Flat Config
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Cao <70191398+ryanccn@users.noreply.github.com>
  • Loading branch information
ryanccn committed Feb 13, 2024
1 parent ff007e7 commit 3dbb7fe
Show file tree
Hide file tree
Showing 36 changed files with 664 additions and 415 deletions.
18 changes: 0 additions & 18 deletions .eslintrc

This file was deleted.

46 changes: 46 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import js from "@eslint/js";
import ts from "typescript-eslint";
import unicorn from "eslint-plugin-unicorn";

import globals from "globals";

import { FlatCompat } from "@eslint/eslintrc";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({ baseDirectory: __dirname });

export default ts.config(
js.configs.recommended,
...ts.configs.recommendedTypeChecked,
unicorn.configs["flat/recommended"],
...compat.extends("plugin:@next/next/recommended"),

{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.browser,
...globals.node,
},
},
},

{
rules: {
"unicorn/prevent-abbreviations": "off",
"unicorn/no-null": "off",
"unicorn/filename-case": "off",
"unicorn/no-nested-ternary": "off",
},
},

{
files: ["**/*.js"],
...ts.configs.disableTypeChecked,
},
);
7 changes: 4 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable unicorn/prefer-module */
/* eslint-disable @typescript-eslint/no-var-requires */

const { withPlausibleProxy } = require("next-plausible");
import { withPlausibleProxy } from "next-plausible";
import makeBundleAnalyzer from "@next/bundle-analyzer";

const withBundleAnalyzer = require("@next/bundle-analyzer")({
const withBundleAnalyzer = makeBundleAnalyzer({
enabled: process.env.ANALYZE === "true",
openAnalyzer: false,
});
Expand Down Expand Up @@ -118,4 +119,4 @@ const nextConfig = withPlausibleProxy()(
}),
);

module.exports = nextConfig;
export default nextConfig;
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"name": "moddermore",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"lint": "eslint .",
"format": "prettier --write .",
"utils:minecraftVersions": "node scripts/updateVersions.mjs"
"utils:minecraftVersions": "node scripts/updateVersions.js"
},
"dependencies": {
"@iarna/toml": "^2.2.5",
Expand Down Expand Up @@ -37,24 +38,26 @@
"valibot": "^0.28.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3.0.1",
"@eslint/js": "^8.56.0",
"@headlessui/tailwindcss": "^0.2.0",
"@microsoft/eslint-formatter-sarif": "^3.0.0",
"@next/bundle-analyzer": "^14.1.0",
"@next/eslint-plugin-next": "^14.1.0",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.10",
"@types/file-saver": "^2.0.7",
"@types/node": "20.11.17",
"@types/react": "18.2.55",
"@types/react-dom": "18.2.19",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@upstash/ratelimit": "^1.0.1",
"@vercel/kv": "^1.0.1",
"autoprefixer": "^10.4.17",
"discord-api-types": "^0.37.69",
"eslint": "^8.56.0",
"eslint-config-next": "14.1.0",
"eslint-plugin-unicorn": "^51.0.1",
"globals": "^14.0.0",
"gray-matter": "^4.0.3",
"image-size": "^1.1.1",
"kleur": "^4.1.5",
Expand All @@ -72,6 +75,7 @@
"tailwindcss": "^3.4.1",
"tsx": "^4.7.1",
"typescript": "^5.3.3",
"typescript-eslint": "^7.0.1",
"unified": "^11.0.4"
},
"pnpm": {
Expand Down
75 changes: 69 additions & 6 deletions pnpm-lock.yaml

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

File renamed without changes.
2 changes: 0 additions & 2 deletions scripts/updateVersions.mjs → scripts/updateVersions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import fetch from "node-fetch";

import { writeFile } from "node:fs/promises";
import { format } from "prettier";

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/FullLoadingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const FullLoadingScreen = ({ title, label }: { title?: string; label?: st
)}
<div className="flex flex-col items-center gap-y-6">
<Spinner className="mb-4 block h-8 w-8 stroke-indigo-500 dark:stroke-indigo-400" />
<span className={!label ? "sr-only" : "text-neutral-700 dark:text-neutral-300"}>
<span className={label ? "text-neutral-700 dark:text-neutral-300" : "sr-only"}>
{label ?? "Fetching data"}
</span>
</div>
Expand Down
56 changes: 28 additions & 28 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,7 @@ const Header = () => {
</div>
</div>

{status !== "loading" ? (
data ? (
<div className="flex flex-row items-center gap-x-4">
<Link href="/new" className={buttonVariants()}>
<PlusIcon className="block h-5 w-5" />
<span>Create</span>
</Link>
<Link href="/lists" className="p-1">
<img
src={data.extraProfile.profilePicture ?? undefined}
width={32}
height={32}
alt="Lists"
className="rounded-full bg-neutral-100 dark:bg-neutral-800"
/>
</Link>
</div>
) : (
<Button
onClick={() => {
nextAuthSignIn();
}}
>
<UserIcon className="block h-5 w-5" />
<span>Sign in</span>
</Button>
)
) : (
{status === "loading" ? (
<div
className={twMerge(
buttonVariants({
Expand All @@ -108,6 +81,33 @@ const Header = () => {
>
&nbsp;
</div>
) : data ? (
<div className="flex flex-row items-center gap-x-4">
<Link href="/new" className={buttonVariants()}>
<PlusIcon className="block h-5 w-5" />
<span>Create</span>
</Link>
<Link href="/lists" className="p-1">
<img
src={data.extraProfile.profilePicture ?? undefined}
width={32}
height={32}
alt="Lists"
className="rounded-full bg-neutral-100 dark:bg-neutral-800"
/>
</Link>
</div>
) : (
<Button
onClick={() => {
nextAuthSignIn().catch((error) => {
console.error(error);
});
}}
>
<UserIcon className="block h-5 w-5" />
<span>Sign in</span>
</Button>
)}
</nav>
);
Expand Down
Loading

0 comments on commit 3dbb7fe

Please sign in to comment.