Skip to content

Commit

Permalink
Fix lint issues (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
wil92 committed May 1, 2023
1 parent c101299 commit a76d64a
Show file tree
Hide file tree
Showing 25 changed files with 101 additions and 65 deletions.
2 changes: 1 addition & 1 deletion config/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = ({ env }) => ({
module.exports = (/*{ env }*/) => ({
responses: {
// privateAttributes: ['_v', 'id', 'created_at'],
},
Expand Down
2 changes: 1 addition & 1 deletion config/cron-tasks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
'0 18 * * 5': async ({strapi}) => {
'0 18 * * 5': async (/*{strapi}*/) => {
// Every Friday at 6pm
// await deliveryToEmailSubscriptions.send('Binary Coffee Weekly Posts', 7);
console.log('send weekly email');
Expand Down
2 changes: 1 addition & 1 deletion config/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const cronTasks = require("./cron-tasks");
// const cronTasks = require('./cron-tasks');

module.exports = ({env}) => ({
host: env('HOST', '0.0.0.0'),
Expand Down
36 changes: 36 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@
"moment": "^2.26.0",
"moment-timezone": "^0.5.31",
"mysql": "^2.18.1",
"pre-push": "^0.1.1",
"svg-captcha": "^1.4.0"
},
"description": "Binary Coffee backend",
"devDependencies": {
"babel-eslint": "^10.1.0",
"better-sqlite3": "^8.3.0",
"chai": "^4.2.0",
"chai-http": "^4.3.0",
"chai-spies": "^1.0.0",
"mocha": "^10.2.0",
"nyc": "^15.0.0"
"nyc": "^15.0.0",
"pre-push": "^0.1.1"
},
"engines": {
"node": ">=14.0.0",
Expand All @@ -50,7 +51,7 @@
"test": "NODE_ENV=test nyc --reporter=lcov --reporter=html mocha --ui bdd tests/bootstrap.js tests/integration/**/*.js tests/unit/**/*.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"check": "npm run test:cov && npm run lint && npm run build"
"check": "npm test && npm run lint && npm run build"
},
"strapi": {
"uuid": "b8aa7baf-d6dc-4c50-93d4-7739bc88c3fd"
Expand Down
2 changes: 1 addition & 1 deletion src/api/comment/config/schema.graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = (strapi) => {

args: { limit: 'Int' },

resolve(parent, args, context) {
resolve(parent, args) {
const { limit } = args;
return strapi.service('api::comment.comment').recentComments(limit);
}
Expand Down
8 changes: 4 additions & 4 deletions src/api/comment/routes/comment-extra.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
routes: [
{
method: "GET",
path: "/recentComments",
handler: "comment.recentComments",
method: 'GET',
path: '/recentComments',
handler: 'comment.recentComments',
}
]
}
};
2 changes: 1 addition & 1 deletion src/api/image/controllers/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const {createCoreController} = require('@strapi/strapi').factories;

module.exports = createCoreController('api::image.image', ({strapi}) => ({
module.exports = createCoreController('api::image.image', () => ({
findExtra(ctx) {
return super.find(ctx);
}
Expand Down
5 changes: 1 addition & 4 deletions src/api/podcast/config/schema.graphql.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const canRemove = require("../../comment/policies/canRemove");
const canComment = require("../../comment/policies/canComment");
const canUpdateComment = require("../../comment/policies/canUpdateComment");
module.exports = (strapi) => {
const extensionService = strapi.plugin('graphql').service('extension');

Expand All @@ -12,7 +9,7 @@ module.exports = (strapi) => {
type: nexus.nonNull('Podcast'),
args: { identifier: nexus.nonNull('String') },

resolve(parent, args, context) {
resolve(parent, args) {
const {identifier} = args;
return strapi.service('api::podcast.podcast').findOneByIdentifier(identifier);
}
Expand Down
8 changes: 4 additions & 4 deletions src/api/podcast/routes/podcast-extra.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
routes: [
{
method: "GET",
path: "/podcastByIdentifier",
handler: "podcast.podcastByIdentifier",
method: 'GET',
path: '/podcastByIdentifier',
handler: 'podcast.podcastByIdentifier',
}
]
}
};
6 changes: 3 additions & 3 deletions src/api/post/config/schema.graphql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const canCreatePost = require('../policies/canCreatePost');
const canModifyPost = require('../policies/canModifyPost');
const canPublishPost = require('../policies/canPublishPost');
const tmp = require('../../../policies/validateFindMethod');
const validateFindMethod = require('../policies/validateFindMethod');

module.exports = (strapi) => {
const extensionService = strapi.plugin('graphql').service('extension');
Expand Down Expand Up @@ -40,7 +40,7 @@ module.exports = (strapi) => {
t.field('similarPosts', {
type: nexus.nonNull(nexus.list('Post')),
args: {id: nexus.nonNull('ID'), limit: 'Int'},
resolve(parent, args, context) {
resolve(parent, args) {
const {id, limit} = args;
return strapi.service('api::post.post').findSimilarPosts(id, limit);
}
Expand All @@ -59,7 +59,7 @@ module.exports = (strapi) => {
}
},
'Query.posts': {
policies: ['global::validateFindMethod']
policies: [validateFindMethod]
},
'Mutation.createPost': {
policies: [canPublishPost, canCreatePost]
Expand Down
2 changes: 1 addition & 1 deletion src/api/post/controllers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const {createCoreController} = require('@strapi/strapi').factories;

const {j2xParser: Parser} = require("fast-xml-parser");
const {j2xParser: Parser} = require('fast-xml-parser');

module.exports = createCoreController('api::post.post', ({strapi}) => ({
async find(ctx) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

module.exports = async (ctx, config, {strapi}) => {
const {filters = {}, pagination, sort, publicationState} = ctx.args;
module.exports = async (ctx) => {
const {filters = {}, publicationState} = ctx.args;
if (publicationState === 'preview') {
if (ctx.state.user === undefined) {
filters.publishedAt = {lte: new Date()};
Expand Down
38 changes: 19 additions & 19 deletions src/api/post/routes/post-extra.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
module.exports = {
routes: [
{
method: "GET",
path: "/post-body-by-name/:name/download.md",
handler: "post.getPostBodyByName",
method: 'GET',
path: '/post-body-by-name/:name/download.md',
handler: 'post.getPostBodyByName',
},
{
method: "GET",
path: "/posts/feed/:username/:format",
handler: "post.feedByUsername",
method: 'GET',
path: '/posts/feed/:username/:format',
handler: 'post.feedByUsername',
},
{
method: "GET",
path: "/posts/feed/:format",
handler: "post.feed",
method: 'GET',
path: '/posts/feed/:format',
handler: 'post.feed',
},
{
method: "GET",
path: "/sitemap",
handler: "post.sitemap"
method: 'GET',
path: '/sitemap',
handler: 'post.sitemap'
},
{
method: "GET",
path: "/similarPosts",
handler: "post.findSimilarPosts"
method: 'GET',
path: '/similarPosts',
handler: 'post.findSimilarPosts'
},
{
method: "GET",
path: "/findOneByName",
handler: "post.findOneByName"
method: 'GET',
path: '/findOneByName',
handler: 'post.findOneByName'
}
]
}
};
2 changes: 1 addition & 1 deletion src/api/subscription/services/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { createCoreService } = require('@strapi/strapi').factories;

module.exports = createCoreService('api::subscription.subscription', ({strapi}) => ({
module.exports = createCoreService('api::subscription.subscription', () => ({
generateToken (size = 12) {
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
return new Array(size)
Expand Down
5 changes: 1 addition & 4 deletions src/extensions/users-permissions/config/schema.graphql.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const canRemove = require("../../../api/comment/policies/canRemove");
const canComment = require("../../../api/comment/policies/canComment");
const canUpdateComment = require("../../../api/comment/policies/canUpdateComment");
module.exports = (strapi) => {
const extensionService = strapi.plugin('graphql').service('extension');

Expand Down Expand Up @@ -93,7 +90,7 @@ module.exports = (strapi) => {
pagination: 'PaginationArg',
sort: nexus.list('String')
},
resolve(parent, args, context) {
resolve(parent, args) {
return strapi.service('plugin::users-permissions.extra').users(args);
}
});
Expand Down
3 changes: 2 additions & 1 deletion src/extensions/users-permissions/controllers/user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

module.exports = (controller) => {
controller.users = async function(ctx, next, {populate} = {}) {
controller.users = async function() {
// toDo 01.05.23, guille,
return [];
};

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/users-permissions/services/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function buildSortObject(sort) {
sort = [];
}
return sort.reduce((p, v) => {
const vs = v.split(':')
const vs = v.split(':');
if (vs.length === 2) {
p[vs[0]] = vs[1];
}
Expand Down
2 changes: 1 addition & 1 deletion src/functions/delivery.to.email.subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function getHtmlWithPosts(posts) {
'./public/posts-for-subscriptions-template.html',
data,
options,
(err, str) => err ? reject(err) :resolve(str))
(err, str) => err ? reject(err) :resolve(str));
});
}

Expand Down
5 changes: 5 additions & 0 deletions src/policies/disable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = async () => {
return false;
};
2 changes: 1 addition & 1 deletion tests/integration/post/limit-published-posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const randomName = require('../../helpers/random-name');
const createUser = require('../../helpers/create-user');
const generateJwt = require('../../helpers/generate-jwt-by-user');
const createPostRequest = require('../../helpers/create-post-request');
const createPost = require("../../helpers/create-post");
const createPost = require('../../helpers/create-post');

chai.use(chaiHttp);

Expand Down
9 changes: 4 additions & 5 deletions tests/integration/upload/remove-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const spies = require('chai-spies');
const createUser = require('../../helpers/create-user');
const generateJwt = require('../../helpers/generate-jwt-by-user');
const createFile = require('../../helpers/create-file');
const randomName = require("../../helpers/random-name");

chai.use(chaiHttp);
chai.use(spies);
Expand Down Expand Up @@ -67,7 +66,7 @@ describe('Remove file/images INTEGRATION', () => {

const {file, image} = await createFile(strapi, staffUser);

const res = await new Promise(resolve => {
const res = await new Promise((resolve, reject) => {
chai.request(strapi.server.httpServer)
.delete(`/api/upload/files/${file.id}`)
.set('Authorization', `Bearer ${jwt}`)
Expand All @@ -88,7 +87,7 @@ describe('Remove file/images INTEGRATION', () => {

const {file, image} = await createFile(strapi, authUser);

const res = await new Promise(resolve => {
const res = await new Promise((resolve, reject) => {
chai.request(strapi.server.httpServer)
.delete(`/api/upload/files/${file.id}`)
.set('Authorization', `Bearer ${jwt}`)
Expand All @@ -109,7 +108,7 @@ describe('Remove file/images INTEGRATION', () => {

const {file, image} = await createFile(strapi, staffUser);

const res = await new Promise(resolve => {
const res = await new Promise((resolve, reject) => {
chai.request(strapi.server.httpServer)
.delete(`/api/upload/files/${file.id}`)
.set('Authorization', `Bearer ${jwt}`)
Expand All @@ -128,7 +127,7 @@ describe('Remove file/images INTEGRATION', () => {
it('should not be able to remove the file (public)', async () => {
const {file, image} = await createFile(strapi, authUser);

const res = await new Promise(resolve => {
const res = await new Promise((resolve, reject) => {
chai.request(strapi.server.httpServer)
.delete(`/api/upload/files/${file.id}`)
.end((err, res) => err ? reject(err) : resolve(res));
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/upload/remove-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Remove images INTEGRATION', () => {
return Promise.resolve();
}),
delete: chai.spy(() => {
Promise.resolve()
Promise.resolve();
}),
checkFileSize: () => Promise.resolve()
};
Expand Down Expand Up @@ -75,7 +75,7 @@ describe('Remove images INTEGRATION', () => {
let img = await strapi.query('api::image.image').findOne({where: {id: fileUpload.related[0].id}});
expect(img).not.null;

const res2 = await new Promise((resolve, reject) => {
await new Promise((resolve, reject) => {
chai.request(strapi.server.httpServer)
.post('/graphql')
.set('Authorization', `Bearer ${jwt}`)
Expand Down
Loading

0 comments on commit a76d64a

Please sign in to comment.