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

Further Improvement eslint WIP #239

Closed
wants to merge 1 commit into from
Closed
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
22 changes: 21 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"extends": [
"standard",
"plugin:import/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:react/jsx-runtime",
Expand All @@ -23,11 +24,16 @@
"sourceType": "module"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
},
"react": {
"version": "detect"
}
},
"plugins": ["react", "react-hooks", "vitest", "cypress", "n", "promise", "no-only-tests"],
"plugins": ["react", "react-hooks", "vitest", "cypress", "n", "promise", "no-only-tests", "import"],
"globals": {
"vi": true
},
Expand All @@ -42,7 +48,21 @@
"functions": "never"
}
],
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"import/newline-after-import": ["error", { "count": 2 }],
"import/order": [
"error",
{
"alphabetize": {
"caseInsensitive": true,
"order": "asc"
},
"groups": ["type", "builtin", "external", "internal", ["sibling", "parent"], "index", "object"],
"newlines-between": "always"
}
],
"multiline-ternary": "off",
"no-multiple-empty-lines": "off",
"no-console": "warn",
"no-only-tests/no-only-tests": "error",
"no-unused-vars": "warn",
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/scrobbleSong/scrobble-song-submit.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import qs from 'qs';


const scrobblingBaseDate = Date.UTC(2023, 5, 30, 23, 59, 4, 123);

