Skip to content

Commit 21ece18

Browse files
committed
add eslint
1 parent 1168965 commit 21ece18

15 files changed

+88
-71
lines changed

createChannel.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
const axios = require('axios');
2-
const {WebClient} = require('@slack/web-api');
3-
const config = require('./.config/config.js')
2+
const { WebClient } = require('@slack/web-api');
3+
const config = require('./.config/config.js');
44
const readline = require('readline');
55
const r1 = readline.createInterface({
6-
input: process.stdin,
7-
output: process.stdout
6+
input: process.stdin,
7+
output: process.stdout
88
});
99

10-
run().catch(err => console.log(err));
10+
run().catch(err => console.log(err));
1111

1212
async function run() {
13-
const client = new WebClient(config.slackToken);
14-
let res = await client.conversations.list({types: 'public_channel, private_channel'});
15-
res = res.channels.map((item) => item.name_normalized);
16-
console.log(res);
17-
const val = await client.users.lookupByEmail({email: '[email protected]'});
18-
const daniel = await client.users.lookupByEmail({email: '[email protected]'});
19-
r1.question('What is the name of the channel you wish to create? ', function(name) {
20-
if(res.includes(name.toLowerCase())) {
21-
r1.emit('close', 'Name is already taken, please try again and enter a unique name.');
22-
}
23-
r1.question('public or private? ',async function(status) {
24-
console.log('status', status, typeof status, status.toLowerCase())
25-
if(status.toLowerCase == 'public') {
26-
status = false;
27-
} else if(status.toLowerCase() == 'private') {
28-
status = true;
29-
} else if(status.toLowerCase() != 'public' && status.toLowerCase() != 'private') {
30-
r1.emit('close', 'Not a valid option. please try again and enter public or private.');
31-
}
32-
let response = await client.conversations.create({name: name.toLowerCase(), is_private: status });
33-
console.log(response);
34-
let reservation = await client.conversations.invite({channel: response.channel.id , users: `${val.user.id}, ${daniel.user.id}`});
35-
console.log(response);
36-
r1.emit('close', `Channel created and invites sent to ${val.user.real_name} and ${daniel.user.real_name}!`);
37-
});
13+
const client = new WebClient(config.slackToken);
14+
let res = await client.conversations.list({ types: 'public_channel, private_channel' });
15+
res = res.channels.map((item) => item.name_normalized);
16+
console.log(res);
17+
const val = await client.users.lookupByEmail({ email: '[email protected]' });
18+
const daniel = await client.users.lookupByEmail({ email: '[email protected]' });
19+
r1.question('What is the name of the channel you wish to create? ', function(name) {
20+
if (res.includes(name.toLowerCase())) {
21+
r1.emit('close', 'Name is already taken, please try again and enter a unique name.');
22+
}
23+
r1.question('public or private? ', async function(status) {
24+
console.log('status', status, typeof status, status.toLowerCase());
25+
if (status.toLowerCase == 'public') {
26+
status = false;
27+
} else if (status.toLowerCase() == 'private') {
28+
status = true;
29+
} else if (status.toLowerCase() != 'public' && status.toLowerCase() != 'private') {
30+
r1.emit('close', 'Not a valid option. please try again and enter public or private.');
31+
}
32+
const response = await client.conversations.create({ name: name.toLowerCase(), is_private: status });
33+
console.log(response);
34+
const reservation = await client.conversations.invite({ channel: response.channel.id, users: `${val.user.id}, ${daniel.user.id}` });
35+
console.log(response);
36+
r1.emit('close', `Channel created and invites sent to ${val.user.real_name} and ${daniel.user.real_name}!`);
3837
});
38+
});
3939
}
4040

4141
r1.on('close', function(reason) {
42-
console.log(reason);
43-
process.exit(0);
44-
})
42+
console.log(reason);
43+
process.exit(0);
44+
});
4545

