Skip to content

Commit 5a3a798

Browse files
committed
Adds prettier
1 parent 14b51a9 commit 5a3a798

22 files changed

+910
-284
lines changed

packages/push/.eslintrc.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/push/.prettierrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'use strict';
2+
3+
module.exports = {
4+
overrides: [
5+
{
6+
files: '*.{js,ts,mjs,mts,cjs,cts}',
7+
options: {
8+
singleQuote: true,
9+
trailingComma: 'es5',
10+
printWidth: 120,
11+
},
12+
}
13+
],
14+
};

packages/push/eslint.config.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import globals from "globals";
2+
3+
import js from "@eslint/js";
4+
import prettier from "eslint-plugin-prettier/recommended";
5+
6+
import babelParser from "@babel/eslint-parser";
7+
8+
export default [
9+
js.configs.recommended,
10+
prettier,
11+
{
12+
languageOptions: {
13+
globals: {
14+
...globals.node,
15+
...globals.mocha,
16+
},
17+
18+
parser: babelParser,
19+
ecmaVersion: 2018,
20+
sourceType: "module",
21+
},
22+
},
23+
{
24+
linterOptions: {
25+
reportUnusedDisableDirectives: "error",
26+
},
27+
},
28+
{
29+
ignores: ["node_modules", "!**/.*"],
30+
},
31+
];

