mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-02-10 18:05:07 +08:00
[linter] manual-fix after merge
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Routes, Route } from 'react-router-dom';
|
||||
import { Provider } from 'react-redux';
|
||||
import './App.css';
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { fetchUser, selectUser, selectUserLoading, selectUserError, selectIsAuthenticated } from '../../store/slices/userSlice';
|
||||
import { fetchUser, selectUser, selectUserLoading, selectIsAuthenticated } from '../../store/slices/userSlice';
|
||||
import Spinner from '../../assets/Spinner.svg';
|
||||
import Login from '../../pages/Login';
|
||||
|
||||
@ -8,7 +8,6 @@ export default function AuthWrapper({ children }) {
|
||||
const dispatch = useDispatch();
|
||||
const user = useSelector(selectUser);
|
||||
const loading = useSelector(selectUserLoading);
|
||||
const error = useSelector(selectUserError);
|
||||
const isAuthenticated = useSelector(selectIsAuthenticated);
|
||||
const [hasInitialized, setHasInitialized] = useState(false);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useState, forwardRef } from 'react';
|
||||
import { useState, forwardRef } from 'react';
|
||||
import styles from './styles.module.css';
|
||||
import Spinner from '../../assets/Spinner.svg';
|
||||
import Success from '../../assets/Success.svg';
|
||||
@ -28,7 +28,7 @@ const Button = forwardRef(({
|
||||
setState('idle');
|
||||
setIsProcessing(false);
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
} catch (_error) {
|
||||
setState('error');
|
||||
|
||||
// Show error for 3 seconds
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { fetchConfiguration, updateConfiguration } from '../../api';
|
||||
import { getNestedValue } from '../../utils/getNestedValue';
|
||||
@ -12,7 +12,7 @@ import styles from './styles.module.css';
|
||||
|
||||
export default function Configuration() {
|
||||
const user = useSelector(selectUser);
|
||||
const [config, setConfig] = useState(null);
|
||||
const [, setConfig] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState(null);
|
||||
const [fieldValues, setFieldValues] = useState({});
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import Input from '../Input';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default function ExpandableSection({ title, children }) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { selectIsAuthenticated } from '../../store/slices/userSlice';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default function Input({
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default function InfoTable({ caption, editor, viewer, desc }) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default function TopBlock({ title, children }) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import TopBlock from './TopBlock/index';
|
||||
import InfoTable from './InfoTable/index';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default function Tabs({ tabs, activeTab, onTabChange, children }) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import { StrictMode } from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { BrowserRouter } from 'react-router-dom';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
@ -16,11 +16,11 @@ const queryClient = new QueryClient({
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</QueryClientProvider>
|
||||
</React.StrictMode>
|
||||
</StrictMode>
|
||||
);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import { useState } from 'react';
|
||||
import Statistics from '../components/Statistics';
|
||||
import Configuration from '../components/Configuration';
|
||||
import Tabs from '../components/Tabs';
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import React, { useState, useRef } from 'react';
|
||||
import { useState, useRef } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { loginUser } from '../../store/slices/userSlice';
|
||||
import Input from '../../components/Input';
|
||||
|
||||
@ -3,7 +3,7 @@ export function mergeNestedObjects(objects) {
|
||||
|
||||
for (const obj of objects) {
|
||||
for (const key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
if (Object.hasOwn(obj, key)) {
|
||||
const keys = key.split('.');
|
||||
let current = result;
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ module.exports = {
|
||||
use: {
|
||||
loader: "babel-loader",
|
||||
options: {
|
||||
presets: ["@babel/preset-react", "@babel/preset-env"],
|
||||
presets: [["@babel/preset-react", { runtime: "automatic" }], "@babel/preset-env"],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@ -25,8 +25,8 @@ router.get('/me', async (req, res) => {
|
||||
try {
|
||||
const decoded = jwt.verify(token, defaultTenantSecret);
|
||||
res.json(decoded);
|
||||
return;
|
||||
} catch (defaultError) {
|
||||
|
||||
} catch {
|
||||
if (tenantBaseDir && fs.existsSync(tenantBaseDir)) {
|
||||
const tenantList = fs.readdirSync(tenantBaseDir);
|
||||
for (const tenant of tenantList) {
|
||||
@ -35,14 +35,14 @@ router.get('/me', async (req, res) => {
|
||||
const decoded = jwt.verify(token, tenantSecret);
|
||||
res.json({ tenant: decoded.tenant, isAdmin: decoded.isAdmin });
|
||||
return;
|
||||
} catch (tenantError) {
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res.status(401).json({ error: 'Invalid token' });
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
});
|
||||
@ -64,7 +64,7 @@ router.post('/login', async (req, res) => {
|
||||
});
|
||||
|
||||
res.json({ tenant: tenant.tenant, isAdmin: tenant.isAdmin });
|
||||
} catch (error) {
|
||||
} catch {
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
@ -77,7 +77,7 @@ router.post('/logout', async (req, res) => {
|
||||
path: '/'
|
||||
});
|
||||
res.json({ message: 'Logged out successfully' });
|
||||
} catch (error) {
|
||||
} catch {
|
||||
res.status(500).json({ error: 'Internal server error' });
|
||||
}
|
||||
});
|
||||
|
||||
@ -15,10 +15,10 @@ const cookieParser = require('cookie-parser');
|
||||
const router = express.Router();
|
||||
router.use(cookieParser());
|
||||
|
||||
const rawFileParser = bodyParser.raw({ inflate: true, limit: config.get('services.CoAuthoring.server.limits_tempfile_upload'), type: function () { return true; } });
|
||||
const rawFileParser = bodyParser.raw({ inflate: true, limit: config.get('services.CoAuthoring.server.limits_tempfile_upload'), type () { return true; } });
|
||||
|
||||
const validateJWT = async (req, res, next) => {
|
||||
let ctx = new operationContext.Context();
|
||||
const ctx = new operationContext.Context();
|
||||
try {
|
||||
ctx.initFromRequest(req);
|
||||
await ctx.initTenantCache();
|
||||
@ -37,7 +37,7 @@ const validateJWT = async (req, res, next) => {
|
||||
req.user = decoded;
|
||||
req.ctx = ctx;
|
||||
return next();
|
||||
} catch (defaultError) {
|
||||
} catch {
|
||||
if (tenantBaseDir && fs.existsSync(tenantBaseDir)) {
|
||||
const tenantList = fs.readdirSync(tenantBaseDir);
|
||||
for (const tenant of tenantList) {
|
||||
@ -50,20 +50,20 @@ const validateJWT = async (req, res, next) => {
|
||||
req.user = decoded;
|
||||
req.ctx = ctx;
|
||||
return next();
|
||||
} catch (tenantError) {
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res.status(401).json({ error: 'Unauthorized - Invalid token' });
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
};
|
||||
|
||||
router.get('/', validateJWT, async (req, res) => {
|
||||
let ctx = req.ctx;
|
||||
const ctx = req.ctx;
|
||||
try {
|
||||
ctx.logger.debug('config get start');
|
||||
const filteredConfig = getFilteredConfig(ctx);
|
||||
@ -77,7 +77,7 @@ router.get('/', validateJWT, async (req, res) => {
|
||||
});
|
||||
|
||||
router.patch('/', validateJWT, rawFileParser, async (req, res) => {
|
||||
let ctx = req.ctx;
|
||||
const ctx = req.ctx;
|
||||
try {
|
||||
const currentConfig = ctx.getFullCfg();
|
||||
const updateData = JSON.parse(req.body);
|
||||
|
||||
@ -12,7 +12,6 @@ try {
|
||||
process.env.NODE_CONFIG = JSON.stringify({ log: { filePath: absLogCfgPath } });
|
||||
}
|
||||
const config = moduleReloader.requireConfigWithRuntime();
|
||||
const logger = require('../../../Common/sources/logger');
|
||||
const operationContext = require('../../../Common/sources/operationContext');
|
||||
const tenantManager = require('../../../Common/sources/tenantManager');
|
||||
const utils = require('../../../Common/sources/utils');
|
||||
@ -40,14 +39,14 @@ const corsWithCredentials = cors({
|
||||
|
||||
operationContext.global.logger.warn('AdminPanel server starting...');
|
||||
|
||||
const rawFileParser = bodyParser.raw(
|
||||
{ inflate: true, limit: config.get('services.CoAuthoring.server.limits_tempfile_upload'), type: function () { return true; } }
|
||||
const _rawFileParser = bodyParser.raw(
|
||||
{ inflate: true, limit: config.get('services.CoAuthoring.server.limits_tempfile_upload'), type () { return true; } }
|
||||
);
|
||||
|
||||
app.get('/info/info.json', cors(), utils.checkClientIp, async (req, res) => {
|
||||
const serverDate = new Date();
|
||||
serverDate.setMilliseconds(0);
|
||||
let output = {
|
||||
const output = {
|
||||
connectionsStat: {},
|
||||
licenseInfo: {},
|
||||
serverInfo: {
|
||||
@ -78,8 +77,8 @@ app.get('/info/info.json', cors(), utils.checkClientIp, async (req, res) => {
|
||||
app.use('/info/config', corsWithCredentials, utils.checkClientIp, configRouter);
|
||||
app.use('/info/adminpanel', corsWithCredentials, utils.checkClientIp, adminpanelRouter);
|
||||
|
||||
app.use((err, req, res, next) => {
|
||||
let ctx = new operationContext.Context();
|
||||
app.use((err, req, res) => {
|
||||
const ctx = new operationContext.Context();
|
||||
ctx.initFromRequest(req);
|
||||
ctx.logger.error('default error handler:%s', err.stack);
|
||||
res.sendStatus(500);
|
||||
|
||||
@ -1471,7 +1471,7 @@ exports.watchWithFallback = async function watchWithFallback(ctx, dirPath, fileP
|
||||
*/
|
||||
function getImpl(object, property) {
|
||||
//from https://github.com/node-config/node-config/blob/a8b91ac86b499d11b90974a2c9915ce31266044a/lib/config.js#L137
|
||||
var t = this,
|
||||
const _t = this,
|
||||
elems = Array.isArray(property) ? property : property.split('.'),
|
||||
name = elems[0],
|
||||
value = object[name];
|
||||
|
||||
@ -38,12 +38,10 @@ const tenantBaseDir = config.get('tenants.baseDir');
|
||||
// const isMultitenantMode = config.get('tenants.isMultitenantMode');
|
||||
const defaultTenantSecret = config.get('services.CoAuthoring.secret.browser.string');
|
||||
const filenameSecret = config.get('tenants.filenameSecret');
|
||||
const tenantManager = require('../../../../Common/sources/tenantManager');
|
||||
const jwt = require('jsonwebtoken');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cookieParser = require('cookie-parser');
|
||||
const commonDefines = require('../../../../Common/sources/commondefines');
|
||||
|
||||
|
||||
const router = express.Router();
|
||||
@ -65,8 +63,8 @@ router.get('/me', async (req, res) => {
|
||||
try {
|
||||
const decoded = jwt.verify(token, defaultTenantSecret);
|
||||
res.json(decoded);
|
||||
return;
|
||||
} catch (defaultError) {
|
||||
|
||||
} catch {
|
||||
// If default secret fails, try to find the tenant and verify with their secret
|
||||
const tenantList = fs.readdirSync(tenantBaseDir);
|
||||
for (const tenant of tenantList) {
|
||||
@ -78,7 +76,7 @@ router.get('/me', async (req, res) => {
|
||||
isAdmin: decoded.isAdmin
|
||||
});
|
||||
return;
|
||||
} catch (tenantError) {
|
||||
} catch {
|
||||
// Continue to next tenant
|
||||
continue;
|
||||
}
|
||||
@ -93,7 +91,7 @@ router.get('/me', async (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/login', async (req, res) => {
|
||||
let ctx = new operationContext.Context();
|
||||
const ctx = new operationContext.Context();
|
||||
ctx.initDefault()
|
||||
try {
|
||||
const { secret } = req.body;
|
||||
|
||||
@ -3,6 +3,8 @@ const globals = require('globals');
|
||||
const prettier = require('eslint-config-prettier');
|
||||
const {includeIgnoreFile} = require('@eslint/compat');
|
||||
const path = require('node:path');
|
||||
const react = require('eslint-plugin-react');
|
||||
const reactHooks = require('eslint-plugin-react-hooks');
|
||||
|
||||
const gitignorePath = path.resolve(__dirname, '.gitignore');
|
||||
|
||||
@ -65,5 +67,22 @@ module.exports = [
|
||||
'max-lines': ['warn', 5000]
|
||||
}
|
||||
},
|
||||
{
|
||||
files: ['AdminPanel/client/**/*.{js,jsx}'],
|
||||
plugins: {react, 'react-hooks': reactHooks},
|
||||
languageOptions: {
|
||||
ecmaVersion: 2022,
|
||||
sourceType: 'module',
|
||||
parserOptions: {ecmaFeatures: {jsx: true}},
|
||||
globals: {...globals.browser, ...globals.es2022}
|
||||
},
|
||||
settings: {react: {version: 'detect'}},
|
||||
rules: {
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/jsx-uses-vars': 'error',
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn'
|
||||
}
|
||||
},
|
||||
prettier
|
||||
];
|
||||
|
||||
11836
npm-shrinkwrap.json
generated
11836
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
@ -15,6 +15,8 @@
|
||||
"cross-env": "7.0.3",
|
||||
"eslint": "9.16.0",
|
||||
"eslint-config-prettier": "10.1.8",
|
||||
"eslint-plugin-react": "^7.37.2",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"express": "4.21.2",
|
||||
"globals": "15.12.0",
|
||||
"husky": "^9.1.7",
|
||||
|
||||
Reference in New Issue
Block a user