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

feat: upgrade ESLint v9 #111

Open
wants to merge 2 commits into
base: test
Choose a base branch
from
Open
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
49 changes: 0 additions & 49 deletions .eslintrc.json

This file was deleted.

103 changes: 103 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// @ts-check
import unusedImports from 'eslint-plugin-unused-imports';
import pluginNext from '@next/eslint-plugin-next';
import headers from 'eslint-plugin-headers';
import globals from 'globals';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import gitignore from 'eslint-config-flat-gitignore';

export default [
gitignore(),
{
name: 'eslint/javascript/rules',
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
document: 'readonly',
navigator: 'readonly',
window: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2022,
sourceType: 'module',
},
sourceType: 'module',
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
plugins: {
'unused-imports': unusedImports,
},
rules: {
'unused-imports/no-unused-imports': 'warn',
'unused-imports/no-unused-vars': [
'error',
{
args: 'after-used',
argsIgnorePattern: '^_',
vars: 'all',
varsIgnorePattern: '^_',
},
],
},
},
{
name: 'eslint/react/rules',
files: ['src/**/*.{js,jsx,ts,tsx}'],
settings: {
react: {
version: 'detect',
},
},
languageOptions: {
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
react: pluginReact,
'react-hooks': pluginReactHooks,
'@next/next': pluginNext,
},
rules: {
...pluginReact.configs.recommended.rules,
...pluginReactHooks.configs.recommended.rules,

'react/display-name': 'off',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',

...pluginNext.configs.recommended.rules,
...pluginNext.configs['core-web-vitals'].rules,
},
},
{
name: 'eslint/headers/rules',
files: ['src/**/*.{js,jsx,ts,tsx}'],
plugins: {
headers,
},
rules: {
'headers/header-format': [
'error',
{
source: 'string',
content:
'Copyright 2024 OpenBuild\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.',
trailingNewlines: 2,
},
],
},
},
];
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
"license": "node .knosys/scripts license add",
"doc": "node .knosys/scripts site",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
"lint": "eslint .",
"prepare": "husky"
},
"dependencies": {
Expand Down Expand Up @@ -63,8 +63,6 @@
"daisyui": "^4.4.23",
"dayjs": "^1.11.7",
"easymde": "^2.18.0",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-unused-imports": "^3.0.0",
"ethers": "^6.9.0",
"file-saver": "^2.0.5",
"framer-motion": "^10.16.4",
Expand Down Expand Up @@ -122,7 +120,10 @@
"@astrojs/tailwind": "5.1.2",
"@commitlint/cli": "19.6.1",
"@commitlint/config-conventional": "19.6.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.19.0",
"@knosys/sdk": "^0.0.3",
"@next/eslint-plugin-next": "^15.1.6",
"@tailwindcss/line-clamp": "0.4.4",
"@types/node": "18.11.3",
"@types/qs": "^6.9.15",
Expand All @@ -131,10 +132,15 @@
"@types/sha256": "^0.2.0",
"astro": "4.16.7",
"autoprefixer": "^10.4.12",
"eslint": "^8.7.0",
"eslint": "^9.19.0",
"eslint-config-flat-gitignore": "^1.0.0",
"eslint-config-next": "^13.1.1",
"eslint-plugin-headers": "1.2.1",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-tailwindcss": "3.15.1",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.14.0",
"husky": "9.1.7",
"ksio": "^0.0.3",
"lint-staged": "15.3.0",
Expand Down
2 changes: 1 addition & 1 deletion src/app/(uc)/signin/VerifyCodeLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function VerifyCodeLogin({ register, loginType, email }) {
} else {
toast.error(res.message);
}
} catch (error) {
} catch {
toast.error('Failed to send code.');
} finally {
setSendLoading(false);
Expand Down
2 changes: 1 addition & 1 deletion src/app/(uc)/signin/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default function Login() {
} else {
toast.error(response.message);
}
} catch (error) {
} catch {
toast.error('Sign in failed. Please try again.');
} finally {
setLoading(false);
Expand Down
2 changes: 1 addition & 1 deletion src/app/bounties/Tips.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useBoundWallet } from '@/hooks/useBoundWallet';
function TipsContainer({children}) {
return <div className="h-12 bg-[#E6E6E6] px-6 flex items-center fixed w-full z-[20] top-[72px]">
<svg className="mr-2" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
<path d="M9.99996 18.3334C12.3011 18.3334 14.3845 17.4007 15.8925 15.8926C17.4005 14.3846 18.3333 12.3012 18.3333 10.0001C18.3333 7.69891 17.4005 5.61558 15.8925 4.10752C14.3845 2.59949 12.3011 1.66675 9.99996 1.66675C7.69879 1.66675 5.61546 2.59949 4.1074 4.10752C2.59937 5.61558 1.66663 7.69891 1.66663 10.0001C1.66663 12.3012 2.59937 14.3846 4.1074 15.8926C5.61546 17.4007 7.69879 18.3334 9.99996 18.3334Z" stroke="#1A1A1A" stroke-linejoin="round"/>
<path d="M9.99996 18.3334C12.3011 18.3334 14.3845 17.4007 15.8925 15.8926C17.4005 14.3846 18.3333 12.3012 18.3333 10.0001C18.3333 7.69891 17.4005 5.61558 15.8925 4.10752C14.3845 2.59949 12.3011 1.66675 9.99996 1.66675C7.69879 1.66675 5.61546 2.59949 4.1074 4.10752C2.59937 5.61558 1.66663 7.69891 1.66663 10.0001C1.66663 12.3012 2.59937 14.3846 4.1074 15.8926C5.61546 17.4007 7.69879 18.3334 9.99996 18.3334Z" stroke="#1A1A1A" strokeLinejoin="round"/>
<path fillRule="evenodd" clipRule="evenodd" d="M9.99996 14.9999C10.4602 14.9999 10.8333 14.6268 10.8333 14.1666C10.8333 13.7064 10.4602 13.3333 9.99996 13.3333C9.53973 13.3333 9.16663 13.7064 9.16663 14.1666C9.16663 14.6268 9.53973 14.9999 9.99996 14.9999Z" fill="#333333"/>
<path d="M10 5V11.6667" stroke="#1A1A1A" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
Expand Down
2 changes: 1 addition & 1 deletion src/app/bounties/[id]/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function applyAction(id, comment) {
} else {
return res;
}
} catch (e) {
} catch {
return { message: 'Failed to request' };
}
}
1 change: 0 additions & 1 deletion src/app/learn/[type]/[id]/[chapter_id]/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

