chore: update eslint

This commit is contained in:
Tim 2024-10-07 12:17:33 +02:00
parent 251878bb69
commit e51e6f415e
67 changed files with 2090 additions and 672 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/preset-env": "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/react": "^18.2.9",
"babel-loader": "8.2.3",
@ -58,8 +61,9 @@
"css-loader": "6.5.0",
"cssnano": "5.0.8",
"cssnano-preset-advanced": "5.1.4",
"eslint": "7.32.0",
"eslint-plugin-react": "7.26.1",
"eslint": "^9.12.0",
"eslint-plugin-react": "^7.37.1",
"globals": "^15.10.0",
"html-webpack-plugin": "5.5.0",
"jest": "27.3.1",
"less": "4.1.2",
@ -70,6 +74,7 @@
"terser-webpack-plugin": "5.2.4",
"ts-loader": "^9.5.1",
"typescript": "^5.4.2",
"typescript-eslint": "^8.8.0",
"webpack": "5.61.0",
"webpack-cli": "4.9.1",
"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
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
import Chips from './Chips';
export default Chips;
export default Chips;

View file

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

View file

@ -17,7 +17,8 @@ const DelayedRenderer = ({ children, delay }) => {
};
DelayedRenderer.propTypes = {
children: PropTypes.node
children: PropTypes.node,
delay: PropTypes.number,
};
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']} />
{t('BACK')}
</Button>
: null
: null
}
{
options
@ -46,10 +46,9 @@ const Dropdown = ({ level, setLevel, options, onSelect, selectedOption, menuOpen
/>
))
}
</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';
export default Option;
export default Option;

View file

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

View file

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

View file

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

View file

@ -1,2 +1,2 @@
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 };
export = useSearchHistory;
export = useSearchHistory;

View file

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

View file

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

View file

@ -2,4 +2,4 @@ import { PlatformProvider, usePlatform } from './Platform';
export {
PlatformProvider,
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
/* eslint-disable @typescript-eslint/no-empty-function */
const React = require('react');
const ToastContext = React.createContext({

View file

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

View file

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

View file

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

View file

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

2
src/modules.d.ts vendored
View file

@ -1,3 +1,3 @@
declare module '*.less';
declare module 'stremio/common';
declare module 'stremio/common/*';
declare module 'stremio/common/*';

View file

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

View file

@ -1,2 +1,2 @@
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];
export = useBoard;
export = useBoard;

View file

@ -1,2 +1,2 @@
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;
export = useLibrary;
export = useLibrary;

View file

@ -1,2 +1,2 @@
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];
export = usePlayer;
export = usePlayer;

View file

@ -1,2 +1,2 @@
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];
export = useSearch;
export = useSearch;

View file

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

View file

@ -1,2 +1,2 @@
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 {
active: boolean,
transport: CoreTransport,
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,3 +1,5 @@
/* eslint-disable no-var */
interface QtTransport {
send: (message: string) => void,
}
@ -10,4 +12,4 @@ declare global {
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,
extra: [string, string][]
} | null,
};
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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