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

setup-prettier-linting-husky #2183

Merged
merged 18 commits into from
Jul 2, 2024
Merged
9 changes: 3 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@
"no-use-before-define": "off", // since we are using airbnb, it turns this on, we need to disabled it @see https://stackoverflow.com/a/64024916/1931451
"@typescript-eslint/no-use-before-define": "off",
"no-shadow": "off", // we need to disable this @see https://stackoverflow.com/a/63961972/1931451
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/no-shadow": 2,
"react/jsx-filename-extension": 0,
"react/jsx-props-no-spreading": 0,
"react/function-component-definition": 0,
"react/jsx-no-useless-fragment": 0,
"react/no-unstable-nested-components": 0,
"react/boolean-prop-naming": [
"error",
{ "rule": "^(is|has|should)[A-Z]([A-Za-z0-9]?)+" }
],
"react/boolean-prop-naming": ["error", { "rule": "^(is|has|should)[A-Z]([A-Za-z0-9]?)+" }],
"react/destructuring-assignment": 2,
"react/no-children-prop": 2,
"react/no-deprecated": 2,
Expand Down Expand Up @@ -153,7 +150,7 @@
],
"react/forbid-prop-types": 0,
"react/jsx-no-undef": 0,
"react/no-unused-prop-types": 0,
"react/no-unused-prop-types": 2,
"react/prop-types": 0,
"react/react-in-jsx-scope": 0,
"curly": "error",
Expand Down
13 changes: 13 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"printWidth": 100,
"proseWrap": "always",
"requirePragma": false,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const config = {
},
};

