Use standard and prettier (#10)

* switch from custom eslint config to standard + prettier

* fix new standard eslint violations

* add editorconfig file

* auto-fix all other violations

* update lint yarn script

* remove jshint comment
This commit is contained in:
Spencer
2019-07-09 13:24:13 -07:00
committed by GitHub
parent f69840c50f
commit 7c1573fb07
119 changed files with 4506 additions and 3521 deletions

View File

@ -1,58 +1,62 @@
describe('Client instances creation', function () {
describe('Client instances creation', function() {
var stream = require('stream');
var util = require('util');
var es = require('../../../src/elasticsearch');
var apis = require('../../../src/lib/apis');
var expect = require('expect.js');
var stub = require('../../utils/auto_release_stub').make();
var client;
describe('', function () {
beforeEach(function () {
describe('', function() {
beforeEach(function() {
client = new es.Client();
});
afterEach(function () {
afterEach(function() {
client.close();
});
it('throws an error linking to the es module when you try to instanciate the exports', function () {
it('throws an error linking to the es module when you try to instanciate the exports', function() {
var Es = es;
expect(function () {
expect(function() {
var c = new Es();
return c
return c;
}).to.throwError(/previous "elasticsearch" module/);
});
var pkg = require('../../../package.json');
var def = pkg.config.default_api_branch;
var prev = pkg.config.supported_es_branches[pkg.config.supported_es_branches.indexOf(def) + 1];
var prev =
pkg.config.supported_es_branches[
pkg.config.supported_es_branches.indexOf(def) + 1
];
it('inherits the ' + def + ' API by default', function () {
it('inherits the ' + def + ' API by default', function() {
expect(client.bulk).to.be(apis[def].bulk);
expect(client.nodes.stats).to.be(apis[def].nodes.prototype.stats);
});
it('inherits the ' + prev + ' API when specified', function () {
it('inherits the ' + prev + ' API when specified', function() {
client.close();
client = es.Client({
apiVersion: prev
apiVersion: prev,
});
expect(client.bulk).to.be(apis[prev].bulk);
expect(client.cluster.nodeStats).to.be(apis[prev].cluster.prototype.nodeStats);
expect(client.cluster.nodeStats).to.be(
apis[prev].cluster.prototype.nodeStats
);
});
it('closing the client causes it\'s transport to be closed', function () {
it("closing the client causes it's transport to be closed", function() {
var called = false;
client.transport.close = function () {
client.transport.close = function() {
called = true;
};
client.close();
expect(called).to.be(true);
});
it('creates a warning level logger by default', function () {
it('creates a warning level logger by default', function() {
expect(client.transport.log.listenerCount('error')).to.eql(1);
expect(client.transport.log.listenerCount('warning')).to.eql(1);
expect(client.transport.log.listenerCount('info')).to.eql(0);
@ -61,21 +65,19 @@ describe('Client instances creation', function () {
});
});
describe('config', function () {
it('accepts a stream type logger', function (done) {
describe('config', function() {
it('accepts a stream type logger', function(done) {
function NullStream() {
stream.Writable.call(this);
}
util.inherits(NullStream, stream.Writable);
NullStream.prototype._write = function (/* chunk, encoding, next */) {
NullStream.prototype._write = function(/* chunk, encoding, next */) {
done();
};
client = new es.Client({
log: [
{ type: 'stream', stream: new NullStream() }
]
log: [{ type: 'stream', stream: new NullStream() }],
});
client.transport.log.error(new Error());