Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

chore: switch standard to eslint #203

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"root": true,
"env": {
"node": true
},
"extends": "standard",
"plugins": [
"license-header"
],
"rules": {
"license-header/header": ["error", "./scripts/license-header.js"],
// Regarding "no-var": The opinion of this repository's maintainers is that
// while const/let are useful, the use of `var` is not bad and therefore
// does not need to be ruled out. Eliminating the use of `var` would be a
// large diff that (a) could theoretically cause bugs due to lexical scoping
// changes and (b) could theoretically impact perf (e.g. see
// https://github.com/microsoft/TypeScript/issues/52924). New code MAY
// prefer const/let over `var`. Code in "examples/" MUST use const/let --
// this is enforced by "examples/.eslintrc.json".
"no-var": "off"
},
"ignorePatterns": [
"/*.example.js", // a pattern for uncommited local dev files to avoid linting
"/*.example.mjs", // a pattern for uncommited local dev files to avoid linting
"/.nyc_output"
]
}
15 changes: 11 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const assert = require('assert')
Expand Down Expand Up @@ -555,8 +561,8 @@ Client.prototype._writeBatch = function (objs, cb) {
this._slowWriteBatch.numOver10Ms++
}
this._log.trace({
encodeTimeMs: encodeTimeMs,
fullTimeMs: fullTimeMs,
encodeTimeMs,
fullTimeMs,
numEvents: objs.length,
numBytes: chunk.length
}, '_writeBatch')
Expand Down Expand Up @@ -1188,7 +1194,8 @@ function getChoppedStreamHandler (client, onerror) {
log.trace('gzipStream "finish"')
if (!completedFromPart.intakeReq && !completedFromPart.intakeRes) {
const timeout = (client._writableState.ending || intakeRequestGracefulExitCalled
? intakeResTimeoutOnEnd : intakeResTimeout)
? intakeResTimeoutOnEnd
: intakeResTimeout)
log.trace({ timeout }, 'start intakeResTimer')
intakeResTimer = setTimeout(() => {
completePart('intakeRes',
Expand Down Expand Up @@ -1450,7 +1457,7 @@ function getConfigRequestOptions (opts, agent) {

function getBasicRequestOptions (method, defaultPath, headers, opts, agent) {
return {
agent: agent,
agent,
rejectUnauthorized: opts.rejectUnauthorized !== false,
ca: opts.serverCaCert,
hostname: opts.serverUrl.hostname,
Expand Down
6 changes: 6 additions & 0 deletions lib/central-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Central config-related utilities for the APM http client.
Expand Down
4 changes: 3 additions & 1 deletion lib/container-info.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*
* Copyright (c) 2018 Stephen Belanger
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const fs = require('fs')
Expand Down
6 changes: 6 additions & 0 deletions lib/detect-hostname.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Detect the current hostname, preferring the FQDN if possible.
Expand Down
6 changes: 6 additions & 0 deletions lib/logging.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Logging utilities for the APM http client.
Expand Down
6 changes: 6 additions & 0 deletions lib/ndjson.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const stringify = require('fast-safe-stringify')
Expand Down
6 changes: 6 additions & 0 deletions lib/truncate.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

var breadthFilter = require('breadth-filter')
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lib"
],
"scripts": {
"lint": "standard",
"lint": "eslint --ext=js,mjs,cjs . # requires node >=16.0.0",
"lint:fix": "eslint --ext=js,mjs,cjs --fix . # requires node >=16.0.0",
"test": "nyc node ./scripts/run-tests.js"
},
"engines": {
Expand All @@ -30,10 +31,15 @@
"stream-chopper": "^3.0.1"
},
"devDependencies": {
"eslint": "^8.42.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-license-header": "^0.6.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-promise": "^6.1.1",
"glob": "^7.2.3",
"ndjson": "^1.5.0",
"nyc": "^14.1.1",
"standard": "^14.3.1",
"tape": "^4.11.0"
},
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions scripts/license-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/
6 changes: 6 additions & 0 deletions test/abort.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/apm-server-version.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Test that fetching the APM Server version works as expected.
Expand Down
6 changes: 6 additions & 0 deletions test/backoff-delay.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Test Client.prototype._getBackoffDelay.
Expand Down
6 changes: 6 additions & 0 deletions test/basic.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/central-config.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/config.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const fs = require('fs')
Expand Down
6 changes: 6 additions & 0 deletions test/container-info.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const fs = require('fs')
Expand Down
6 changes: 6 additions & 0 deletions test/edge-cases.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const { exec } = require('child_process')
Expand Down
6 changes: 6 additions & 0 deletions test/expectExtraMetadata.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Test usage of `expectExtraMetadata: true` and `setExtraMetadata()`.
Expand Down
6 changes: 6 additions & 0 deletions test/extraMetadata.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Test usage of `extraMetadata: ...`.
Expand Down
6 changes: 6 additions & 0 deletions test/fixtures/cgroup_result.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

module.exports = {
Expand Down
6 changes: 6 additions & 0 deletions test/k8s.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/lambda-usage.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// Test the expected usage of this Client in an AWS Lambda environment.
Expand Down
8 changes: 7 additions & 1 deletion test/lib/call-me-back-maybe.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

// A script, used by test/side-effects.js, to test that the client.flush
// callback is called.
//
Expand All @@ -17,7 +23,7 @@ const serverUrl = process.argv[2]

const client = new Client({
// logger: require('pino')({ level: 'trace', ...require('@elastic/ecs-pino-format')() }, process.stderr), // uncomment for debugging
serverUrl: serverUrl,
serverUrl,
serviceName: 'call-me-back-maybe',
agentName: 'my-nodejs-agent',
agentVersion: '1.2.3',
Expand Down
6 changes: 6 additions & 0 deletions test/lib/unref-client.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

// This is used in test/side-effects.js to ensure that a Client with a
Expand Down
6 changes: 6 additions & 0 deletions test/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const http = require('http')
Expand Down
6 changes: 6 additions & 0 deletions test/metadata-filter.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/side-effects.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const path = require('path')
Expand Down
6 changes: 6 additions & 0 deletions test/stringify.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/truncate.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
6 changes: 6 additions & 0 deletions test/writev.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* Copyright Elasticsearch B.V. and other contributors where applicable.
* Licensed under the BSD 2-Clause License; you may not use this file except in
* compliance with the BSD 2-Clause License.
*/

'use strict'

const test = require('tape')
Expand Down
Loading