Add eslint (#741)
This commit is contained in:
parent
953428cad5
commit
62417f7fb8
72 changed files with 305 additions and 323 deletions
|
|
@ -4,6 +4,7 @@ import Config from '../config';
|
|||
import db from '../database';
|
||||
import { DatabaseStore } from './dbstore';
|
||||
|
||||
/* eslint no-console: off */
|
||||
function main() {
|
||||
Config.load('config.yaml');
|
||||
db.init();
|
||||
|
|
|
|||
|
|
@ -106,10 +106,12 @@ export class DatabaseStore {
|
|||
|
||||
if (totalSize > SIZE_LIMIT) {
|
||||
throw new ChannelStateSizeError(
|
||||
'Channel state size is too large', {
|
||||
limit: SIZE_LIMIT,
|
||||
actual: totalSize
|
||||
});
|
||||
'Channel state size is too large',
|
||||
{
|
||||
limit: SIZE_LIMIT,
|
||||
actual: totalSize
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
saveRowcount.inc(rowCount);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,14 @@ export class FileStore {
|
|||
return statAsync(filename).then(stats => {
|
||||
if (stats.size > SIZE_LIMIT) {
|
||||
return Promise.reject(
|
||||
new ChannelStateSizeError('Channel state file is too large', {
|
||||
limit: SIZE_LIMIT,
|
||||
actual: stats.size
|
||||
}));
|
||||
new ChannelStateSizeError(
|
||||
'Channel state file is too large',
|
||||
{
|
||||
limit: SIZE_LIMIT,
|
||||
actual: stats.size
|
||||
}
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return readFileAsync(filename);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import { DatabaseStore } from './dbstore';
|
|||
import { sanitizeHTML } from '../xss';
|
||||
import { ChannelNotFoundError } from '../errors';
|
||||
|
||||
const QUERY_CHANNEL_NAMES = 'SELECT name FROM channels WHERE 1';
|
||||
/* eslint no-console: off */
|
||||
|
||||
const EXPECTED_KEYS = [
|
||||
'chatbuffer',
|
||||
'chatmuted',
|
||||
|
|
@ -22,21 +23,6 @@ const EXPECTED_KEYS = [
|
|||
'poll'
|
||||
];
|
||||
|
||||
function queryAsync(query, substitutions) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.query(query, substitutions, (err, res) => {
|
||||
if (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
err = new Error(err);
|
||||
}
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function fixOldChandump(data) {
|
||||
const converted = {};
|
||||
EXPECTED_KEYS.forEach(key => {
|
||||
|
|
@ -146,7 +132,7 @@ function migrate(src, dest, opts) {
|
|||
return dest.save(name, data);
|
||||
}).then(() => {
|
||||
console.log(`Migrated /${chanPath}/${name}`);
|
||||
}).catch(ChannelNotFoundError, err => {
|
||||
}).catch(ChannelNotFoundError, _err => {
|
||||
console.log(`Skipping /${chanPath}/${name} (not present in the database)`);
|
||||
}).catch(err => {
|
||||
console.error(`Failed to migrate /${chanPath}/${name}: ${err.stack}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue