Skip to content

Commit

Permalink
chore(deps): Update ESLint v8 to v9 (#1113)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicstone authored Nov 3, 2024
1 parent c184798 commit 8453c63
Show file tree
Hide file tree
Showing 51 changed files with 1,336 additions and 1,234 deletions.
69 changes: 0 additions & 69 deletions .eslintrc.json

This file was deleted.

File renamed without changes.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
2020 年に作成したポートフォリオサイトです。
~~2022 年には、ブログ機能を追加しました。~~ 2024 年に削除

現在 Next.js にリプレイス中です。

![PC・タブレット・スマホでポートフォリオサイトを表示した写真、マルチプラットフォームに対応したことを示す図](./docs/readme-images/portfolio.jpg)

- 本番環境 <https://bicstone.me>
Expand Down
113 changes: 113 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import love from "eslint-config-love";
import jsxA11y from "eslint-plugin-jsx-a11y";
import regexp from "eslint-plugin-regexp";
import react from "eslint-plugin-react";
import reactHooks from "eslint-plugin-react-hooks";

const files = ["**/*.js", "**/*.ts", "**/*.tsx"];

export default [
{
...love,
files,
},
{
...jsxA11y.flatConfigs.recommended,
files,
},
{
...jsxA11y.flatConfigs.strict,
files,
},
{
...regexp.configs["flat/recommended"],
files,
},
{
...react.configs.flat.recommended,
files,
},
{
...react.configs.flat["jsx-runtime"],
files,
},
{
languageOptions: {
parserOptions: {
project: "./tsconfig.json",
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
"react-hooks": reactHooks,
},
rules: {
...reactHooks.configs.recommended.rules,
// import order
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
"type",
],
alphabetize: {
order: "asc",
},
"newlines-between": "always",
},
],
"no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1, maxBOF: 0 }],
// prop-types is not used because use typescript
"react/prop-types": "off",
// unnecessary import react because use new JSX transform
// https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#eslint
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
// prefer import type / export type
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/consistent-type-exports": "error",
// Disabled for guarding in Typescript.
"react/no-unknown-property": "off",
// Feature should be imported from the index.ts file
"no-restricted-imports": [
"error",
{
patterns: ["@/features/*/*"],
},
],
// TODO: Remove this rule when the following issue is resolved.
"@typescript-eslint/no-unsafe-argument": "warn",
"@typescript-eslint/unbound-method": "warn",
// Tentatively changed from error to warn due to migration
"@typescript-eslint/no-magic-numbers": "off",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/only-throw-error": "warn",
"@typescript-eslint/prefer-destructuring": "warn",
},
settings: {
react: {
version: "detect",
},
},
files,
},
{
ignores: [
".cache/",
"pnpm-lock.yaml",
"public/",
"src/generated/",
"static/",
"content/",
],
},
];
10 changes: 3 additions & 7 deletions gatsby-browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,14 @@ import { isDefined } from "@/utils/typeguard";

export const wrapRootElement: GatsbyBrowser["wrapRootElement"] = ({
element,
}) => {
return <WrapRootElement>{element}</WrapRootElement>;
};
}) => <WrapRootElement>{element}</WrapRootElement>;

export const wrapPageElement: GatsbyBrowser["wrapPageElement"] = ({
element,
}) => {
return <WrapPageElement>{element}</WrapPageElement>;
};
}) => <WrapPageElement>{element}</WrapPageElement>;

export const onRouteUpdate: GatsbyBrowser["onRouteUpdate"] = ({ location }) => {
if (isDefined(location?.hash)) {
if (isDefined(location.hash)) {
const id = location.hash.replace("#", "");
const element = document.getElementById(id);
if (isDefined(element)) {
Expand Down
41 changes: 18 additions & 23 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,14 @@ const config: GatsbyConfig = {
query: { allTimeline },
}: {
query: GatsbyPluginFeedQuery;
}) => {
return allTimeline.nodes.map((node) => ({
guid: node.url ?? "",
}) =>
allTimeline.nodes.map((node) => ({
guid: node.url,
title: node.title,
url: node.url ?? "",
url: node.url,
description: "",
date: node.date,

Check warning on line 73 in gatsby-config.ts

View workflow job for this annotation

GitHub Actions / test

Unsafe assignment of an `any` value
}));
},
})),
query: /* GraphQL */ `
query GatsbyPluginFeed {
allTimeline(sort: { date: DESC }) {
Expand Down Expand Up @@ -157,25 +156,21 @@ const config: GatsbyConfig = {
lastmod: string;
changefreq: string;
priority: number;
}) => {
return {
url: path,
lastmod,
changefreq,
priority,
};
},
}) => ({
url: path,
lastmod,
changefreq,
priority,
}),
},
},
...contentPaths.map((contentPath) => {
return {
resolve: `gatsby-source-filesystem`,
options: {
path: path.resolve("content", contentPath),
name: contentPath,
},
};
}),
...contentPaths.map((contentPath) => ({
resolve: `gatsby-source-filesystem`,
options: {
path: path.resolve("content", contentPath),
name: contentPath,
},
})),
`gatsby-transformer-sharp`,
`gatsby-transformer-yaml`,
`gatsby-transformer-json`,
Expand Down
9 changes: 6 additions & 3 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ export const createPagesStatefully: GatsbyNode["createPagesStatefully"] =
}
`);

