Merge pull request #703 from Stremio/chore/update-eslint

chore: update eslint
This commit is contained in:
Tim 2024-10-07 13:46:19 +02:00 committed by GitHub
commit 2b83e86fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
68 changed files with 2092 additions and 674 deletions

View file

@ -1,99 +0,0 @@
{
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"settings": {
"react": {
"version": "detect"
}
},
"globals": {
"YT": "readonly",
"FB": "readonly",
"cast": "readonly",
"chrome": "readonly"
},
"env": {
"node": true,
"commonjs": true,
"browser": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 11,
"ecmaFeatures": {
"jsx": true
}
},
"ignorePatterns": [
"/*",
"!/src"
],
"rules": {
"arrow-parens": "error",
"arrow-spacing": "error",
"block-spacing": "error",
"comma-spacing": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"indent": [
"error",
4,
{
"SwitchCase": 1
}
],
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
],
"no-extra-semi": "error",
"no-eq-null": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1
}
],
"no-prototype-builtins": "off",
"no-template-curly-in-string": "error",
"no-trailing-spaces": "error",
"no-useless-concat": "error",
"no-unreachable": "error",
"no-unused-vars": [
"error",
{
"varsIgnorePattern": "_"
}
],
"prefer-const": "error",
"quotes": [
"error",
"single"
],
"quote-props": [
"error",
"as-needed",
{
"unnecessary": false
}
],
"semi": "error",
"semi-spacing": "error",
"space-before-blocks": "error",
"valid-typeof": [
"error",
{
"requireStringLiterals": true
}
]
}
}

100
eslint.config.mjs Normal file
View file

@ -0,0 +1,100 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import stylistic from '@stylistic/eslint-plugin'
export default [
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
pluginReact.configs.flat.recommended,
{
plugins: {
'@stylistic': stylistic
},
},
{
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}']
},
{
files: ['**/*.js'],
languageOptions: {
sourceType: 'commonjs',
ecmaVersion: 'latest',
}
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
YT: 'readonly',
FB: 'readonly',
cast: 'readonly',
chrome: 'readonly',
}
}
},
{
settings: {
react: {
version: 'detect',
},
},
},
{
rules: {
'no-redeclare': 'off',
'eol-last': 'error',
'eqeqeq': 'error',
'no-console': ['error', {
allow: [
'warn',
'error'
]
}],
}
},
{
rules: {
'@typescript-eslint/no-redeclare': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
'varsIgnorePattern': '_',
'caughtErrorsIgnorePattern': '_',
}
],
}
},
{
rules: {
'@stylistic/arrow-parens': 'error',
'@stylistic/arrow-spacing': 'error',
'@stylistic/block-spacing': 'error',
'@stylistic/comma-spacing': 'error',
'@stylistic/semi-spacing': 'error',
'@stylistic/space-before-blocks': 'error',
'@stylistic/no-trailing-spaces': 'error',
'@stylistic/func-call-spacing': 'error',
'@stylistic/eol-last': 'error',
'@stylistic/no-multi-spaces': 'error',
'@stylistic/no-multiple-empty-lines': ['error', {
max: 1
}],
'@stylistic/indent': ['error', 4],
'@stylistic/quotes': ['error', 'single'],
}
},
{
rules: {
'react/display-name': 'off',
}
}
];

2418
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -50,6 +50,9 @@
"@babel/plugin-proposal-object-rest-spread": "7.16.0", "@babel/plugin-proposal-object-rest-spread": "7.16.0",
"@babel/preset-env": "7.16.0", "@babel/preset-env": "7.16.0",
"@babel/preset-react": "7.16.0", "@babel/preset-react": "7.16.0",
"@eslint/js": "^9.12.0",
"@stylistic/eslint-plugin": "^2.9.0",
"@stylistic/eslint-plugin-jsx": "^2.9.0",
"@types/hat": "^0.0.4", "@types/hat": "^0.0.4",
"@types/react": "^18.2.9", "@types/react": "^18.2.9",
"babel-loader": "8.2.3", "babel-loader": "8.2.3",
@ -58,8 +61,9 @@
"css-loader": "6.5.0", "css-loader": "6.5.0",
"cssnano": "5.0.8", "cssnano": "5.0.8",
"cssnano-preset-advanced": "5.1.4", "cssnano-preset-advanced": "5.1.4",
"eslint": "7.32.0", "eslint": "^9.12.0",
"eslint-plugin-react": "7.26.1", "eslint-plugin-react": "^7.37.1",
"globals": "^15.10.0",
"html-webpack-plugin": "5.5.0", "html-webpack-plugin": "5.5.0",
"jest": "27.3.1", "jest": "27.3.1",
"less": "4.1.2", "less": "4.1.2",
@ -70,6 +74,7 @@
"terser-webpack-plugin": "5.2.4", "terser-webpack-plugin": "5.2.4",
"ts-loader": "^9.5.1", "ts-loader": "^9.5.1",
"typescript": "^5.4.2", "typescript": "^5.4.2",
"typescript-eslint": "^8.8.0",
"webpack": "5.61.0", "webpack": "5.61.0",
"webpack-cli": "4.9.1", "webpack-cli": "4.9.1",
"webpack-dev-server": "^4.7.4", "webpack-dev-server": "^4.7.4",

View file

@ -42,4 +42,4 @@ const Chip = memo(({ label, value, active, onSelect }: Props) => {
); );
}); });
export default Chip; export default Chip;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2017-2024 Smart code 203358507 // Copyright (C) 2017-2024 Smart code 203358507
import Chip from './Chip'; import Chip from './Chip';
export default Chip; export default Chip;

View file

@ -53,4 +53,4 @@ const Chips = memo(({ options, selected, onSelect }: Props) => {
); );
}); });
export default Chips; export default Chips;

View file

@ -1,4 +1,4 @@
// Copyright (C) 2017-2024 Smart code 203358507 // Copyright (C) 2017-2024 Smart code 203358507
import Chips from './Chips'; import Chips from './Chips';
export default Chips; export default Chips;

View file

@ -37,6 +37,7 @@ const useCoreSuspender = () => {
return React.useContext(CoreSuspenderContext); return React.useContext(CoreSuspenderContext);
}; };
// eslint-disable-next-line @typescript-eslint/no-empty-function
const withCoreSuspender = (Component, Fallback = () => { }) => { const withCoreSuspender = (Component, Fallback = () => { }) => {
return function withCoreSuspender(props) { return function withCoreSuspender(props) {
const { core } = useServices(); const { core } = useServices();

View file

@ -17,7 +17,8 @@ const DelayedRenderer = ({ children, delay }) => {
}; };
DelayedRenderer.propTypes = { DelayedRenderer.propTypes = {
children: PropTypes.node children: PropTypes.node,
delay: PropTypes.number,
}; };
module.exports = DelayedRenderer; module.exports = DelayedRenderer;

View file

@ -32,7 +32,7 @@ const Dropdown = ({ level, setLevel, options, onSelect, selectedOption, menuOpen
<Icon name={'caret-left'} className={styles['back-button-icon']} /> <Icon name={'caret-left'} className={styles['back-button-icon']} />
{t('BACK')} {t('BACK')}
</Button> </Button>
: null : null
} }
{ {
options options
@ -46,10 +46,9 @@ const Dropdown = ({ level, setLevel, options, onSelect, selectedOption, menuOpen
/> />
)) ))
} }
</div> </div>
); );
}; };
export default Dropdown; export default Dropdown;

View file

@ -43,4 +43,4 @@ const Option = ({ option, selectedOption, onSelect }: Props) => {
); );
}; };
export default Option; export default Option;

View file

@ -2,4 +2,4 @@
import Option from './Option'; import Option from './Option';
export default Option; export default Option;

View file

@ -2,4 +2,4 @@
import Dropdown from './Dropdown'; import Dropdown from './Dropdown';
export default Dropdown; export default Dropdown;

View file

@ -25,7 +25,7 @@ const MultiselectMenu = ({ className, title, options, selectedOption, onSelect }
const onOptionSelect = (value: number) => { const onOptionSelect = (value: number) => {
level ? setLevel(level + 1) : onSelect(value), closeMenu(); level ? setLevel(level + 1) : onSelect(value), closeMenu();
}; };
return ( return (
<div className={classNames(styles['multiselect-menu'], className)} ref={multiselectMenuRef}> <div className={classNames(styles['multiselect-menu'], className)} ref={multiselectMenuRef}>
<Button <Button
@ -48,10 +48,10 @@ const MultiselectMenu = ({ className, title, options, selectedOption, onSelect }
menuOpen={menuOpen} menuOpen={menuOpen}
selectedOption={selectedOption} selectedOption={selectedOption}
/> />
: null : null
} }
</div> </div>
); );
}; };
export default MultiselectMenu; export default MultiselectMenu;

