Skip to content

Commit b4dcd5d

Browse files
committed
style: linting
1 parent ce09799 commit b4dcd5d

21 files changed

+1259
-562
lines changed

.eslintrc

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
{
2-
"extends": "semistandard",
2+
"plugins": ["prettier"],
3+
"extends": [
4+
"semistandard"
5+
],
36
"env": {
47
"node": true,
58
"jest": true
69
},
710
"rules": {
811
"space-before-function-paren": 0,
912
"no-control-regex": 0,
13+
"no-console": 1,
14+
"no-var": 2,
15+
"prefer-const": 1,
1016
"no-prototype-builtins": 0,
17+
"no-useless-escape": 1,
1118
"comma-dangle": 0,
12-
"indent": "off"
19+
"keyword-spacing": ["error", { "before": true, "after": true }],
20+
"comma-spacing": ["error", { "before": false, "after": true }],
21+
"indent": 0,
22+
"prefer-spread": 1,
23+
"no-mixed-operators": 1,
24+
"prettier/prettier": 1,
25+
"camelcase": ["error", {
26+
"allow": ["^UNSAFE_"],
27+
"properties": "never",
28+
"ignoreGlobals": true
29+
}],
30+
"quotes": [
31+
"error", "single", {
32+
"avoidEscape": true,
33+
"allowTemplateLiterals": true
34+
}
35+
],
1336
}
1437
}

