Skip to content

Commit 31b435c

Browse files
authored
feat(prettier): switch to prettier (#2)
1 parent 5290336 commit 31b435c

File tree

4 files changed

+1527
-59
lines changed

4 files changed

+1527
-59
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
[![serverless](https://img.shields.io/badge/serverless-1.0-dda415.svg)](http://www.serverless.com)
44
[![npm version](https://img.shields.io/npm/v/serverless-elasticsearch-client.svg)](https://www.npmjs.org/package/serverless-elasticsearch-client)
5-
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-dbb30b.svg)](https://standardjs.com)
65
[![CircleCI](https://circleci.com/gh/goldcaddy77/serverless-elasticsearch-client/tree/master.svg?style=shield)](https://circleci.com/gh/goldcaddy77/serverless-elasticsearch-client/tree/master)
6+
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](#badge)
77
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
88

9-
109
## AWS Elasticsearch Client
1110

1211
Wrapper around [elasticsearch-js](https://github.com/elastic/elasticsearch-js) client that plays nicely with AWS and serverless. Features include:

index.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
1-
'use strict'
1+
'use strict';
22

3-
const AWS = require('aws-sdk')
4-
const elasticsearch = require('elasticsearch')
5-
const httpAWSESClass = require('http-aws-es')
3+
const AWS = require('aws-sdk');
4+
const elasticsearch = require('elasticsearch');
5+
const httpAWSESClass = require('http-aws-es');
66

77
module.exports = {
88
createClient: createClient,
99
getOptions: getOptions
10-
}
10+
};
1111

12-
function getOptions (options) {
13-
options = options || {}
12+
function getOptions(options) {
13+
options = options || {};
1414

1515
// serverless-offline will set IS_OFFLINE based on whether we're offline
16-
const devMode = Boolean(process.env.IS_OFFLINE)
16+
const devMode = Boolean(process.env.IS_OFFLINE);
1717

18-
const prefix = options.envPrefix || 'AWS'
19-
const region = options.region || process.env[`${prefix}_REGION`]
20-
const host = options.host || process.env[`${prefix}_HOST`]
18+
const prefix = options.envPrefix || 'AWS';
19+
const region = options.region || process.env[`${prefix}_REGION`];
20+
const host = options.host || process.env[`${prefix}_HOST`];
2121

22-
delete (options.region) // this doesn't belong in ES options
22+
delete options.region; // this doesn't belong in ES options
2323

24-
if (!region) { throw new TypeError('region is required') }
25-
if (!host) { throw new TypeError('host is required') }
24+
if (!region) {
25+
throw new TypeError('region is required');
26+
}
27+
if (!host) {
28+
throw new TypeError('host is required');
29+
}
2630

27-
const credentials = options.credentials || new AWS.EnvironmentCredentials(prefix)
31+
const credentials = options.credentials || new AWS.EnvironmentCredentials(prefix);
2832

2933
const config = Object.assign({}, options, {
3034
host: host,
3135
amazonES: {
3236
region,
3337
credentials
3438
}
35-
})
39+
});
3640

3741
// don't sign the request in offline mode
3842
if (!devMode) {
39-
config.connectionClass = httpAWSESClass
43+
config.connectionClass = httpAWSESClass;
4044
}
4145

42-
return config
46+
return config;
4347
}
4448

45-
function createClient (options) {
46-
return new elasticsearch.Client(getOptions(options))
49+
function createClient(options) {
50+
return new elasticsearch.Client(getOptions(options));
4751
}

package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,16 @@
44
"description": "Elasticsearch client for AWS that plays nicely with serverless-offline and signed requests",
55
"main": "index.js",
66
"scripts": {
7-
"precommit": "npm test",
8-
"prepush": "npm test",
9-
"preversion": "npm test",
7+
"precommit": "lint-staged && npm test",
8+
"preversion": "lint-staged && npm test",
109
"test": "./node_modules/.bin/ava --verbose",
1110
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
1211
},
1312
"repository": {
1413
"type": "git",
1514
"url": "https://github.com/goldcaddy77/serverless-elasticsearch-client.git"
1615
},
17-
"keywords": [
18-
"elasticsearch",
19-
"aws",
20-
"serverless",
21-
"serverless-offline"
22-
],
16+
"keywords": ["elasticsearch", "aws", "serverless", "serverless-offline"],
2317
"author": "Dan Caddigan",
2418
"license": "ISC",
2519
"bugs": {
@@ -35,8 +29,17 @@
3529
"aws-sdk": "^2.23.0",
3630
"condition-circle": "^1.5.0",
3731
"husky": "^0.13.2",
32+
"lint-staged": "^4.1.0",
33+
"prettier": "^1.6.1",
3834
"semantic-release": "^7.0.2"
3935
},
36+
"lint-staged": {
37+
"*.{js,json}": ["prettier --write", "git add"]
38+
},
39+
"prettier": {
40+
"printWidth": 120,
41+
"singleQuote": true
42+
},
4043
"release": {
4144
"verifyConditions": "condition-circle"
4245
}

0 commit comments

Comments
 (0)