eslint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
const config = require('@masteringjs/eslint-config');
3+
const globals = require('globals');
4+
module.exports = [
5+
{
6+
languageOptions: {
7+
ecmaVersion: 2020,
8+
globals: {
9+
...globals.node
10+
}
11+
}
12+
},
13+
...config
14+
];

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ app.use('/.netlify/functions', cors(), express.json(), function netlifyFunctions
4040
} catch (err) {}
4141
return res.status(400).json(data);
4242
}
43-
res.json(JSON.parse(result.body))
43+
res.json(JSON.parse(result.body));
4444
}).
4545
catch(err => {
4646
res.status(500).json({ message: err.message, stack: err.stack, extra: err.extra });
@@ -65,7 +65,7 @@ app.use(
6565
)
6666
);
6767

68-
(async function () {
68+
(async function() {
6969
const db = await connect();
7070
app.use('/studio', studio('/studio/api', db));
7171

migrations/createJob.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

netlify/functions/search.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ const uri = process.env.MONGODB_CONNECTION_STRING;
2828

2929
module.exports = extrovert.toNetlifyFunction(async function search(params) {
3030
params = new SearchParams(params);
31-
let Content;
3231
if (conn == null) {
3332
conn = mongoose.createConnection(uri);
3433
await conn.asPromise();
3534
}
3635

37-
Content = conn.model('Content', contentSchema, 'Content');
36+
const Content = conn.model('Content', contentSchema, 'Content');
3837

3938
const query = params.search;
4039
const version = params.version ? +params.version.replace(/\.x$/, '') : null;

netlify/functions/status.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use strict'
1+
'use strict';
22

33
const extrovert = require('extrovert');
44
const pkg = require('../../package.json');

netlify/functions/webhookGitHubComment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,22 @@ module.exports = extrovert.toNetlifyFunction(async function webhookGitHubComment
7575
await axios.post(url, {
7676
channel: '#pro-notifications',
7777
blocks: [
78-
{type: 'divider'},
78+
{ type: 'divider' },
7979
{
8080
type: 'section',
8181
text: {
8282
type: 'mrkdwn',
8383
text: `*NEW ISSUE CREATED!* \n\n ${issue.user.login} has posted an issue titled: ${issue.title}`
8484
}
8585
},
86-
{type: 'divider'},
86+
{ type: 'divider' },
8787
{
8888
type: 'section',
8989
text: {
9090
type: 'mrkdwn',
9191
text: `*DESCRIPTION* \n\n ${issue.body}`
9292
}
93-
},
93+
}
9494
]
9595
}, { headers: { authorization: `Bearer ${slackToken}` } });
9696
} else if (ref != null && ref_type === 'tag') {

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
"ramda": "0.28.0"
1515
},
1616
"devDependencies": {
17+
"@masteringjs/eslint-config": "0.1.1",
1718
"@mongoosejs/migrations": "0.2.5",
1819
"@mongoosejs/studio": "0.0.50",
1920
"cors": "2.8.5",
2021
"dotenv": "16.4.7",
22+
"eslint": "9.x",
2123
"express": "4.x",
2224
"mocha": "9.1.3",
2325
"sinon": "12.0.1"

src/actions/requestInvite.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ module.exports = () => async function requestInvite(email) {
1818
await axios.post(url, {
1919
channel: '#pro-notifications',
2020
blocks: [
21-
{type: 'divider'},
21+
{ type: 'divider' },
2222
{
2323
type: 'section',
2424
text: {
2525
type: 'mrkdwn',
2626
text: `${email} is requesting access to the mongoosejs workspace`
2727
}
28-
},
28+
}
2929
]
3030
}, { headers: { authorization: `Bearer ${slackToken}` } });
3131

3232
return { success: true };
33-
}
33+
};

src/actions/updateJobs.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,29 +58,29 @@ module.exports = ({ task, conn }) => async function findJobsBySponsor(params) {
5858
company: subscriber.companyName,
5959
subscriberId: subscriber._id
6060
})));
61-
let messageObj = {channel: '#pro-notifications', blocks: []};
61+
const messageObj = { channel: '#pro-notifications', blocks: [] };
6262
let company = '';
6363
let jobTitle = '';
6464
company = jobs[0].company;
6565
jobTitle = jobs.map(entry =>
66-
entry.title
66+
entry.title
6767
);
68-
messageObj.blocks.push({type: 'divider'},
69-
{
70-
type: 'section',
71-
text: {
72-
type: 'mrkdwn',
73-
text: `*Jobs Updated!* \n\n ${company} has updated the following jobs`
74-
}
75-
},
76-
{type: 'divider'},
77-
{
78-
type: 'section',
79-
text: {
80-
type: 'mrkdwn',
81-
text: `*Jobs:* \n\n ${jobTitle.join(', ')}`
82-
}
83-
});
68+
messageObj.blocks.push({ type: 'divider' },
69+
{
70+
type: 'section',
71+
text: {
72+
type: 'mrkdwn',
73+
text: `*Jobs Updated!* \n\n ${company} has updated the following jobs`
74+
}
75+
},
76+
{ type: 'divider' },
77+
{
78+
type: 'section',
79+
text: {
80+
type: 'mrkdwn',
81+
text: `*Jobs:* \n\n ${jobTitle.join(', ')}`
82+
}
83+
});
8484

8585
await slack.sendMessage(messageObj);
8686
return { jobs };

src/db/task.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ taskSchema.methods.sideEffect = async function sideEffect(fn, params) {
2626
await this.save();
2727

2828
return result;
29-
}
29+
};
3030

3131
module.exports = taskSchema;

src/integrations/githubOAuth.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
const data = {
1616
tag_name: tagAndName,
1717
name: tagAndName,
18-
body: body,
18+
body: body
1919
};
2020
const { token } = await createTokenAuth(githubAccessTokenForMongoose)();
2121
const headers = {
@@ -59,7 +59,7 @@ module.exports = {
5959
code
6060
};
6161
const opts = { headers: { accept: 'application/json' } };
62-
return axios.post(`https://github.com/login/oauth/access_token`, body, opts).
62+
return axios.post('https://github.com/login/oauth/access_token', body, opts).
6363
then(res => res.data);
6464
},
6565
getChangelog(params) {

src/integrations/slack.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ const axios = require('axios');
44
const config = require('../../.config');
55

66
module.exports = {
7-
async sendMessage(jobs) {
7+
async sendMessage(jobs) {
88
const url = 'https://slack.com/api/chat.postMessage';
99
// Send to Slack
1010
await axios.post(url, jobs, { headers: { authorization: `Bearer ${config.slackToken}` } });
11-
}
12-
}
11+
}
12+
};

test/createReleaseFromChangelog.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
const TaskSchema = require('../src/db/task');
44
const assert = require('assert');
5-
const sinon = require('sinon');
6-
const githubOAuth = require('../src/integrations/githubOAuth');
75
const createReleaseFromChangelog = require('../src/actions/createReleaseFromChangelog');
6+
const { describe, it } = require('mocha');
7+
const githubOAuth = require('../src/integrations/githubOAuth');
8+
const sinon = require('sinon');
89

910
const changelog = `
1011
6.1.1 / 2021-12-09

test/setup.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require('dotenv').config({ path: './.env.test' });
44

5+
const { after, before } = require('mocha');
56
const connect = require('../src/db');
67

78
global.conn = null;

0 commit comments

Comments
 (0)