From 23eede4d2ff0e613910cb33b878bd8743eedba11 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Thu, 29 Sep 2022 12:50:25 -0400 Subject: [PATCH] Only allow jsx in jsx/tsx files --- .eslintrc.js | 5 +- src/{scripts/site.js => index.jsx} | 92 +++++++++++++++--------------- webpack.dev.js | 2 +- webpack.prod.js | 2 +- 4 files changed, 52 insertions(+), 49 deletions(-) rename src/{scripts/site.js => index.jsx} (78%) diff --git a/.eslintrc.js b/.eslintrc.js index b42920ef9..d3796446d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -64,7 +64,9 @@ module.exports = { 'space-before-blocks': ['error'], 'space-infix-ops': 'error', 'yoda': 'error', - 'no-sequences': ['error', { 'allowInParentheses': false }] + 'no-sequences': ['error', { 'allowInParentheses': false }], + + 'react/jsx-filename-extension': ['error', { 'extensions': ['.jsx', '.tsx'] }] }, settings: { react: { @@ -180,6 +182,7 @@ module.exports = { { files: [ './src/**/*.js', + './src/**/*.jsx', './src/**/*.ts' ], parser: '@babel/eslint-parser', diff --git a/src/scripts/site.js b/src/index.jsx similarity index 78% rename from src/scripts/site.js rename to src/index.jsx index edf2dab2c..7ca4b92a2 100644 --- a/src/scripts/site.js +++ b/src/index.jsx @@ -6,44 +6,44 @@ import 'intersection-observer'; import 'classlist.js'; import 'whatwg-fetch'; import 'resize-observer-polyfill'; -import '../assets/css/site.scss'; +import './assets/css/site.scss'; import React from 'react'; import * as ReactDOM from 'react-dom'; import { Events } from 'jellyfin-apiclient'; -import ServerConnections from '../components/ServerConnections'; -import globalize from './globalize'; -import browser from './browser'; -import keyboardNavigation from './keyboardNavigation'; -import './mouseManager'; -import autoFocuser from '../components/autoFocuser'; -import { appHost } from '../components/apphost'; -import { getPlugins } from './settings/webSettings'; -import { pluginManager } from '../components/pluginManager'; -import packageManager from '../components/packageManager'; -import { appRouter, history } from '../components/appRouter'; -import '../elements/emby-button/emby-button'; -import './autoThemes'; -import './libraryMenu'; -import './routes'; -import '../components/themeMediaPlayer'; -import './autoBackdrops'; -import { pageClassOn, serverAddress } from '../utils/dashboard'; -import './screensavermanager'; -import './serverNotifications'; -import '../components/playback/playerSelectionMenu'; -import '../legacy/domParserTextHtml'; -import '../legacy/focusPreventScroll'; -import '../legacy/htmlMediaElement'; -import '../legacy/vendorStyles'; -import SyncPlay from '../components/syncPlay/core'; -import { playbackManager } from '../components/playback/playbackmanager'; -import SyncPlayNoActivePlayer from '../components/syncPlay/ui/players/NoActivePlayer'; -import SyncPlayHtmlVideoPlayer from '../components/syncPlay/ui/players/HtmlVideoPlayer'; -import SyncPlayHtmlAudioPlayer from '../components/syncPlay/ui/players/HtmlAudioPlayer'; -import { currentSettings } from './settings/userSettings'; -import taskButton from './taskbutton'; -import { HistoryRouter } from '../components/HistoryRouter.tsx'; -import AppRoutes from '../routes/index.tsx'; +import ServerConnections from './components/ServerConnections'; +import globalize from './scripts/globalize'; +import browser from './scripts/browser'; +import keyboardNavigation from './scripts/keyboardNavigation'; +import './scripts/mouseManager'; +import autoFocuser from './components/autoFocuser'; +import { appHost } from './components/apphost'; +import { getPlugins } from './scripts/settings/webSettings'; +import { pluginManager } from './components/pluginManager'; +import packageManager from './components/packageManager'; +import { appRouter, history } from './components/appRouter'; +import './elements/emby-button/emby-button'; +import './scripts/autoThemes'; +import './scripts/libraryMenu'; +import './scripts/routes'; +import './components/themeMediaPlayer'; +import './scripts/autoBackdrops'; +import { pageClassOn, serverAddress } from './utils/dashboard'; +import './scripts/screensavermanager'; +import './scripts/serverNotifications'; +import './components/playback/playerSelectionMenu'; +import './legacy/domParserTextHtml'; +import './legacy/focusPreventScroll'; +import './legacy/htmlMediaElement'; +import './legacy/vendorStyles'; +import SyncPlay from './components/syncPlay/core'; +import { playbackManager } from './components/playback/playbackmanager'; +import SyncPlayNoActivePlayer from './components/syncPlay/ui/players/NoActivePlayer'; +import SyncPlayHtmlVideoPlayer from './components/syncPlay/ui/players/HtmlVideoPlayer'; +import SyncPlayHtmlAudioPlayer from './components/syncPlay/ui/players/HtmlAudioPlayer'; +import { currentSettings } from './scripts/settings/userSettings'; +import taskButton from './scripts/taskbutton'; +import { HistoryRouter } from './components/HistoryRouter.tsx'; +import AppRoutes from './routes/index.tsx'; function loadCoreDictionary() { const languages = ['af', 'ar', 'be-by', 'bg-bg', 'bn_bd', 'ca', 'cs', 'cy', 'da', 'de', 'el', 'en-gb', 'en-us', 'eo', 'es', 'es-419', 'es-ar', 'es_do', 'es-mx', 'et', 'fa', 'fi', 'fil', 'fr', 'fr-ca', 'gl', 'gsw', 'he', 'hi-in', 'hr', 'hu', 'id', 'it', 'ja', 'kk', 'ko', 'lt-lt', 'lv', 'mr', 'ms', 'nb', 'nl', 'nn', 'pl', 'pr', 'pt', 'pt-br', 'pt-pt', 'ro', 'ru', 'sk', 'sl-si', 'sq', 'sv', 'ta', 'th', 'tr', 'uk', 'ur_pk', 'vi', 'zh-cn', 'zh-hk', 'zh-tw']; @@ -94,13 +94,13 @@ function onGlobalizeInit() { if (browser.tv && !browser.android) { console.debug('using system fonts with explicit sizes'); - import('../assets/css/fonts.sized.scss'); + import('./assets/css/fonts.sized.scss'); } else { console.debug('using default fonts'); - import('../assets/css/fonts.scss'); + import('./assets/css/fonts.scss'); } - import('../assets/css/librarybrowser.scss'); + import('./assets/css/librarybrowser.scss'); loadPlugins().then(function () { initSyncPlay(); @@ -164,7 +164,7 @@ async function onAppReady() { console.debug('onAppReady: loading dependencies'); if (browser.iOS) { - import('../assets/css/ios.scss'); + import('./assets/css/ios.scss'); } Events.on(appHost, 'resume', () => { @@ -181,29 +181,29 @@ async function onAppReady() { ); if (!browser.tv && !browser.xboxOne && !browser.ps4) { - import('../components/nowPlayingBar/nowPlayingBar'); + import('./components/nowPlayingBar/nowPlayingBar'); } if (appHost.supports('remotecontrol')) { - import('../components/playback/playerSelectionMenu'); - import('../components/playback/remotecontrolautoplay'); + import('./components/playback/playerSelectionMenu'); + import('./components/playback/remotecontrolautoplay'); } if (!appHost.supports('physicalvolumecontrol') || browser.touch) { - import('../components/playback/volumeosd'); + import('./components/playback/volumeosd'); } /* eslint-disable-next-line compat/compat */ if (navigator.mediaSession || window.NativeShell) { - import('../components/playback/mediasession'); + import('./components/playback/mediasession'); } if (!browser.tv && !browser.xboxOne) { - import('../components/playback/playbackorientation'); + import('./components/playback/playbackorientation'); registerServiceWorker(); if (window.Notification) { - import('../components/notifications/notifications'); + import('./components/notifications/notifications'); } } diff --git a/webpack.dev.js b/webpack.dev.js index 8cfa98f2f..a6288a80c 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -5,7 +5,7 @@ module.exports = merge(common, { // In order for live reload to work we must use "web" as the target not "browserslist" target: process.env.WEBPACK_SERVE ? 'web' : 'browserslist', mode: 'development', - entry: { 'main.jellyfin': './scripts/site.js' }, + entry: { 'main.jellyfin': './index.jsx' }, devtool: 'eval-cheap-module-source-map', module: { rules: [ diff --git a/webpack.prod.js b/webpack.prod.js index f87e9b429..a0fd04b5b 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -5,7 +5,7 @@ const WorkboxPlugin = require('workbox-webpack-plugin'); module.exports = merge(common, { mode: 'production', - entry: { 'main.jellyfin': './scripts/site.js' }, + entry: { 'main.jellyfin': './index.jsx' }, plugins: [ new WorkboxPlugin.InjectManifest({ swSrc: path.resolve(__dirname, 'src/serviceworker.js'),