Migrate to tslint 5.1.0

This commit is contained in:
Aya Morisawa 2017-04-14 20:45:37 +09:00
parent 798d1610f0
commit b095efaee5
16 changed files with 107 additions and 95 deletions

View file

@ -32,7 +32,7 @@ module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) =
} else {
const select = {};
if (key !== null) {
select['data.' + key] = true;
select[`data.${key}`] = true;
}
const appdata = await Appdata.findOne({
app_id: app._id,

View file

@ -37,10 +37,10 @@ module.exports = (params, user, app, isSecure) => new Promise(async (res, rej) =
let set = {};
if (data) {
Object.entries(data).forEach(([k, v]) => {
set['data.' + k] = v;
set[`data.${k}`] = v;
});
} else {
set['data.' + key] = value;
set[`data.${key}`] = value;
}
if (isSecure) {

View file

@ -67,7 +67,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
res();
const inc = {};
inc['reaction_counts.' + reaction] = 1;
inc[`reaction_counts.${reaction}`] = 1;
// Increment reactions count
await Post.update({ _id: post._id }, {

View file

@ -51,7 +51,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
res();
const dec = {};
dec['reaction_counts.' + exist.reaction] = -1;
dec[`reaction_counts.${exist.reaction}`] = -1;
// Decrement reactions count
Post.update({ _id: post._id }, {

View file

@ -58,7 +58,7 @@ export default async (req: express.Request, res: express.Response) => {
const hash = bcrypt.hashSync(password, salt);
// Generate secret
const secret = '!' + rndstr('a-zA-Z0-9', 32);
const secret = `!${rndstr('a-zA-Z0-9', 32)}`;
// Create account
const account = await User.insert({

View file

@ -34,10 +34,10 @@ app.get('/', (req, res) => {
*/
endpoints.forEach(endpoint =>
endpoint.withFile ?
app.post('/' + endpoint.name,
app.post(`/${endpoint.name}`,
endpoint.withFile ? multer({ dest: 'uploads/' }).single('file') : null,
require('./api-handler').default.bind(null, endpoint)) :
app.post('/' + endpoint.name,
app.post(`/${endpoint.name}`,
require('./api-handler').default.bind(null, endpoint))
);

View file

@ -22,7 +22,7 @@ module.exports = async (app: express.Application) => {
const handler = new EventEmitter();
app.post('/hooks/github', (req, res, next) => {
if ((new Buffer(req.headers['x-hub-signature'])).equals(new Buffer('sha1=' + crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')))) {
if ((new Buffer(req.headers['x-hub-signature'])).equals(new Buffer(`sha1=${crypto.createHmac('sha1', config.github_bot.hook_secret).update(JSON.stringify(req.body)).digest('hex')}`))) {
handler.emit(req.headers['x-github-event'], req.body);
res.sendStatus(200);
} else {
@ -40,7 +40,7 @@ module.exports = async (app: express.Application) => {
// Fetch parent status
request({
url: parent.url + '/statuses',
url: `${parent.url}/statuses`,
headers: {
'User-Agent': 'misskey'
}

View file

@ -38,7 +38,7 @@ module.exports = (app: express.Application) => {
const twAuth = autwh({
consumerKey: config.twitter.consumer_key,
consumerSecret: config.twitter.consumer_secret,
callbackUrl: config.api_url + '/tw/cb'
callbackUrl: `${config.api_url}/tw/cb`
});
app.get('/connect/twitter', async (req, res): Promise<any> => {

View file

@ -24,7 +24,7 @@ app.use(cors());
/**
* Statics
*/
app.use('/assets', express.static(__dirname + '/assets', {
app.use('/assets', express.static(`${__dirname}/assets`, {
maxAge: 1000 * 60 * 60 * 24 * 365 // 一年
}));
@ -33,12 +33,12 @@ app.get('/', (req, res) => {
});
app.get('/default-avatar.jpg', (req, res) => {
const file = fs.readFileSync(__dirname + '/assets/avatar.jpg');
const file = fs.readFileSync(`${__dirname}/assets/avatar.jpg`);
send(file, 'image/jpeg', req, res);
});
app.get('/app-default.jpg', (req, res) => {
const file = fs.readFileSync(__dirname + '/assets/dummy.png');
const file = fs.readFileSync(`${__dirname}/assets/dummy.png`);
send(file, 'image/png', req, res);
});
@ -54,7 +54,7 @@ async function raw(data: Buffer, type: string, download: boolean, res: express.R
async function thumbnail(data: Buffer, type: string, resize: number, res: express.Response): Promise<any> {
if (!/^image\/.*$/.test(type)) {
data = fs.readFileSync(__dirname + '/assets/dummy.png');
data = fs.readFileSync(`${__dirname}/assets/dummy.png`);
}
let g = gm(data);
@ -100,7 +100,7 @@ app.get('/:id', async (req, res) => {
const file = await File.findOne({ _id: new mongodb.ObjectID(req.params.id) });
if (file == null) {
res.status(404).sendFile(__dirname + '/assets/dummy.png');
res.status(404).sendFile(`${__dirname} / assets / dummy.png`);
return;
} else if (file.data == null) {
res.sendStatus(400);
@ -120,7 +120,7 @@ app.get('/:id/:name', async (req, res) => {
const file = await File.findOne({ _id: new mongodb.ObjectID(req.params.id) });
if (file == null) {
res.status(404).sendFile(__dirname + '/assets/dummy.png');
res.status(404).sendFile(`${__dirname}/assets/dummy.png`);
return;
} else if (file.data == null) {
res.sendStatus(400);

View file

@ -13,11 +13,11 @@ app.disable('x-powered-by');
app.locals.cache = true;
app.get('/himasaku.png', (req, res) => {
res.sendFile(__dirname + '/assets/himasaku.png');
res.sendFile(`${__dirname}/assets/himasaku.png`);
});
app.get('*', (req, res) => {
res.sendFile(__dirname + '/assets/index.html');
res.sendFile(`${__dirname}/assets/index.html`);
});
module.exports = app;

View file

@ -52,7 +52,7 @@ export default class extends ev.EventEmitter {
private render(): string {
const width = 30;
const t = this.text ? this.text + ' ' : '';
const t = this.text ? `${this.text} ` : '';
const v = Math.floor((this.value / this.max) * width);
const vs = new Array(v + 1).join('*');

View file

@ -38,8 +38,8 @@ app.use((req, res, next) => {
* Static assets
*/
app.use(favicon(`${__dirname}/assets/favicon.ico`));
app.get('/manifest.json', (req, res) => res.sendFile(__dirname + '/assets/manifest.json'));
app.get('/apple-touch-icon.png', (req, res) => res.sendFile(__dirname + '/assets/apple-touch-icon.png'));
app.get('/manifest.json', (req, res) => res.sendFile(`${__dirname}/assets/manifest.json`));
app.get('/apple-touch-icon.png', (req, res) => res.sendFile(`${__dirname}/assets/apple-touch-icon.png`));
app.use('/assets', express.static(`${__dirname}/assets`, {
maxAge: ms('7 days')
}));

View file

@ -63,6 +63,7 @@
true,
"check-function-in-method"
],
"no-misused-new": true,
"no-null-keyword": false,
"no-shadowed-variable": false,
"no-string-literal": false,
@ -92,7 +93,10 @@
"no-default-export": false,
"no-mergeable-namespace": true,
"no-require-imports": false,
"no-reference-import": true,
"no-trailing-whitespace": true,
"no-unnecessary-callback-wrapper": true,
"no-unnecessary-initializer": true,
"object-literal-sort-keys": false,
"trailing-comma": true,
// Style
@ -102,8 +106,12 @@
"statements"
],
"arrow-parens": false,
"arrow-return-shorthand": true,
"class-name": true,
"comment-format": false,
"comment-format": [
true,
"check-space"
],
"interface-name": false,
"jsdoc-format": true,
"match-default-export-name": false,
@ -122,6 +130,9 @@
],
"one-variable-per-declaration": true,
"ordered-imports": false,
"prefer-function-over-method": true,
"prefer-method-signature": true,
"prefer-template": true,
"quotemark": [
true,
"single",
@ -135,7 +146,8 @@
"check-decl",
"check-operator",
"check-separator",
"check-type"
"check-type",
"check-preblock"
]
}
}