Skip to content

Commit

Permalink
Feature/enforce license notice in each file via eslint rule (#304)
Browse files Browse the repository at this point in the history
* [ESLint] Add "eslint-plugin-header" as dev dependency

* [ESLint::eslint-plugin-header] Setup rule

* [ESLint::eslint-plugin-header] Fix errors
  • Loading branch information
schroda authored May 18, 2023
1 parent 13dbb8f commit 58eb2fe
Show file tree
Hide file tree
Showing 93 changed files with 252 additions and 75 deletions.
18 changes: 17 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
module.exports = {
extends: ['airbnb', 'airbnb-typescript', 'prettier'],
plugins: ['@typescript-eslint', 'no-relative-import-paths', 'prettier'],
plugins: ['@typescript-eslint', 'no-relative-import-paths', 'prettier', 'header'],
parserOptions: {
project: './tsconfig.json',
},
rules: {
'header/header': [
'error',
'block', // comment type
[ // expected file header comment
// the spaces are important, otherwise, the rule will mark it as an error
'',
' * Copyright (C) Contributors to the Suwayomi project',
' *',
' * This Source Code Form is subject to the terms of the Mozilla Public',
' * License, v. 2.0. If a copy of the MPL was not distributed with this',
' * file, You can obtain one at https://mozilla.org/MPL/2.0/.',
' ',
],
2, // number of new lines after comment
],

'prettier/prettier': 'error',

'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-no-relative-import-paths": "^1.5.2",
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { Container } from '@mui/material';
import CssBaseline from '@mui/material/CssBaseline';
Expand Down
3 changes: 2 additions & 1 deletion src/components/ExtensionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useState } from 'react';
import Card from '@mui/material/Card';
Expand Down
3 changes: 2 additions & 1 deletion src/components/MangaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React from 'react';
import Card from '@mui/material/Card';
Expand Down
3 changes: 2 additions & 1 deletion src/components/MangaGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
import Grid from '@mui/material/Grid';
Expand Down
3 changes: 2 additions & 1 deletion src/components/SourceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { CardActionArea } from '@mui/material';
import Avatar from '@mui/material/Avatar';
Expand Down
8 changes: 8 additions & 0 deletions src/components/atoms/LoadingIconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { CircularProgress, IconButton, IconButtonProps } from '@mui/material';
import React, { useState } from 'react';

Expand Down
3 changes: 2 additions & 1 deletion src/components/context/DarkTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React from 'react';

Expand Down
3 changes: 2 additions & 1 deletion src/components/context/LibraryOptionsContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useContext } from 'react';
import { LibraryOptions } from 'typings';
Expand Down
3 changes: 2 additions & 1 deletion src/components/context/NavbarContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useContext, useEffect } from 'react';
import { INavbarOverride } from 'typings';
Expand Down
3 changes: 2 additions & 1 deletion src/components/library/LibraryOptionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { FormLabel, RadioGroup } from '@mui/material';
import CheckboxInput from 'components/atoms/CheckboxInput';
Expand Down
3 changes: 2 additions & 1 deletion src/components/library/LibraryOptionsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import LibraryOptionsContext, { DefaultLibraryOptions } from 'components/context/LibraryOptionsContext';
import React, { useMemo } from 'react';
Expand Down
3 changes: 2 additions & 1 deletion src/components/library/LibraryToolbarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import FilterList from '@mui/icons-material/FilterList';
import { IconButton } from '@mui/material';
Expand Down
8 changes: 8 additions & 0 deletions src/components/library/UpdateChecker.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useEffect, useState } from 'react';
import IconButton from '@mui/material/IconButton';
import RefreshIcon from '@mui/icons-material/Refresh';
Expand Down
8 changes: 8 additions & 0 deletions src/components/library/useSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { useEffect, useState } from 'react';

const baseWebsocketUrl = JSON.parse(window.localStorage.getItem('serverBaseURL')!).replace('http', 'ws');
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/ChapterCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import BookmarkIcon from '@mui/icons-material/Bookmark';
import BookmarkAdd from '@mui/icons-material/BookmarkAdd';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/ChapterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { Button, CircularProgress, Stack } from '@mui/material';
import Typography from '@mui/material/Typography';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/ChapterOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { RadioGroup } from '@mui/material';
import RadioInput from 'components/atoms/RadioInput';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/ChaptersToolbarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import FilterList from '@mui/icons-material/FilterList';
import { IconButton } from '@mui/material';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/MangaDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import FavoriteIcon from '@mui/icons-material/Favorite';
import FavoriteBorderIcon from '@mui/icons-material/FavoriteBorder';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/MangaToolbarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import Label from '@mui/icons-material/Label';
import MoreHoriz from '@mui/icons-material/MoreHoriz';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/ResumeFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React from 'react';
import { Link } from 'react-router-dom';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/SelectionFAB.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import MoreHoriz from '@mui/icons-material/MoreHoriz';
import { Fab, Menu } from '@mui/material';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/SelectionFABActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import BookmarkAdd from '@mui/icons-material/BookmarkAdd';
import BookmarkRemove from '@mui/icons-material/BookmarkRemove';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { useCallback, useState } from 'react';
import { mutate } from 'swr';
Expand Down
3 changes: 2 additions & 1 deletion src/components/manga/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { t } from 'i18next';
import { useReducerLocalStorage } from 'util/useLocalStorage';
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/OptionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { Drawer } from '@mui/material';
import { Box } from '@mui/system';
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/OptionsTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import { Stack, Tab, Tabs } from '@mui/material';
import TabPanel from 'components/util/TabPanel';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/DefaultNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useContext } from 'react';
import AppBar from '@mui/material/AppBar';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/NavBarContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useCallback, useMemo, useState } from 'react';
import NavBarContext from 'components/context/NavbarContext';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/ReaderNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import IconButton from '@mui/material/IconButton';
import CloseIcon from '@mui/icons-material/Close';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/action/CategorySelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useMemo } from 'react';
import Button from '@mui/material/Button';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/action/LangSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React, { useState } from 'react';
import Button from '@mui/material/Button';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/navigation/DesktopSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React from 'react';
import { ListItem, ListItemIcon, Tooltip } from '@mui/material';
Expand Down
3 changes: 2 additions & 1 deletion src/components/navbar/navigation/MobileBottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React from 'react';
import { ListItem } from '@mui/material';
Expand Down
3 changes: 2 additions & 1 deletion src/components/reader/DoublePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

import React from 'react';
import { Box, styled } from '@mui/system';
Expand Down
Loading

0 comments on commit 58eb2fe

Please sign in to comment.