Skip to content

Commit

Permalink
New eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
chimpdev committed Oct 22, 2024
1 parent 2743a6a commit 14e6810
Show file tree
Hide file tree
Showing 452 changed files with 3,927 additions and 3,295 deletions.
129 changes: 117 additions & 12 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,29 @@ module.exports = {
node: true,
browser: true
},
extends: ['eslint:recommended', 'plugin:react/recommended', 'plugin:react/jsx-runtime', 'next'],
plugins: ['react'],
overrides: [
{
files: ['*.{js,jsx}'],
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
}
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'next',
'plugin:depend/recommended',
'plugin:tailwindcss/recommended'
],
plugins: ['react'],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'react/prop-types': 'off',
'react/self-closing-comp': [
'error',
{
component: true,
html: false
}
],
'react/jsx-indent-props': ['error', 2],
indent: [
'error',
2,
Expand All @@ -40,6 +45,106 @@ module.exports = {
'comma-dangle': [
'error',
'never'
],
'no-trailing-spaces': 'error',
'no-multiple-empty-lines': [
'error',
{ max: 1 }
],
'arrow-spacing': [
'error',
{
before: true,
after: true
}
],
'object-curly-spacing': [
'error',
'always'
],
'key-spacing': [
'error',
{
beforeColon: false,
afterColon: true
}
],
'space-in-parens': [
'error',
'never'
],
'brace-style': [
'error',
'1tbs',
{ allowSingleLine: true }
],
'no-empty-function': 'error',
'no-lonely-if': 'error',
'no-useless-return': 'error',
'spaced-comment': [
'error',
'always',
{ markers: ['/'] }
],
'func-call-spacing': [
'error',
'never'
],
'template-curly-spacing': [
'error',
'never'
],
'default-param-last': 'error',
'newline-before-return': 'error',
'no-duplicate-imports': [
'error',
{ includeExports: true }
],
'prefer-template': 'error',
'prefer-arrow-callback': 'error',
'arrow-parens': [
'error',
'as-needed'
],
'no-return-assign': 'error',
'object-shorthand': 'error',
'func-style': [
'error',
'declaration',
{ allowArrowFunctions: true }
],
'array-bracket-spacing': ['error', 'never'],
'space-infix-ops': 'error',
'keyword-spacing': [
'error',
{ before: true, after: true }
],
'no-unneeded-ternary': 'error',
'no-multi-spaces': 'error',
'depend/ban-dependencies': [
2,
{
allowed: [
'moment',
'lodash'
]
}
]
}
},
overrides: [
{
files: ['*.{js,jsx}'],
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
},
{
'files': ['*.jsx'],
'rules': {
'no-duplicate-imports': 'off'
}
}
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function BlockItem({ id, name, icon, href, onClick, badge, disabl
const activeTab = useAccountStore(state => state.activeTab);
const setActiveTab = useAccountStore(state => state.setActiveTab);
const loading = useAccountStore(state => state.loading);

const IconComponent = icon;
const ContainerComponent = href ? Link : onClick ? 'button' : 'div';
const TooltipContainer = isCollapsed ? Tooltip : 'div';
Expand All @@ -21,7 +21,7 @@ export default function BlockItem({ id, name, icon, href, onClick, badge, disabl

if (id.startsWith('divider-')) {
return (
<div className='w-full h-px my-2 bg-quaternary' />
<div className='my-2 h-px w-full bg-quaternary' />
);
}

Expand All @@ -45,7 +45,7 @@ export default function BlockItem({ id, name, icon, href, onClick, badge, disabl
href={href}
target='_blank'
>
<IconComponent className='w-4 h-4' />
<IconComponent className='size-4' />

<span
className={cn(
Expand All @@ -57,17 +57,17 @@ export default function BlockItem({ id, name, icon, href, onClick, badge, disabl
</span>

{!isCollapsed && href ? (
<MdOpenInNew className='w-4 h-4 ml-auto mr-4 text-tertiary' />
<MdOpenInNew className='ml-auto mr-4 size-4 text-tertiary' />
) : ''}

{visited && !isCollapsed && badge ? (
<span className='text-white ml-auto mr-4 px-2 py-0.5 text-xs font-bold bg-purple-600 rounded-full'>
<span className='ml-auto mr-4 rounded-full bg-purple-600 px-2 py-0.5 text-xs font-bold text-white'>
{badge}
</span>
) : ''}

{!visited && !isCollapsed && (
<span className='text-white ml-auto mr-4 px-2 py-0.5 text-xs font-bold bg-purple-600 rounded-full'>
<span className='ml-auto mr-4 rounded-full bg-purple-600 px-2 py-0.5 text-xs font-bold text-white'>
{t('accountPage.sidebar.newBadge')}
</span>
)}
Expand Down
22 changes: 11 additions & 11 deletions client/app/(account)/account/components/Content/Sidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Sidebar({ blocks }) {
const theme = useThemeStore(state => state.theme);
const isCollapsed = useAccountStore(state => state.isCollapsed);
const setIsCollapsed = useAccountStore(state => state.setIsCollapsed);

const isMobile = useMedia('(max-width: 768px)');

return (
Expand All @@ -28,7 +28,7 @@ export default function Sidebar({ blocks }) {
isCollapsed ? 'min-w-[60px] w-[60px]' : 'min-w-[250px]'
)}
>
<div className='sticky top-0 w-full h-max'>
<div className='sticky top-0 h-max w-full'>
<div
className={cn(
'flex items-center pt-8 select-none gap-4',
Expand All @@ -39,12 +39,12 @@ export default function Sidebar({ blocks }) {
className='flex gap-x-4 hover:opacity-60'
href='/'
>
<Image
src={theme === 'dark' ? '/symbol_white.png' : '/symbol_black.png'}
width={64}
height={64}
alt="discord.place Logo"
className='w-6 h-6'
<Image
src={theme === 'dark' ? '/symbol_white.png' : '/symbol_black.png'}
width={64}
height={64}
alt="discord.place Logo"
className='size-6'
/>

<h1
Expand Down Expand Up @@ -88,7 +88,7 @@ export default function Sidebar({ blocks }) {
)}
</div>

<div className='flex flex-col w-full pl-4 mt-8 gap-y-1'>
<div className='mt-8 flex w-full flex-col gap-y-1 pl-4'>
{blocks.filter(({ tabs }) => !tabs).map(block => (
<BlockItem
key={block.id}
Expand All @@ -101,7 +101,7 @@ export default function Sidebar({ blocks }) {
key={block.id}
className={cn(
'flex flex-col gap-y-1',
!isCollapsed && 'mt-3'
!isCollapsed && 'mt-3'
)}
>
<span
Expand All @@ -110,7 +110,7 @@ export default function Sidebar({ blocks }) {
isCollapsed && 'hidden'
)}
>
{block.name}
{block.name}
</span>

<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useLanguageStore, { t } from '@/stores/language';
export default function ActiveReminders() {
const data = useAccountStore(state => state.data);
const language = useLanguageStore(state => state.language);

const remindersCount = data.reminders?.length || 0;
const voteRemindersCount = data.voteReminders?.length || 0;

Expand All @@ -29,8 +29,8 @@ export default function ActiveReminders() {
</div>

{(remindersCount === 0 && voteRemindersCount === 0) ? (
<div className='max-w-[800px] mt-20'>
<ErrorState
<div className='mt-20 max-w-[800px]'>
<ErrorState
title={
<div className='flex items-center gap-x-2'>
<BsEmojiAngry />
Expand All @@ -43,7 +43,7 @@ export default function ActiveReminders() {
) : (
<>
{remindersCount > 0 && (
<div className='flex flex-col gap-y-4 max-w-[800px]'>
<div className='flex max-w-[800px] flex-col gap-y-4'>
<h2 className='text-sm font-bold text-secondary'>
{t('accountPage.tabs.activeReminders.fields.reminders.title')}

Expand All @@ -52,7 +52,7 @@ export default function ActiveReminders() {
</span>
</h2>

<div className='flex flex-col border-2 divide-y border-primary rounded-xl'>
<div className='flex flex-col divide-y rounded-xl border-2 border-primary'>
{data.reminders.map((reminder, index) => (
<div
key={reminder._id}
Expand All @@ -62,19 +62,19 @@ export default function ActiveReminders() {
index === 0 ? 'rounded-t-xl' : ''
)}
>
<div className='flex flex-wrap items-center w-full gap-4 sm:items-start'>
<div className='flex w-full flex-wrap items-center gap-4 sm:items-start'>
<div className='flex flex-col items-start'>
<div className='hidden text-base font-semibold text-primary sm:block'>
{t('accountPage.tabs.activeReminders.fields.reminders.about')}
</div>

<div className='text-xs font-medium text-tertiary max-w-[300px] break-words line-clamp-6'>
<div className='line-clamp-6 max-w-[300px] break-words text-xs font-medium text-tertiary'>
{reminder.about}
</div>
</div>

<div className='flex flex-col items-center flex-1 w-full sm:items-end'>
<div className='text-base font-semibold text-center text-primary'>
<div className='flex w-full flex-1 flex-col items-center sm:items-end'>
<div className='text-center text-base font-semibold text-primary'>
<Countdown
date={new Date(reminder.expire_at).getTime()}
renderer={({ days, hours, minutes, seconds, completed }) => {
Expand All @@ -97,7 +97,7 @@ export default function ActiveReminders() {
)}

{voteRemindersCount > 0 && (
<div className='flex flex-col gap-y-4 max-w-[800px]'>
<div className='flex max-w-[800px] flex-col gap-y-4'>
<h2 className='text-sm font-bold text-secondary'>
{t('accountPage.tabs.activeReminders.fields.voteReminders.title')}

Expand All @@ -106,7 +106,7 @@ export default function ActiveReminders() {
</span>
</h2>

<div className='flex flex-col border-2 divide-y border-primary rounded-xl'>
<div className='flex flex-col divide-y rounded-xl border-2 border-primary'>

{data.voteReminders.map((voteReminder, index) => (
<div
Expand All @@ -118,7 +118,7 @@ export default function ActiveReminders() {
)}
>
<Link
className='flex items-center transition-opacity gap-x-4 hover:opacity-70'
className='flex items-center gap-x-4 transition-opacity hover:opacity-70'
href={`/servers/${voteReminder.guild.id}`}
>
<ServerIcon
Expand All @@ -129,20 +129,20 @@ export default function ActiveReminders() {
height={32}
className='rounded-lg'
/>

<div className='flex flex-col'>
<p className='text-sm font-bold text-secondary'>
{voteReminder.guild.name}
</p>

<p className='text-xs text-tertiary'>
{voteReminder.guild.id}
</p>
</div>
</Link>

<div className='flex flex-col items-center sm:items-end'>
<div className='text-base font-semibold text-center text-primary'>
<div className='text-center text-base font-semibold text-primary'>
<Countdown
date={new Date(voteReminder.createdAt).getTime() + 86400000}
renderer={({ hours, minutes, seconds, completed }) => {
Expand All @@ -152,7 +152,7 @@ export default function ActiveReminders() {
}}
/>
</div>

<div className='text-xs font-medium text-tertiary'>
{new Date(voteReminder.createdAt).toLocaleDateString(language, { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' })}
</div>
Expand Down
Loading

0 comments on commit 14e6810

Please sign in to comment.