README.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ toasted.notify(
286286
287287
<br />
288288

289-
There is a default timeout set of `10` to ensure that the application closes properly. To remove the timeout and have a notification instantly close _(does not support actions)_, set `timeout: false`. If you are using an `action:`; it is recommended to set timeout to a high value to ensure the user has time to respond to the notification.
289+
Default timeout is `10` to ensure that the application closes properly. To remove the timeout and have notifications instantly close _(does not support actions)_, set `timeout: false`. If you are using an `action:` declaration; it is recommended to set the timeout to a high value to ensure the user has time to respond to the notification.
290290

291291
> [!NOTE]
292292
> **Exception**: If `reply: true` is defined, set timeout to a high value, or to nothing at all.
@@ -376,7 +376,7 @@ If you do not see notifications from Toasted-Notifier, click windows **Start** a
376376

377377
Locate `NtfyToast`, or your `customPath` / `appID` program in the list.
378378

379-
<sup>`Note`: <a href="https://github.com/Aetherinox/ntfy-toast">NtfyToast</a> is the library used in Toasted-Notifier for Windows notifications</sup>
379+
<sup>`Note`: <a href="https://github.com/Aetherinox/ntfy-toast">NtfyToast</a> is the library used by Toasted-Notifier for Windows notifications</sup>
380380

381381
<div align="center">
382382

@@ -709,7 +709,6 @@ For instructions on accomplishing this, read the section [appID support](#appid-
709709
### Can't use Windows Toast notifications in WSL2
710710
Ntfy makes use of a 3rd party package for Windows notifications to work. You must change the permissions on the Ntfy vendor .exe in order for it to work properly.
711711

712-
713712
```shell
714713
chmod +x node_modules/toasted-notifier/vendor/ntfyToast/ntfytoast.exe
715714
```
@@ -812,8 +811,6 @@ When using toasted-notifier within a tmux session, it can cause the system to ab
812811
set -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL -l"
813812
```
814813
815-
816-
817814
<br />
818815
819816
---

example/advanced.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
const notifier = require('../');
2-
const nc = new notifier.NotificationCenter();
1+
/* eslint-disable no-console */
2+
3+
const toasted = require('../');
4+
const nc = new toasted.NotificationCenter();
35
const path = require('path');
46

57
nc.notify(
68
{
7-
title: 'Phil Coulson',
8-
subtitle: 'Agent of S.H.I.E.L.D.',
9-
message: "If I come out, will you shoot me? 'Cause then I won't come out.",
9+
title: 'Test Notification',
10+
subtitle: 'This is a subtitle',
11+
message: 'This is an advanced test message',
1012
sound: 'Funk',
11-
// case sensitive
1213
wait: true,
1314
icon: path.join(__dirname, 'example_1.png'),
1415
contentImage: path.join(__dirname, 'example_1.png'),

example/forceBallon.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
/* eslint-disable no-console */
12
const toasted = require('../index');
3+
24
const balloon = toasted.WindowsBalloon();
35
balloon
46
.notify({ message: 'Hello' }, function (err, data) {
57
console.log(err, data);
68
})
9+
710
.on('click', function () {
811
console.log(arguments);
912
});

example/macInput.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1+
/* eslint-disable no-console */
2+
13
const notifier = require('../');
24
const nc = new notifier.NotificationCenter();
35

4-
const trueAnswer = 'Most def.';
6+
const trueAnswer = 'Yessir.';
7+
8+
/*
9+
@note : closeLabel is case sensitive
10+
*/
511

612
nc.notify(
713
{
814
title: 'Notifications',
9-
message: 'Are they cool?',
15+
message: 'Do you like them?',
1016
sound: 'Funk',
11-
// case sensitive
12-
closeLabel: 'Absolutely not',
17+
closeLabel: 'Nope',
1318
actions: trueAnswer
1419
},
1520
function (err, response, metadata) {
1621
if (err) throw err;
1722
console.log(metadata);
1823

1924
if (metadata.activationValue !== trueAnswer) {
20-
return; // No need to continue
25+
return; // Do not continue
2126
}
2227

2328
nc.notify(
2429
{
2530
title: 'Notifications',
26-
message: 'Do you want to reply to them?',
31+
message: 'Do you wish to reply to them?',
2732
sound: 'Funk',
28-
// case sensitive
2933
reply: true
3034
},
3135
function (err, response, metadata) {
@@ -37,5 +41,5 @@ nc.notify(
3741
);
3842

3943
nc.on('replied', function (obj, options, metadata) {
40-
console.log('User replied', metadata);
44+
console.log('User has replied', metadata);
4145
});

example/message.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
/* eslint-disable no-console */
2+
13
const toasted = require('../index');
24

35
toasted
46
.notify({ message: 'Hello', wait: true }, function (err, data) {
5-
// Will also wait until notification is closed.
7+
// wait until notification is closed.
68
console.log('Waited');
79
console.log(err, data);
810
})

example/toaster-custom-path.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-console */
2+
13
const path = require('path');
24

35
/*
@@ -17,7 +19,7 @@ const { WindowsToaster } = require('../');
1719
const customPath = path.join('vendor', 'ntfyToast', 'ntfytoast.exe');
1820
const toasted = new WindowsToaster({
1921
withFallback: false,
20-
customPath: customPath
22+
customPath
2123
});
2224

2325
/*

example/toaster-persistent.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
const path = require('path');
23
const toasted = require('../index');
34

example/toaster-with-actions.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
const path = require('path');
23
const toasted = require('../index');
34

example/toaster.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable no-console */
2+
13
const path = require('path');
24
const toasted = require('../index');
35

lib/utils.js

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
const shellwords = require('shellwords');
23
const cp = require('child_process');
34
const semver = require('semver');
@@ -54,10 +55,10 @@ const notifySendFlags = {
5455

5556
module.exports.command = function (notifier, options, cb) {
5657
notifier = shellwords.escape(notifier);
57-
if (process.env.DEBUG && process.env.DEBUG.indexOf('notifier') !== -1) {
58-
console.info('node-notifier debug info (command):');
59-
console.info('[notifier path]', notifier);
60-
console.info('[notifier options]', options.join(' '));
58+
if (process.env.DEBUG && process.env.DEBUG.indexOf('toasted') !== -1) {
59+
console.info('toasted-notifier debug info (command):');
60+
console.info('[toast path]', notifier);
61+
console.info('[toast options]', options.join(' '));
6162
}
6263

6364
return cp.exec(notifier + ' ' + options.join(' '), function (error, stdout, stderr) {
@@ -67,10 +68,10 @@ module.exports.command = function (notifier, options, cb) {
6768
};
6869

6970
module.exports.fileCommand = function (notifier, options, cb) {
70-
if (process.env.DEBUG && process.env.DEBUG.indexOf('notifier') !== -1) {
71-
console.info('node-notifier debug info (fileCommand):');
72-
console.info('[notifier path]', notifier);
73-
console.info('[notifier options]', options.join(' '));
71+
if (process.env.DEBUG && process.env.DEBUG.indexOf('toasted') !== -1) {
72+
console.info('toasted-notifier debug info (fileCommand):');
73+
console.info('[toast path]', notifier);
74+
console.info('[toast options]', options.join(' '));
7475
}
7576

7677
return cp.execFile(notifier, options, function (error, stdout, stderr) {
@@ -80,10 +81,10 @@ module.exports.fileCommand = function (notifier, options, cb) {
8081
};
8182

8283
module.exports.fileCommandJson = function (notifier, options, cb) {
83-
if (process.env.DEBUG && process.env.DEBUG.indexOf('notifier') !== -1) {
84-
console.info('node-notifier debug info (fileCommandJson):');
85-
console.info('[notifier path]', notifier);
86-
console.info('[notifier options]', options.join(' '));
84+
if (process.env.DEBUG && process.env.DEBUG.indexOf('toasted') !== -1) {
85+
console.info('toasted-notifier debug info (fileCommandJson):');
86+
console.info('[toast path]', notifier);
87+
console.info('[toast options]', options.join(' '));
8788
}
8889

8990
return cp.execFile(notifier, options, function (error, stdout, stderr) {
@@ -100,9 +101,9 @@ module.exports.fileCommandJson = function (notifier, options, cb) {
100101
};
101102

102103
module.exports.immediateFileCommand = function (notifier, options, cb) {
103-
if (process.env.DEBUG && process.env.DEBUG.indexOf('notifier') !== -1) {
104-
console.info('node-notifier debug info (notifier):');
105-
console.info('[notifier path]', notifier);
104+
if (process.env.DEBUG && process.env.DEBUG.indexOf('toasted') !== -1) {
105+
console.info('toasted-notifier debug info (Toast):');
106+
console.info('[toast path]', notifier);
106107
}
107108

108109
notifierExists(notifier, function (_, exists) {

notifiers/balloon.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function notifyRaw(options, callback) {
5757
callback = callback || noop;
5858

5959
if (typeof options === 'string') {
60-
options = { title: 'node-notifier', message: options };
60+
options = { title: 'toasted-notifier', message: options };
6161
}
6262

6363
const actionJackedCallback = utils.actionJackerDecorator(this, options, callback, function (data) {
@@ -128,7 +128,7 @@ function doNotification(options, notifierOptions, callback) {
128128
wrapper: '',
129129
noEscape: true,
130130
explicitTrue: true,
131-
allowedArguments: allowedArguments
131+
allowedArguments
132132
});
133133

134134
if (options.wait) {

notifiers/growl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function notifyRaw(options, callback) {
3232
options = utils.clone(options || {});
3333

3434
if (typeof options === 'string') {
35-
options = { title: 'node-notifier', message: options };
35+
options = { title: 'toasted-notifier', message: options };
3636
}
3737

3838
callback = utils.actionJackerDecorator(this, options, callback, function (data) {

notifiers/notificationcenter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function notifyRaw(options, callback) {
3535
activeId = id;
3636

3737
if (typeof options === 'string') {
38-
options = { title: 'node-notifier', message: options };
38+
options = { title: 'toasted-notifier', message: options };
3939
}
4040
callback = callback || noop;
4141

notifiers/notifysend.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function notifyRaw(options, callback) {
3535
}
3636

3737
if (typeof options === 'string') {
38-
options = { title: 'node-notifier', message: options };
38+
options = { title: 'toasted-notifier', message: options };
3939
}
4040

4141
if (!options.message) {
@@ -87,9 +87,9 @@ function doNotification(options, callback) {
8787
delete options.message;
8888

8989
const argsList = utils.constructArgumentList(options, {
90-
initial: initial,
90+
initial,
9191
keyExtra: '-',
92-
allowedArguments: allowedArguments
92+
allowedArguments
9393
});
9494

9595
utils.command(notifier, argsList, callback);

notifiers/toaster.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function notifyRaw(options, callback) {
6565
};
6666

6767
if (typeof options === 'string') {
68-
options = { title: 'node-notifier', message: options };
68+
options = { title: 'toasted-notifier', message: options };
6969
}
7070

7171
if (typeof callback !== 'function') {
@@ -102,7 +102,6 @@ function notifyRaw(options, callback) {
102102
callback(null, result);
103103

104104
/*
105-
@ref : https://github.com/mikaelbr/node-notifier/issues/334
106105
Due to an issue with ntfytoast not using stdio and pipe
107106
when notifications are disabled, make sure named pipe server
108107
is closed before exiting.

0 commit comments

Comments
 (0)