View file

@ -2,4 +2,4 @@
import MultiselectMenu from './MultiselectMenu'; import MultiselectMenu from './MultiselectMenu';
export default MultiselectMenu; export default MultiselectMenu;

View file

@ -6,4 +6,4 @@ type MultiselectMenuOption = {
default?: boolean; default?: boolean;
hidden?: boolean; hidden?: boolean;
level?: MultiselectMenuOption[]; level?: MultiselectMenuOption[];
}; };

View file

@ -1,2 +1,2 @@
declare const useLocalSearch: () => { items: LocalSearchItem[], search: (query: string) => void }; declare const useLocalSearch: () => { items: LocalSearchItem[], search: (query: string) => void };
export = useLocalSearch; export = useLocalSearch;

View file

@ -1,2 +1,2 @@
declare const useSearchHistory: () => { items: SearchHistory, clear: () => void }; declare const useSearchHistory: () => { items: SearchHistory, clear: () => void };
export = useSearchHistory; export = useSearchHistory;

View file

@ -45,7 +45,7 @@ const usePlatform = () => {
return useContext(PlatformContext); return useContext(PlatformContext);
}; };
export { export {
PlatformProvider, PlatformProvider,
usePlatform usePlatform
}; };

View file

@ -28,4 +28,4 @@ const isMobile = ['ios', 'android'].includes(name);
export { export {
name, name,
isMobile, isMobile,
}; };

View file

@ -2,4 +2,4 @@ import { PlatformProvider, usePlatform } from './Platform';
export { export {
PlatformProvider, PlatformProvider,
usePlatform, usePlatform,
}; };

View file

@ -19,4 +19,4 @@ const useShell = () => {
}; };
}; };
export default useShell; export default useShell;

View file

