Skip to content

Add eslint #25

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

Merged
merged 2 commits into from
Jul 12, 2023
Merged
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
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
tmp
91 changes: 91 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
module.exports = {
env: {
browser: true,
es2020: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "react"],
rules: {
// See https://github.com/emotion-js/emotion/issues/2878
"react/no-unknown-property": ["error", { ignore: ["css"] }],
},
settings: {
react: {
version: "detect",
},
},

// TODO
overrides: [
{
rules: {
"@typescript-eslint/no-unused-vars": "off",
},
files: [
"src/client/components/Article.tsx",
"src/client/components/SidebarContents.tsx",
"src/client/templates/Sidebar.tsx",
"src/commands/login.ts",
"src/commands/preview.ts",
"src/commands/publish.ts",
"src/commands/pull.ts",
"src/lib/file-system-repo.test.ts",
"src/lib/file-system-repo.ts",
"src/server/api/items.ts",
"src/server/api/readme.ts",
"src/server/app.ts",
"src/server/lib/get-current-user.ts",
],
},
{
rules: {
"react-hooks/exhaustive-deps": "off",
},
files: [
"src/client/components/HotReloadRoot.tsx",
"src/client/components/SidebarArticles.tsx",
"src/client/components/Snackbar.tsx",
"src/client/components/Tooltip.tsx",
],
},
{
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
files: [
"src/client/lib/embed-init-scripts.ts",
"src/lib/config.test.ts",
"src/lib/config.ts",
"src/lib/file-system-repo.test.ts",
"src/lib/file-system-repo.ts",
"src/server/api/readme.ts",
],
},
{
rules: {
"@typescript-eslint/ban-types": "off",
},
files: ["src/client/lib/entries.ts"],
},
{
rules: {
"no-prototype-builtins": "off",
},
files: ["src/commands/index.ts"],
},
{
rules: {
"@typescript-eslint/no-var-requires": "off",
},
files: ["src/lib/package-settings.ts"],
},
],
};
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
"@types/react-dom": "^18.0.11",
"@types/webpack": "^5.28.0",
"@types/ws": "^8.5.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"classnames": "^2.3.2",
"eslint": "^8.44.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"html-webpack-plugin": "^5.5.0",
"husky": "^8.0.3",
"jest": "^29.4.3",
Expand All @@ -54,9 +59,10 @@
"dev:client": "webpack --watch",
"dev:server": "tsc --build --watch",
"dev": "run-p dev:*",
"format": "prettier --write .",
"format": "eslint --fix . && prettier --write .",
"lint": "run-p lint:*",
"lint:format": "prettier --check .",
"lint:prettier": "prettier --check .",
"lint:eslint": "eslint .",
"lint:typecheck": "tsc --noEmit",
"prepare": "husky install",
"qiita": "node dist/main.js",
Expand Down
28 changes: 14 additions & 14 deletions src/client/components/SidebarContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterTitleStyle}
href="https://qiita.com"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<QiitaLogo css={{ height: 16 }} />
</a>
Expand All @@ -188,7 +188,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articlesListItemStyle}
href="https://help.qiita.com/ja/articles/qiita-article-guideline"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<MaterialSymbol css={{ color: Colors.disabled }}>
lightbulb
Expand All @@ -201,7 +201,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articlesListItemStyle}
href="https://qiita.com/Qiita/items/c686397e4a0f4f11683d"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<MaterialSymbol css={{ color: Colors.disabled }}>
help
Expand All @@ -216,7 +216,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterListItemStyle}
href="https://help.qiita.com/ja/articles/qiita-community-guideline"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
コミュニティガイドライン
</a>
Expand All @@ -226,7 +226,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterListItemStyle}
href="https://qiita.com/terms"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
利用規約
</a>
Expand All @@ -236,7 +236,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterListItemStyle}
href="https://qiita.com/privacy"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
プライバシーポリシー
</a>
Expand Down Expand Up @@ -346,7 +346,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterTitleStyle}
href="https://qiita.com"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<QiitaLogo css={{ height: 16 }} />
</a>
Expand All @@ -364,7 +364,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articlesListItemStyle}
href="https://help.qiita.com/ja/articles/qiita-article-guideline"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<MaterialSymbol css={{ color: Colors.disabled }}>
lightbulb
Expand All @@ -377,7 +377,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articlesListItemStyle}
href="https://qiita.com/Qiita/items/c686397e4a0f4f11683d"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<MaterialSymbol css={{ color: Colors.disabled }}>
help
Expand All @@ -392,7 +392,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterListItemStyle}
href="https://help.qiita.com/ja/articles/qiita-community-guideline"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
コミュニティガイドライン
</a>
Expand All @@ -402,7 +402,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterListItemStyle}
href="https://qiita.com/terms"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
利用規約
</a>
Expand All @@ -412,7 +412,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={articleFooterListItemStyle}
href="https://qiita.com/privacy"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
プライバシーポリシー
</a>
Expand Down Expand Up @@ -503,7 +503,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={closeSidebarFooterLinkStyle}
href="https://help.qiita.com/ja/articles/qiita-article-guideline"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<MaterialSymbol>lightbulb</MaterialSymbol>
</a>
Expand All @@ -521,7 +521,7 @@ export const SidebarContents = ({ isStateOpen, handleMobileClose }: Props) => {
css={closeSidebarFooterLinkStyle}
href="https://qiita.com/Qiita/items/c686397e4a0f4f11683d"
target="_blank"
rel="noopener"
rel="noopener noreferrer"
>
<MaterialSymbol>help</MaterialSymbol>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/server/api/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const itemsUpdate = async (req: Express.Request, res: Express.Response) => {
}

const qiitaApi = await getQiitaApiInstance();
let output: { [key: string]: string | boolean } = {
const output: { [key: string]: string | boolean } = {
success: true,
uuid: result.id || "",
};
Expand Down
1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");

Expand Down
Loading