/* eslint-disable jsx-a11y/anchor-is-valid */
'use client';

import { useEffect, useState } from 'react';
Expand Down
4 changes: 2 additions & 2 deletions src/app/learn/[type]/[id]/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function enrollAction(id) {
} else {
return res;
}
} catch (e) {
} catch {
return { message: 'Failed to request' };
}
}
Expand All @@ -45,7 +45,7 @@ export async function growPathEnrollAction(id) {
} else {
return res;
}
} catch (e) {
} catch {
return { message: 'Failed to request' };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ function AnswerRecordDrawer({ questions = [], result, submitting, onSubmit, onCh
</label>
</div>
<div className="drawer-side">
<label htmlFor="my-drawer-4" ariaLabel="close sidebar" className="drawer-overlay" />
<label htmlFor="my-drawer-4" aria-label="close sidebar" className="drawer-overlay" />
<div className="p-6 w-full md:w-96 min-h-full bg-white text-base-content flex flex-col justify-between">
<div>
<div className="flex justify-between">
<div className="flex items-center">
<AnswerIcon className="mr-2" />
Answer record
</div>
<label htmlFor="my-drawer-4" ariaLabel="close sidebar">
<label htmlFor="my-drawer-4" aria-label="close sidebar">
<ModalCloseIcon className="md:hidden cursor-pointer" />
</label>
</div>
Expand Down Expand Up @@ -114,8 +114,8 @@ function ModalCloseIcon(props = {}) {
return (
<svg {...props} width="36" height="36" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g opacity="0.6">
<path d="M14 14L22 22" stroke="#1A1A1A" stroke-linecap="round" strokeLinejoin="round"/>
<path d="M14 22L22 14" stroke="#1A1A1A" stroke-linecap="round" strokeLinejoin="round"/>
<path d="M14 14L22 22" stroke="#1A1A1A" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M14 22L22 14" stroke="#1A1A1A" strokeLinecap="round" strokeLinejoin="round"/>
</g>
<path d="M35.5 12C35.5 5.64873 30.3513 0.5 24 0.5H12C5.64872 0.5 0.5 5.64873 0.5 12V24C0.5 30.3513 5.64873 35.5 12 35.5H24C30.3513 35.5 35.5 30.3513 35.5 24V12Z" stroke="#F1F1F1"/>
</svg>
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/Icons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="2580"

Check failure on line 129 in src/shared/components/Icons/index.js

View workflow job for this annotation

GitHub Actions / lint

Unknown property 'p-id' found
width="16"
height="16"
>
<path
d="M512 167.04C71.706 167.04 64 206.195 64 512s7.706 344.96 448 344.96S960 817.805 960 512s-7.706-344.96-448-344.96z m143.584 359.923l-201.152 93.901c-17.606 8.154-32.032-0.986-32.032-20.429v-176.87c0-19.398 14.426-28.582 32.032-20.429l201.152 93.901c17.606 8.243 17.606 21.683 0 29.926z"
fill="currentColor"
p-id="2581"

Check failure on line 136 in src/shared/components/Icons/index.js

View workflow job for this annotation

GitHub Actions / lint

Unknown property 'p-id' found
/>
</svg>
);
Expand Down Expand Up @@ -1757,8 +1757,8 @@
return (
<svg {...props} width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fillRule="evenodd" clipRule="evenodd" d="M12 14.5L6 8.49999H9.99995V3H14V8.49999H18L12 14.5Z" stroke="#1A1A1A" strokeLinecap="round" strokeLinejoin="round"/>
<path d="M21 18.5H3" stroke="#1A1A1A" stroke-linecap="round"/>
<path d="M17 22H7" stroke="#1A1A1A" stroke-linecap="round"/>
<path d="M21 18.5H3" stroke="#1A1A1A" strokeLinecap="round"/>
<path d="M17 22H7" stroke="#1A1A1A" strokeLinecap="round"/>
</svg>

);
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/block-editor/bubble/LinkSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function isValidUrl(url) {
try {
new URL(url);
return true;
} catch (_e) {
} catch {
return false;
}
}
Expand All @@ -36,7 +36,7 @@ export function getUrlFromString(str) {
if (str.includes('.') && !str.includes(' ')) {
return new URL(`https://${str}`).toString();
}
} catch (_e) {
} catch {
return null;
}
}
Expand Down
Loading