@ -1,5 +1,7 @@
// Copyright (C) 2017-2023 Smart code 203358507 // Copyright (C) 2017-2023 Smart code 203358507
/* eslint-disable @typescript-eslint/no-empty-function */
const React = require('react'); const React = require('react');
const ToastContext = React.createContext({ const ToastContext = React.createContext({

View file

@ -5,4 +5,4 @@ declare const useBinaryState: (initialValue?: boolean) => [
() => void, () => void,
]; ];
export = useBinaryState; export = useBinaryState;

View file

@ -1,2 +1,2 @@
declare const useNotifcations: () => Notifications; declare const useNotifcations: () => Notifications;
export = useNotifcations; export = useNotifcations;

View file

@ -24,4 +24,4 @@ const useOutsideClick = (callback: () => void) => {
return ref; return ref;
}; };
export default useOutsideClick; export default useOutsideClick;

View file

@ -1,2 +1,2 @@
declare const useProfile: () => Profile; declare const useProfile: () => Profile;
export = useProfile; export = useProfile;

View file

@ -1,2 +1,2 @@
declare const useStreamingServer: () => StreamingServer; declare const useStreamingServer: () => StreamingServer;
export = useStreamingServer; export = useStreamingServer;

4
src/modules.d.ts vendored
View file

@ -1,6 +1,6 @@
declare module '*.less' { declare module '*.less' {
const resource: { [key: string]: string }; const resource: Record<string, string>;
export = resource; export = resource;
} }
declare module 'stremio/common/Button'; declare module 'stremio/common/Button';

View file

@ -1,2 +1,2 @@
declare const useInstalledAddons: (urlParams: UrlParams) => InstalledAddons; declare const useInstalledAddons: (urlParams: UrlParams) => InstalledAddons;
export = useInstalledAddons; export = useInstalledAddons;

View file

@ -1,2 +1,2 @@
declare const useRemoteAddons: (urlParams: UrlParams) => RemoteAddons; declare const useRemoteAddons: (urlParams: UrlParams) => RemoteAddons;
export = useRemoteAddons; export = useRemoteAddons;

View file

@ -1,2 +1,2 @@
declare const useBoard: () => [Board, ({ start, end }: { start: number, end: number }) => void]; declare const useBoard: () => [Board, ({ start, end }: { start: number, end: number }) => void];
export = useBoard; export = useBoard;

View file

@ -1,2 +1,2 @@
declare const useDiscover: (urlParams: UrlParams, searchParams: URLSearchParams) => [Discover, () => void]; declare const useDiscover: (urlParams: UrlParams, searchParams: URLSearchParams) => [Discover, () => void];
export = useDiscover; export = useDiscover;

View file

@ -1,2 +1,2 @@
declare const useLibrary: (model: string, urlParams: UrlParams, searchParams: URLSearchParams) => Library; declare const useLibrary: (model: string, urlParams: UrlParams, searchParams: URLSearchParams) => Library;
export = useLibrary; export = useLibrary;

View file

@ -1,2 +1,2 @@
declare const useMetaDetails: (urlParams: UrlParams) => MetaDetails; declare const useMetaDetails: (urlParams: UrlParams) => MetaDetails;
export = useMetaDetails; export = useMetaDetails;

View file

@ -1,2 +1,2 @@
declare const usePlayer: (urlParams: UrlParams, videoParams: any) => [Player, (time: number, duration: number, device: string) => void, (paused: boolean) => void, () => void, () => void]; declare const usePlayer: (urlParams: UrlParams, videoParams: any) => [Player, (time: number, duration: number, device: string) => void, (paused: boolean) => void, () => void, () => void];
export = usePlayer; export = usePlayer;

View file

@ -1,2 +1,2 @@
declare const useSettings: () => [Settings, (settings: any) => void]; declare const useSettings: () => [Settings, (settings: any) => void];
export = useSettings; export = useSettings;

View file

@ -1,2 +1,2 @@
declare const useSearch: (searchParams: URLSearchParams) => [Search, (range: number) => void]; declare const useSearch: (searchParams: URLSearchParams) => [Search, (range: number) => void];
export = useSearch; export = useSearch;

View file

@ -1,2 +1,2 @@
declare function Core(): Core; declare function Core(): Core;
export = Core; export = Core;

View file

@ -1,2 +1,2 @@
declare function CoreTransport(): CoreTransport; declare function CoreTransport(): CoreTransport;
export = CoreTransport; export = CoreTransport;

View file

@ -9,4 +9,4 @@ declare global {
} }
} }
export {}; export {};

View file

@ -25,4 +25,4 @@ interface CoreTransport {
interface Core { interface Core {
active: boolean, active: boolean,
transport: CoreTransport, transport: CoreTransport,
} }

View file

@ -25,7 +25,7 @@ function DragAndDrop({ core }) {
args: Array.from(new Uint8Array(torrent)) args: Array.from(new Uint8Array(torrent))
} }
}); });
} catch (error) { } catch (_error) {
events.emit('error', { events.emit('error', {
message: 'Failed to process file', message: 'Failed to process file',
file: { file: {

View file

@ -4,4 +4,4 @@ type ServicesContext = {
chromecast: any, chromecast: any,
keyboardShortcuts: any, keyboardShortcuts: any,
dragAndDrop: any, dragAndDrop: any,
}; };

View file

@ -1,2 +1,2 @@
declare const useService: () => ServicesContext; declare const useService: () => ServicesContext;
export = useService; export = useService;

View file

@ -45,6 +45,7 @@ function ShellTransport() {
this.props = {}; this.props = {};
// eslint-disable-next-line @typescript-eslint/no-this-alias
const shell = this; const shell = this;
initialize() initialize()
.then(() => { .then(() => {

View file

@ -17,4 +17,4 @@ type Addon = {
type AddonsDeepLinks = { type AddonsDeepLinks = {
addons: string, addons: string,
}; };

View file

@ -31,4 +31,4 @@ type LibraryItemDeepLinks = {
metaDetailsStreams: string | null, metaDetailsStreams: string | null,
player: string | null, player: string | null,
externalPlayer: ExternalPlayerLinks | null, externalPlayer: ExternalPlayerLinks | null,
}; };

View file

@ -29,4 +29,4 @@ type MetaItemDeepLinks = {
metaDetailsVideos: string | null, metaDetailsVideos: string | null,
metaDetailsStreams: string | null, metaDetailsStreams: string | null,
player: string | null, player: string | null,
}; };

View file

@ -24,4 +24,4 @@ type SelectableCatalog<T> = {
name: string, name: string,
selected: boolean, selected: boolean,
deepLinks: T, deepLinks: T,
}; };

View file

@ -15,4 +15,4 @@ type Stream = {
player: string, player: string,
externalPlayer: ExternalPlayerLinks, externalPlayer: ExternalPlayerLinks,
}, },
}; };

View file

@ -14,4 +14,4 @@ type Video = {
episode?: number, episode?: number,
streams: Stream[], streams: Stream[],
trailerStreams: TrailerStream[], trailerStreams: TrailerStream[],
}; };

View file

@ -1,3 +1,5 @@
/* eslint-disable no-var */
interface QtTransport { interface QtTransport {
send: (message: string) => void, send: (message: string) => void,
} }
@ -10,4 +12,4 @@ declare global {
var qt: Qt | undefined; var qt: Qt | undefined;
} }
export { }; export { };

View file

@ -1 +1 @@
type Board = CatalogsWithExtra; type Board = CatalogsWithExtra;

View file

@ -8,4 +8,4 @@ type CatalogsWithExtra = {
type: string | null, type: string | null,
extra: [string, string][] extra: [string, string][]
} | null, } | null,
}; };

View file

@ -71,4 +71,4 @@ type Ctx = {
profile: Profile, profile: Profile,
notifications: Notifications, notifications: Notifications,
searchHistory: SearchHistory, searchHistory: SearchHistory,
}; };