// eslint-disable-next-line max-lines
module.exports = withPlugins(
[withBundleAnalyzer, withPWA, withFonts, nextTranslate, withSentryConfig],
config,
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
"test:watch": "vitest watch",
"analyze": "cross-env ANALYZE_BUNDLE=true yarn build",
"lokalise": "node scripts/lokalise.js",
"chapter-data:format": "node scripts/format-chapter-data-json.js"
"chapter-data:format": "node scripts/format-chapter-data-json.js",
"postinstall": "husky",
"prepack": "pinst --disable",
"postpack": "pinst --enable"
},
"dependencies": {
"@babel/eslint-parser": "^7.19.1",
Expand Down Expand Up @@ -138,12 +141,13 @@
"eslint-plugin-sonarjs": "^0.15.0",
"eslint-plugin-storybook": "^0.6.15",
"eslint-plugin-unicorn": "^43.0.2",
"husky": "^8.0.1",
"husky": "^9.0.11",
"inquirer": "^8.0.0",
"inquirer-file-tree-selection-prompt": "^1",
"jsdom": "^20.0.0",
"lint-staged": "^13.0.3",
"next-sitemap": "^3.1.22",
"pinst": "^3.0.0",
"postcss": "8",
"postcss-scss": "^4.0.5",
"prettier": "^2.7.1",
Expand All @@ -169,6 +173,7 @@
},
"lint-staged": {
"*.{tsx,ts}": "yarn lint:fix",
"*.scss": "yarn lint:scss"
"*.scss": "yarn lint:scss",
"*": "prettier --write"
}
}
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ app.prepare().then(() => {
},
).listen(3000, (err) => {
if (err) throw err;
// eslint-disable-next-line no-console
console.log('> Server started on https://localhost:3000');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ type CollectionDetailProps = {
bookmarks: Bookmark[];
sortBy: string;
onSortByChange: (sortBy: string) => void;
onUpdated: () => void;
onItemDeleted: (bookmarkId: string) => void;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ const CollectionDetailContainer = ({
bookmarks={bookmarks}
sortBy={sortBy}
onSortByChange={onSortByChange}
onUpdated={onUpdated}
onItemDeleted={onItemDeleted}
isOwner={isOwner}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type SaveToCollectionModalProps = {
collections: Collection[];
onCollectionToggled: (collection: Collection, newValue: boolean) => void;
onNewCollectionCreated: (name: string) => Promise<void>;
isAddingNewCollection?: boolean;
onClose?: () => void;
verseKey: string;
};
Expand Down
1 change: 1 addition & 0 deletions src/components/FormBuilder/FormBuider.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
/* eslint-disable max-lines */
/* eslint-disable react/no-multi-comp */
/* eslint-disable no-alert */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type NavigationDrawerItemProps = {
isExternalLink?: boolean;
href?: string;
isStale?: boolean;
shouldFlipOnRTL?: boolean;
onClick?: () => void;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import { isFirstSurah, isLastSurah } from '@/utils/chapter';
import { logButtonClick } from '@/utils/eventLogger';
import { getNextSurahNavigationUrl, getPreviousSurahNavigationUrl } from '@/utils/navigation';
import { VersesResponse } from 'types/ApiResponses';
import Verse from 'types/Verse';

interface Props {
lastVerse: Verse;
initialData: VersesResponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const EndOfScrollingControls: React.FC<Props> = ({
<div className={styles.container}>
<div className={styles.buttonsContainer}>
{quranReaderDataType === QuranReaderDataType.Chapter && (
<ChapterControls lastVerse={lastVerse} initialData={initialData} />
<ChapterControls initialData={initialData} />
)}
{(quranReaderDataType === QuranReaderDataType.Verse ||
quranReaderDataType === QuranReaderDataType.ChapterVerseRanges ||
Expand Down
1 change: 1 addition & 0 deletions src/components/QuranReader/ReadingView/Line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type LineProps = {
words: Word[];
lineKey: string;
isBigTextLayout: boolean;
// eslint-disable-next-line react/no-unused-prop-types
quranReaderStyles: QuranReaderStyles;
pageIndex: number;
lineIndex: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const ReadingViewWordActionsMenu: React.FC<Props> = ({ word, onActionTriggered }
{word?.verse?.timestamps && (
<PlayVerseAudioButton
verseKey={word.verseKey}
timestamp={word.verse.timestamps.timestampFrom}
isTranslationView={false}
onActionTriggered={onActionTriggered}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ interface Props {
data: AyahReflectionsResponse;
scrollToTop: () => void;
setSelectedVerseNumber: (verseNumber: string) => void;
translationFontScale: number;
}

const ReflectionBody: React.FC<Props> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { useCallback, useState } from 'react';

import dynamic from 'next/dynamic';
import useTranslation from 'next-translate/useTranslation';
import { shallowEqual, useSelector } from 'react-redux';

import DataFetcher from '@/components/DataFetcher';
import { REFLECTIONS_OBSERVER_ID } from '@/components/QuranReader/observer';
import TafsirSkeleton from '@/components/QuranReader/TafsirView/TafsirSkeleton';
import useGlobalIntersectionObserverWithDelay from '@/hooks/useGlobalIntersectionObserverWithDelay';
import { selectQuranReaderStyles } from '@/redux/slices/QuranReader/styles';
import { isLoggedIn } from '@/utils/auth/login';
import { postReflectionViews } from '@/utils/auth/qf/api';
import {
Expand Down Expand Up @@ -40,7 +38,6 @@ const ReflectionBodyContainer = ({
}: ReflectionBodyProps) => {
const [selectedChapterId, setSelectedChapterId] = useState(initialChapterId);
const [selectedVerseNumber, setSelectedVerseNumber] = useState(initialVerseNumber);
const { translationFontScale } = useSelector(selectQuranReaderStyles, shallowEqual);
const { lang } = useTranslation();

/**
Expand Down Expand Up @@ -75,10 +72,9 @@ const ReflectionBodyContainer = ({
selectedVerseNumber={selectedVerseNumber}
setSelectedVerseNumber={setSelectedVerseNumber}
scrollToTop={scrollToTop}
translationFontScale={translationFontScale}
/>
),
[scrollToTop, selectedChapterId, selectedVerseNumber, translationFontScale],
[scrollToTop, selectedChapterId, selectedVerseNumber],
);

const body = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { RefObject, useEffect, memo, useContext } from 'react';
import React, { RefObject, memo, useContext, useEffect } from 'react';

import { useSelector as useSelectorXstate } from '@xstate/react';
import classNames from 'classnames';
Expand Down Expand Up @@ -96,10 +96,7 @@ const TranslationViewCell: React.FC<TranslationViewCellProps> = ({
<VerseNotes verseKey={verse.verseKey} isTranslationView hasNotes={hasNotes} />
</div>
<div className={classNames(styles.actionItem, styles.priorityAction)}>
<PlayVerseAudioButton
verseKey={verse.verseKey}
timestamp={verse.timestamps.timestampFrom}
/>
<PlayVerseAudioButton verseKey={verse.verseKey} />
</div>
<div className={classNames(styles.actionItem)}>
<TafsirButton verseKey={verse.verseKey} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const QuranicCalendarMonth: React.FC<Props> = ({ monthWeeks, currentQuranicCalen
key={ranges}
isCurrentWeek={currentQuranicCalendarWeek === Number(weekNumber)}
weekNumber={Number(weekNumber)}
currentQuranicCalendarWeek={currentQuranicCalendarWeek}
localizedMonth={localizedMonth}
ranges={ranges}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { getQuranReflectPostUrl } from '@/utils/quranReflect/navigation';

type Props = {
weekNumber: number;
currentQuranicCalendarWeek: number;
isCurrentWeek: boolean;
localizedMonth: string;
ranges: string;
Expand Down
1 change: 0 additions & 1 deletion src/components/Search/PreInput/SearchItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import IconContainer, { IconColor, IconSize } from '@/dls/IconContainer/IconCont
type SearchItemProps = {
prefix: React.ReactNode;
title: string;
url: string;
suffix?: React.ReactNode;
onClick?: () => void;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const SearchQuerySuggestion: React.FC<Props> = ({
<SearchItem
title={searchQuery}
prefix={<SearchIcon />}
url="/"
onClick={() => onSearchKeywordClicked(searchQuery)}
suffix={
onRemoveSearchQueryClicked && (
Expand Down
1 change: 0 additions & 1 deletion src/components/Search/PreInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const PreInput: React.FC<Props> = ({ onSearchKeywordClicked, isSearchDrawer }) =
<SearchItem
prefix={<TrendUpIcon />}
title={chapterData.transliteratedName}
url={url}
key={url}
onClick={() => {
logButtonClick(
Expand Down
1 change: 0 additions & 1 deletion src/components/Verse/PlayVerseAudioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { AudioPlayerMachineContext } from 'src/xstate/AudioPlayerMachineContext'

interface PlayVerseAudioProps {
verseKey: string;
timestamp: number;
isTranslationView?: boolean;
onActionTriggered?: () => void;
}
Expand Down
1 change: 0 additions & 1 deletion src/components/Verse/SaveToCollectionAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ const SaveToCollectionAction = ({ verse, bookmarksRangeUrl, isTranslationView })
onCollectionToggled={onCollectionToggled}
onNewCollectionCreated={onNewCollectionCreated}
onClose={closeModal}
isAddingNewCollection
collections={collections}
verseKey={`${verse.chapterId}:${verse.verseNumber}`}
/>
Expand Down
1 change: 0 additions & 1 deletion src/components/Verses/RecentReadingSessions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const RecentReadingSessions = () => {
Number(verseNumber),
lang,
)}`}
verseCount={surah.versesCount}
/>
</Link>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-alert */
import Button from '../Button/Button';

import ConfirmationModal from './ConfirmationModal';
Expand Down
1 change: 0 additions & 1 deletion src/components/dls/Skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ type SkeletonProps = {
isRounded?: boolean;
isSquared?: boolean;
isActive?: boolean;
style?: React.CSSProperties;
className?: string;
};

Expand Down
1 change: 0 additions & 1 deletion src/components/dls/SurahPreview/SurahPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type SurahProps = {
surahNumber: number;
surahName: string;
translatedSurahName: string;
verseCount: number;
chapterId: number;
display?: SurahPreviewDisplay;
description?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/page/utils/getQuranReaderData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getQuranReaderData = (
) => {
return {
...pageVersesData,
pageVerses: { pagesLookup: pagesLookupData },
pagesLookup: pagesLookupData,
metaData: { numberOfVerses: pageVersesData.verses.length },
};
};
Expand Down
2 changes: 0 additions & 2 deletions src/pages/radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import ReciterStationList from '@/components/Radio/ReciterStationList';
import { getAllChaptersData } from '@/utils/chapter';
import { getLanguageAlternates } from '@/utils/locale';
import { getCanonicalUrl } from '@/utils/navigation';
import ChaptersData from 'types/ChaptersData';
import Reciter from 'types/Reciter';

type RadioPageProps = {
reciters: Reciter[];
chaptersData: ChaptersData;
};

const NAVIGATION_URL = '/radio';
Expand Down
4 changes: 1 addition & 3 deletions src/pages/reciters/[reciterId]/[chapterId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import PauseIcon from '@/icons/pause.svg';
import PlayIcon from '@/icons/play-arrow.svg';
import ReaderIcon from '@/icons/reader.svg';
import { makeCDNUrl } from '@/utils/cdn';
import { getChapterData, getAllChaptersData } from '@/utils/chapter';
import { getAllChaptersData, getChapterData } from '@/utils/chapter';
import { logButtonClick } from '@/utils/eventLogger';
import {
getCanonicalUrl,
Expand All @@ -36,13 +36,11 @@ import { isValidChapterId } from '@/utils/validator';
import { selectCurrentAudioReciterId } from '@/xstate/actors/audioPlayer/selectors';
import { AudioPlayerMachineContext } from '@/xstate/AudioPlayerMachineContext';
import Chapter from 'types/Chapter';
import ChaptersData from 'types/ChaptersData';
import Reciter from 'types/Reciter';

type ShareRecitationPageProps = {
selectedReciter: Reciter;
selectedChapter: Chapter;
chaptersData: ChaptersData;
};

const RecitationPage = ({ selectedReciter, selectedChapter }: ShareRecitationPageProps) => {
Expand Down
1 change: 1 addition & 0 deletions src/xstate/actors/audioPlayer/audioPlayerMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ export const audioPlayerMachine =
handler as MediaSessionActionHandler,
);
} catch (error) {
// eslint-disable-next-line no-console
console.log(`The media session action "${action}" is not supported yet.`);
}
}
Expand Down
Loading
Loading