packages/push/package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,25 @@
3535
},
3636
"devDependencies": {
3737
"@babel/core": "^7.9.0",
38+
"@babel/eslint-parser": "^7.26.10",
3839
"@babel/preset-env": "^7.9.0",
3940
"@babel/register": "^7.9.0",
4041
"@babel/runtime": "^7.9.2",
42+
"@eslint/js": "^9.22.0",
4143
"@rollup/plugin-commonjs": "^11.0.2",
4244
"@rollup/plugin-node-resolve": "^7.1.1",
43-
"babel-eslint": "^10.1.0",
4445
"chai": "^4.2.0",
45-
"eslint": "^6.8.0",
46-
"eslint-config-standard": "^14.1.1",
46+
"eslint": "^9.0.0",
47+
"eslint-config-prettier": "^10.1.1",
48+
"eslint-config-standard": "^17.0.0",
4749
"eslint-plugin-import": "^2.20.1",
4850
"eslint-plugin-node": "^11.0.0",
49-
"eslint-plugin-promise": "^4.2.1",
50-
"eslint-plugin-standard": "^4.0.1",
51+
"eslint-plugin-prettier": "^5.2.3",
52+
"eslint-plugin-promise": "^7.0.0",
53+
"globals": "^16.0.0",
5154
"mocha": "^7.1.1",
5255
"nock": "^12.0.3",
56+
"prettier": "^3.5.3",
5357
"rollup": "^2.2.0",
5458
"rollup-plugin-babel": "^4.4.0",
5559
"sinon": "^9.0.1",

packages/push/src/client.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import http from "http";
2-
import https from "https";
1+
import http from 'http';
2+
import https from 'https';
33

4-
import Config from "./config";
4+
import Config from './config';
55

66
function performRequest(method, url, headers, payload) {
7-
let isTLS = url.protocol === "https:";
7+
let isTLS = url.protocol === 'https:';
88
let client = isTLS ? https : http;
99

1010
let options = {
1111
method,
1212
hostname: url.host,
13-
port: url.port !== "" ? url.port : isTLS ? 443 : 80,
13+
port: url.port !== '' ? url.port : isTLS ? 443 : 80,
1414
path: url.pathname,
1515
headers: headers,
1616
};
@@ -20,7 +20,7 @@ function performRequest(method, url, headers, payload) {
2020
resolve(response);
2121
});
2222

23-
request.on("error", (error) => {
23+
request.on('error', (error) => {
2424
reject(error);
2525
});
2626

@@ -38,28 +38,28 @@ export default class Client {
3838
}
3939

4040
get(endpoint) {
41-
return this._request("GET", endpoint);
41+
return this._request('GET', endpoint);
4242
}
4343

4444
put(endpoint, payload) {
45-
return this._request("PUT", endpoint, payload);
45+
return this._request('PUT', endpoint, payload);
4646
}
4747

4848
post(endpoint, payload) {
49-
return this._request("POST", endpoint, payload);
49+
return this._request('POST', endpoint, payload);
5050
}
5151

5252
delete(endpoint, payload) {
53-
return this._request("DELETE", endpoint, payload);
53+
return this._request('DELETE', endpoint, payload);
5454
}
5555

5656
_request(method, endpoint, payload) {
5757
let { pushEndpoint, pushKey } = this.config;
5858

5959
let url = new URL(endpoint, pushEndpoint);
6060
let headers = {
61-
Accept: "application/json",
62-
"Content-Type": "application/json; charset=UTF-8",
61+
Accept: 'application/json',
62+
'Content-Type': 'application/json; charset=UTF-8',
6363
Authorization: `Push ${pushKey}`,
6464
};
6565

packages/push/src/company.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import Resource from "./resource";
1+
import Resource from './resource';
22

33
export default class Company extends Resource {
44
static get endpoint() {
5-
return "/companies";
5+
return '/companies';
66
}
77

88
constructor(attributes) {
9-
if (typeof attributes === "string") {
9+
if (typeof attributes === 'string') {
1010
attributes = { identifier: attributes };
1111
}
1212

13-
if (attributes == null || typeof attributes !== "object") {
14-
throw "Missing required attributes object";
13+
if (attributes == null || typeof attributes !== 'object') {
14+
throw 'Missing required attributes object';
1515
}
1616

1717
if (attributes.identifier == null) {
18-
throw "Missing required attribute identifier";
18+
throw 'Missing required attribute identifier';
1919
}
2020

2121
super(attributes);

packages/push/src/config.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function decamelize(string, separator = '_'){
1+
function decamelize(string, separator = '_') {
22
return string
33
.replace(/([a-z\d])([A-Z])/g, `$1${separator}$2`)
44
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, `$1${separator}$2`)
@@ -14,27 +14,22 @@ export default class Config {
1414
constructor(configFromConstructor) {
1515
let { configFromDefault, configFromEnvironment } = this;
1616

17-
if(configFromConstructor instanceof Config) {
17+
if (configFromConstructor instanceof Config) {
1818
configFromConstructor = configFromConstructor.config;
1919
}
2020

21-
this.config = Object.assign(
22-
{},
23-
configFromDefault,
24-
configFromEnvironment,
25-
configFromConstructor
26-
);
21+
this.config = Object.assign({}, configFromDefault, configFromEnvironment, configFromConstructor);
2722

28-
for(let key of this.configKeys) {
23+
for (let key of this.configKeys) {
2924
Object.defineProperty(this, key, {
3025
set(value) {
3126
this.config[key] = value;
3227
},
3328

3429
get() {
3530
return this.config[key];
36-
}
37-
})
31+
},
32+
});
3833
}
3934
}
4035

@@ -47,12 +42,12 @@ export default class Config {
4742
}
4843

4944
get configFromEnvironment() {
50-
let config = {}
45+
let config = {};
5146

52-
for(let key of this.configKeys) {
47+
for (let key of this.configKeys) {
5348
let value = process.env[`USERLIST_${decamelize(key).toUpperCase()}`];
5449

55-
if(typeof value !== 'undefined') {
50+
if (typeof value !== 'undefined') {
5651
config[key] = value;
5752
}
5853
}

packages/push/src/event.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import Resource from "./resource";
1+
import Resource from './resource';
22

33
export default class Event extends Resource {
44
static get endpoint() {
5-
return "/events";
5+
return '/events';
66
}
77

88
constructor(attributes) {
9-
if (attributes == null || typeof attributes !== "object") {
10-
throw "Missing required attributes object";
9+
if (attributes == null || typeof attributes !== 'object') {
10+
throw 'Missing required attributes object';
1111
}
1212

1313
if (attributes.user == null && attributes.company == null) {
14-
throw "Missing required attribute user or company";
14+
throw 'Missing required attribute user or company';
1515
}
1616

1717
if (attributes.name == null) {
18-
throw "Missing required attribute name";
18+
throw 'Missing required attribute name';
1919
}
2020

2121
super(attributes);

packages/push/src/message.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import Resource from "./resource";
1+
import Resource from './resource';
22

33
export default class Message extends Resource {
44
static get endpoint() {
5-
return "/messages";
5+
return '/messages';
66
}
77
}

packages/push/src/push.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import Relation from "./relation";
2-
import Client from "./client";
3-
import Config from "./config";
4-
5-
import User from "./user";
6-
import Company from "./company";
7-
import Relationship from "./relationship";
8-
import Event from "./event";
9-
import Message from "./message";
1+
import Relation from './relation';
2+
import Client from './client';
3+
import Config from './config';
4+
5+
import User from './user';
6+
import Company from './company';
7+
import Relationship from './relationship';
8+
import Event from './event';
9+
import Message from './message';
1010

1111
export default class Userlist {
1212
constructor(config = {}) {

0 commit comments

Comments
 (0)