View file

@ -23,4 +23,4 @@ type Discover = {
selected: { selected: {
request: ResourceRequest, request: ResourceRequest,
} | null, } | null,
}; };

View file

@ -9,4 +9,4 @@ type InstalledAddons = {
type: string, type: string,
} }
} | null, } | null,
}; };

View file

@ -26,4 +26,4 @@ type Library = {
type: string | null, type: string | null,
} }
} | null, } | null,
}; };

View file

@ -7,4 +7,4 @@ type LocalSearchItem = {
type LocalSearch = { type LocalSearch = {
items: LocalSearchItem[], items: LocalSearchItem[],
}; };

View file

@ -24,4 +24,4 @@ type MetaDetails = {
content: Loadable<Stream[]> content: Loadable<Stream[]>
}[], }[],
title: string | null, title: string | null,
}; };

View file

@ -42,4 +42,4 @@ type Player = {
} | null, } | null,
subtitles: Subtitle[], subtitles: Subtitle[],
title: string | null, title: string | null,
}; };

View file

@ -7,4 +7,4 @@ type RemoteAddons = {
selected: { selected: {
request: ResourceRequest, request: ResourceRequest,
} | null, } | null,
}; };

View file

@ -1 +1 @@
type Search = CatalogsWithExtra; type Search = CatalogsWithExtra;

View file

@ -115,4 +115,4 @@ type StreamingServer = {
torrent: [string, Loadable<Torrent>] | null, torrent: [string, Loadable<Torrent>] | null,
statistics: Loadable<Statistics> | null, statistics: Loadable<Statistics> | null,
playbackDevices: Loadable<PlaybackDevice[]> | null, playbackDevices: Loadable<PlaybackDevice[]> | null,
}; };

View file

@ -51,7 +51,7 @@ type BehaviorHints = {
hasScheduledVideos: boolean, hasScheduledVideos: boolean,
}; };
type PosterShape = 'square' | 'landscape' | 'poster' | null; type PosterShape = 'square' | 'landscape' | 'poster' | null;
type Catalog<T, D = any> = { type Catalog<T, D = any> = {
label?: string, label?: string,
@ -60,4 +60,4 @@ type Catalog<T, D = any> = {
content: T, content: T,
installed?: boolean, installed?: boolean,
deepLinks?: D, deepLinks?: D,
}; };

View file

@ -194,7 +194,7 @@ module.exports = (env, argv) => ({
new CleanWebpackPlugin({ new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ['*'] cleanOnceBeforeBuildPatterns: ['*']
}), }),
argv.mode === 'production' && argv.mode === 'production' &&
new WorkboxPlugin.GenerateSW({ new WorkboxPlugin.GenerateSW({
maximumFileSizeToCacheInBytes: 20000000, maximumFileSizeToCacheInBytes: 20000000,
clientsClaim: true, clientsClaim: true,