describe('Scrobble song (scrobbling)', () => {
Expand Down
1 change: 1 addition & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs');
const path = require('path');


module.exports = (on, config) => {
/*
* Override config for particular environments
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"start:services": "docker-compose up",
"build": "yarn typecheck && vite build",
"prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint src/ cypress/",
"lint": "eslint \"./src\" \"./cypress\" --ext .js,.jsx,.ts,.tsx",
"fix": "yarn prettier && yarn lint --fix",
"test": "yarn test:unit && yarn test:e2e",
"test:e2e": "TZ=Etc/GMT-3 start-test 'yarn start:server --port 3030' 3030 'cypress run'",
Expand Down
36 changes: 17 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
import { Suspense, useEffect, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useDispatch } from 'react-redux';
import qs from 'qs';
import { useGrowthBook } from '@growthbook/growthbook-react';
import * as Sentry from '@sentry/react';
import AlertZone from 'components/AlertZone';

Check failure on line 3 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/AlertZone'
import AnalyticsListener from 'components/AnalyticsListener';

Check failure on line 4 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/AnalyticsListener'
import Footer from 'components/Footer';

Check failure on line 5 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/Footer'
import Navigation from 'components/Navigation';

Check failure on line 6 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/Navigation'
import { SettingsModalContext } from 'components/SettingsModal/SettingsModalContext';

Check failure on line 7 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/SettingsModal/SettingsModalContext'
import Spinner from 'components/Spinner';

Check failure on line 8 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/Spinner'
import UpdateToast from 'components/UpdateToast';

Check failure on line 9 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'components/UpdateToast'
import { useLanguage } from 'hooks/useLanguage';

Check failure on line 10 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'hooks/useLanguage'
import { useUserData } from 'hooks/useUserData';

Check failure on line 11 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'hooks/useUserData'
import { find } from 'lodash-es';
import qs from 'qs';
import { Suspense, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import lazyWithPreload from 'react-lazy-with-preload';

import * as Sentry from '@sentry/react';
import { useDispatch } from 'react-redux';
import { useLocation, useNavigate } from 'react-router-dom';
import Routes from 'Routes';

Check failure on line 19 in src/App.tsx

View workflow job for this annotation

GitHub Actions / Setup and quick checks

Unable to resolve path to module 'Routes'
import { interceptAxios } from 'utils/axios';
import { languageList, fallbackLng } from 'utils/i18n';

import { useTranslation } from 'react-i18next';
import { useRegisterSW } from 'virtual:pwa-register/react';
import { useGrowthBook } from '@growthbook/growthbook-react';
import { useUserData } from 'hooks/useUserData';
import { useLanguage } from 'hooks/useLanguage';

import Routes from 'Routes';
import Navigation from 'components/Navigation';
import Footer from 'components/Footer';
import AlertZone from 'components/AlertZone';
import AnalyticsListener from 'components/AnalyticsListener';
import UpdateToast from 'components/UpdateToast';
import Spinner from 'components/Spinner';
import { SettingsModalContext } from 'components/SettingsModal/SettingsModalContext';

const SettingsModal = lazyWithPreload(() => import('components/SettingsModal'));

Expand Down
11 changes: 6 additions & 5 deletions src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// import { useSelector } from 'react-redux';
import { Navigate, Route, Routes as Switch } from 'react-router-dom';

import Home from 'domains/home';
import PrivateRoute from 'components/PrivateRoute';
import { ScrobbleSong } from './domains/scrobbleSong';
import Home from 'domains/home';
import { Callback } from 'domains/lastfm/Callback';
import {
ScrobbleAlbumSearch,
ScrobbleArtistResults,
ScrobbleAlbumResults,
ScrobbleAlbumTracklist,
} from 'domains/scrobbleAlbum';
import { Navigate, Route, Routes as Switch } from 'react-router-dom';

import { ScrobbleSong } from './domains/scrobbleSong';
import { ScrobbleUserSearch, ScrobbleUserResults } from './domains/scrobbleUser';
import { Callback } from 'domains/lastfm/Callback';


export default function Routes() {
return (
Expand Down
7 changes: 4 additions & 3 deletions src/components/AlbumCard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { CSSProperties } from 'react';
import { random } from 'lodash-es';
import type { AlbumCover, AlbumCoverSizes } from 'utils/types/album';

import { random } from 'lodash-es';
import { CSSProperties } from 'react';
import { LazyLoadImage } from 'react-lazy-load-image-component';
import 'react-lazy-load-image-component/src/effects/opacity.css';

import './AlbumCard.css';
import { AlbumCover, AlbumCoverSizes } from 'utils/types/album';


interface AlbumCardProps {
artist?: string;
Expand Down
5 changes: 3 additions & 2 deletions src/components/AlertZone/AlertZone.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { RootState } from 'store';

import { useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { useLocation } from 'react-router-dom';

import { clearAlerts } from 'store/actions/alertActions';

import AlertItem from './partials/AlertItem';
import type { RootState } from 'store';


export default function AlertZone() {
const location = useLocation();
Expand Down
8 changes: 4 additions & 4 deletions src/components/AlertZone/partials/AlertItem.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useState } from 'react';
import { useDispatch } from 'react-redux';

import { Trans } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { Alert as ReactstrapAlert } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { dismissAlert } from 'store/actions/alertActions';

import { Alert } from '../types';


export default function AlertItem({ id: alertId, type, errorNumber, title, message, rawMessage, icon }: Alert) {
const [isOpen, setOpenState] = useState(true);
const dispatch = useDispatch();
Expand Down
2 changes: 1 addition & 1 deletion src/components/AlertZone/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { IconProp } from '@fortawesome/fontawesome-svg-core';

import type { ReactNode } from 'react';


export type Alert = {
id: string;
type: 'danger' | 'success' | 'info' | 'warning';
Expand Down
2 changes: 1 addition & 1 deletion src/components/AnalyticsListener.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect } from 'react';
import ReactGA from 'react-ga-neo';

import { useLocation } from 'react-router-dom';


function sendPageChange(page) {
ReactGA.send({ hitType: 'pageview', page });
}
Expand Down
11 changes: 5 additions & 6 deletions src/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { LazyLoadImage } from 'react-lazy-load-image-component';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faUserAstronaut } from '@fortawesome/free-solid-svg-icons';

import type { SizeProp } from '@fortawesome/fontawesome-svg-core';

import type { AvatarSizes } from 'utils/types/avatar';

import { faUserAstronaut } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { LazyLoadImage } from 'react-lazy-load-image-component';

import './Avatar.css';


interface AvatarProps {
alt: string;
className?: string;
Expand Down
2 changes: 2 additions & 0 deletions src/components/DateTimePicker.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { render } from '@testing-library/react';

import DateTimePicker from './DateTimePicker';
import i18n from '../utils/i18n';


const use12Hours = false;
vi.mock('hooks/useSettings', async() => ({
...(await vi.importActual('hooks/useSettings')),
Expand Down
22 changes: 9 additions & 13 deletions src/components/DateTimePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import { forwardRef, useMemo, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import ReactGA from 'react-ga-neo';

import { faCalendarAlt, faClock } from '@fortawesome/free-regular-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import addDays from 'date-fns/addDays';
import subDays from 'date-fns/subDays';
import format from 'date-fns/format';

import { Input, InputGroup, InputGroupText, Modal, ModalBody, ModalHeader } from 'reactstrap';
import TimeKeeper from 'react-timekeeper';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCalendarAlt, faClock } from '@fortawesome/free-regular-svg-icons';

import subDays from 'date-fns/subDays';
import { useSettings } from 'hooks/useSettings';

import { forwardRef, useMemo, useState } from 'react';
import DayPickerInput from 'react-day-picker/DayPickerInput';
import ReactGA from 'react-ga-neo';
import { Trans, useTranslation } from 'react-i18next';
import TimeKeeper from 'react-timekeeper';
import { Input, InputGroup, InputGroupText, Modal, ModalBody, ModalHeader } from 'reactstrap';

import 'react-day-picker/lib/style.css';
import './DateTimePicker.scss';


function DatePickerInput(props = {}) {
return (
<InputGroup size="sm">
Expand Down
4 changes: 2 additions & 2 deletions src/components/EmptyScrobbleListFiller.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { faQuestion, faUserAstronaut } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Trans } from 'react-i18next';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faQuestion, faUserAstronaut } from '@fortawesome/free-solid-svg-icons';

export default function EmptyScrobbleListFiller() {
return (
Expand Down
2 changes: 2 additions & 0 deletions src/components/Footer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { render, screen } from '@testing-library/react';

import Footer from './Footer';
import i18n from '../utils/i18n';


const returnedLocation = {
pathName: '',
};
Expand Down
8 changes: 4 additions & 4 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useLocation } from 'react-router-dom';
import { Trans } from 'react-i18next';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faGithub, faDiscord, faPatreon } from '@fortawesome/free-brands-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Trans } from 'react-i18next';
import { useLocation } from 'react-router-dom';

import './Footer.css';


function Footer() {
const location = useLocation();

Expand Down
14 changes: 7 additions & 7 deletions src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { faPlayCircle } from '@fortawesome/free-regular-svg-icons';
import { faHeadphonesAlt, faCompactDisc, faSignInAlt, faUserFriends } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { LASTFM_AUTH_URL } from 'Constants';
import { useSettings } from 'hooks/useSettings';
import { useUserData } from 'hooks/useUserData';
import { useEffect, useState } from 'react';
import { Link, useLocation } from 'react-router-dom';
import { Collapse, Nav, Navbar, NavbarBrand, NavbarToggler } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faHeadphonesAlt, faCompactDisc, faSignInAlt, faUserFriends } from '@fortawesome/free-solid-svg-icons';
import { faPlayCircle } from '@fortawesome/free-regular-svg-icons';

import { useBootstrapBreakpoint, BS_SIZE_SM } from 'utils/bootstrapBreakpoints';
import { useUserData } from 'hooks/useUserData';
import { useSettings } from 'hooks/useSettings';

import LanguageSelector from './partials/LanguageSelector';
import NavigationItem from './partials/NavigationItem';
import UserDropdown from './partials/UserDropdown';
import { LASTFM_AUTH_URL } from 'Constants';

import './Navigation.scss';


export default function Navigation() {
const { isLoggedIn } = useUserData();
const { settings } = useSettings();
Expand Down
16 changes: 8 additions & 8 deletions src/components/Navigation/partials/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { languageList } from 'utils/i18n';
import ReactGA from 'react-ga-neo';
import { UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faGlobe } from '@fortawesome/free-solid-svg-icons';
import { useTranslation } from 'react-i18next';

import { useUserData } from 'hooks/useUserData';
import { useSettings } from 'hooks/useSettings';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useLanguage } from 'hooks/useLanguage';
import { useSettings } from 'hooks/useSettings';
import { useUserData } from 'hooks/useUserData';
import ReactGA from 'react-ga-neo';
import { useTranslation } from 'react-i18next';
import { UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'reactstrap';
import { languageList } from 'utils/i18n';

import './LanguageSelector.scss';


export default function LanguageSelector({ className = '' }: { className?: string }) {
const { t } = useTranslation();
const { isLoggedIn } = useUserData();
Expand Down
8 changes: 5 additions & 3 deletions src/components/Navigation/partials/NavigationItem.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { NavLink as RouterNavLink } from 'react-router-dom';
import type { IconProp } from '@fortawesome/fontawesome-svg-core';

import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Trans } from 'react-i18next';
import { NavLink as RouterNavLink } from 'react-router-dom';
import { NavItem, NavLink } from 'reactstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { IconProp } from '@fortawesome/fontawesome-svg-core';


export default function NavigationItem({
external = false,
Expand Down
Loading