refactor: lint

main
Barış Soner Uşaklı 3 years ago
parent 44fc76af8f
commit e9110563c7

@ -0,0 +1,3 @@
{
"extends": "nodebb/lib"
}

@ -1,43 +1,38 @@
'use strict'; 'use strict';
var meta = require.main.require('./src/meta'); const meta = require.main.require('./src/meta');
var user = require.main.require('./src/user'); const user = require.main.require('./src/user');
var library = {}; const library = module.exports;
library.init = function(params, callback) {
var app = params.router;
var middleware = params.middleware;
library.init = async function (params) {
const { app, middleware } = params;
app.get('/admin/plugins/persona', middleware.admin.buildHeader, renderAdmin); app.get('/admin/plugins/persona', middleware.admin.buildHeader, renderAdmin);
app.get('/api/admin/plugins/persona', renderAdmin); app.get('/api/admin/plugins/persona', renderAdmin);
callback();
}; };
library.addAdminNavigation = function(header, callback) { library.addAdminNavigation = async function (header) {
header.plugins.push({ header.plugins.push({
route: '/plugins/persona', route: '/plugins/persona',
icon: 'fa-paint-brush', icon: 'fa-paint-brush',
name: 'Persona Theme' name: 'Persona Theme',
}); });
return header;
callback(null, header);
}; };
library.defineWidgetAreas = function(areas, callback) { library.defineWidgetAreas = async function (areas) {
const locations = ['header', 'sidebar', 'footer']; const locations = ['header', 'sidebar', 'footer'];
const templates = [ const templates = [
'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl', 'categories.tpl', 'category.tpl', 'topic.tpl', 'users.tpl',
'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl' 'unread.tpl', 'recent.tpl', 'popular.tpl', 'top.tpl', 'tags.tpl', 'tag.tpl',
]; ];
function capitalizeFirst(str) { function capitalizeFirst(str) {
return str.charAt(0).toUpperCase() + str.slice(1) return str.charAt(0).toUpperCase() + str.slice(1);
} }
templates.forEach(template => { templates.forEach((template) => {
locations.forEach(location => { locations.forEach((location) => {
areas.push({ areas.push({
name: capitalizeFirst(template.split('.')[0]) + ' ' + capitalizeFirst(location), name: `${capitalizeFirst(template.split('.')[0])} ${capitalizeFirst(location)}`,
template: template, template: template,
location: location, location: location,
}); });
@ -46,13 +41,12 @@ library.defineWidgetAreas = function(areas, callback) {
areas = areas.concat([ areas = areas.concat([
{ {
name: "Account Header", name: 'Account Header',
template: "account/profile.tpl", template: 'account/profile.tpl',
location: "header" location: 'header',
}, },
]); ]);
return areas;
callback(null, areas);
}; };
library.getThemeConfig = async function (config) { library.getThemeConfig = async function (config) {
@ -63,7 +57,7 @@ library.getThemeConfig = async function(config) {
return config; return config;
}; };
function renderAdmin(req, res, next) { function renderAdmin(req, res) {
res.render('admin/plugins/persona', {}); res.render('admin/plugins/persona', {});
} }

@ -10,6 +10,9 @@
"type": "git", "type": "git",
"url": "https://github.com/psychobunny/nodebb-theme-persona" "url": "https://github.com/psychobunny/nodebb-theme-persona"
}, },
"scripts": {
"lint": "eslint ."
},
"keywords": [ "keywords": [
"nodebb", "nodebb",
"theme", "theme",
@ -41,5 +44,10 @@
"dependencies": { "dependencies": {
"pulling": "^2.0.0", "pulling": "^2.0.0",
"striptags": "^3.2.0" "striptags": "^3.2.0"
},
"devDependencies": {
"eslint": "^7.32.0",
"eslint-config-nodebb": "^0.0.2",
"eslint-plugin-import": "^2.24.2"
} }
} }

@ -0,0 +1,3 @@
{
"extends": "nodebb/public"
}
Loading…
Cancel
Save