if (isDefined(result?.errors)) throw result.errors;
if (isDefined(result.errors)) throw result.errors;

const timelineList: Array<
Pick<Search, "title" | "slug" | "url" | "excerpt">
> = [];

result?.data?.timelineItems?.nodes.forEach((node) => {
result.data?.timelineItems.nodes.forEach((node) => {
timelineList.push({
title: node.title,
slug: "",
Expand All @@ -90,7 +90,7 @@ export const createPagesStatefully: GatsbyNode["createPagesStatefully"] =
});
});

result?.data?.qiitaItems?.nodes.forEach((node) => {
result.data?.qiitaItems.nodes.forEach((node) => {
timelineList.push({
title: node.title,
slug: "",
Expand Down Expand Up @@ -204,8 +204,11 @@ export const createSchemaCustomization: GatsbyNode["createSchemaCustomization"]
export const onCreateNode: GatsbyNode["onCreateNode"] = ({ node, actions }) => {
const { createNodeField } = actions;
const date =
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- date is nullable
node?.date ?? (node?.frontmatter as Record<string, unknown>)?.date;

const endDate =
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- endDate is nullable
node?.endDate ?? (node?.frontmatter as Record<string, unknown>)?.endDate;

if (typeof date === "string" || date instanceof Date) {
Expand Down
22 changes: 11 additions & 11 deletions gatsby-ssr.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInitColorSchemeScript } from "@mui/material/styles/CssVarsProvider";
import InitColorSchemeScript from "@mui/material/InitColorSchemeScript";
import { Fragment } from "react";

import { SITE_METADATA } from "./src/constants/SITE_METADATA";
Expand All @@ -16,18 +16,18 @@ export const onRenderBody: GatsbySSR["onRenderBody"] = ({

setPreBodyComponents([
<Fragment key="init-color-scheme-script">
{getInitColorSchemeScript({
defaultMode: "light",
modeStorageKey: "mui-mode-disabled",
})}
<InitColorSchemeScript
defaultMode="light"
modeStorageKey="mui-mode-disabled"
/>
</Fragment>,
]);
};

export const wrapRootElement: GatsbySSR["wrapRootElement"] = ({ element }) => {
return <WrapRootElement>{element}</WrapRootElement>;
};
export const wrapRootElement: GatsbySSR["wrapRootElement"] = ({ element }) => (
<WrapRootElement>{element}</WrapRootElement>
);

export const wrapPageElement: GatsbySSR["wrapPageElement"] = ({ element }) => {
return <WrapPageElement>{element}</WrapPageElement>;
};
export const wrapPageElement: GatsbySSR["wrapPageElement"] = ({ element }) => (
<WrapPageElement>{element}</WrapPageElement>
);
30 changes: 14 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"develop": "gatsby develop --port 10014",
"serve": "gatsby serve --port 20014",
"clean": "gatsby clean",
"lint": "eslint --cache --ignore-path .eslintignore --ext .js,.ts,.tsx .",
"lint": "eslint --cache",
"lint:fix": "pnpm run lint --fix",
"format": "prettier --cache --ignore-path .eslintignore --write .",
"format": "prettier --cache --write .",
"graphql": "graphql-codegen",
"typecheck": "tsc -p . --noEmit",
"deploy": "gatsby-plugin-s3 deploy",
Expand Down Expand Up @@ -52,27 +52,25 @@
"react-virtuoso": "4.12.0"
},
"devDependencies": {
"@graphql-codegen/cli": "5.0.3",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.14.0",
"@graphql-codegen/cli": "5.0.2",
"@graphql-codegen/introspection": "4.0.3",
"@graphql-codegen/typescript": "4.1.0",
"@graphql-codegen/typescript-operations": "4.3.0",
"@graphql-codegen/typescript": "4.0.9",
"@graphql-codegen/typescript-operations": "4.2.3",
"@types/eslint": "9.6.1",
"@types/js-yaml": "4.0.9",
"@types/node": "20.17.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"@types/node": "20.16.9",
"@types/react": "18.3.9",
"@types/react-dom": "18.3.0",
"dotenv": "16.4.5",
"eslint": "8.57.1",
"eslint-config-love": "43.1.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.31.0",
"eslint": "9.14.0",
"eslint-config-love": "97.0.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-n": "17.11.1",
"eslint-plugin-promise": "7.1.0",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-regexp": "2.6.0",
"globals": "15.10.0",
"husky": "9.1.6",
"prettier": "3.3.3",
"typescript": "5.6.3"
Expand Down
Loading

0 comments on commit 8453c63

Please sign in to comment.