Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: apply eslint rule semi #2710

Merged
merged 3 commits into from
Jan 11, 2022
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
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = {
"project": "./tsconfig.json"
},
rules: {
"no-trailing-spaces": "error",
"eol-last": "error",
"quotes": [2, "single", { "avoidEscape": true }],
"@typescript-eslint/no-floating-promises": 2,
"@typescript-eslint/no-this-alias": "off",
Expand Down Expand Up @@ -40,6 +42,7 @@ module.exports = {
}
}],
"@typescript-eslint/no-shadow": ["warn"],
"@typescript-eslint/semi": "error",
"arrow-parens": ["error", "as-needed"],
"node/no-deprecated-api": ["warn"],
"header/header": [2, "block", [{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { otlpTypes } from '@opentelemetry/exporter-trace-otlp-http';
import { toOTLPExportMetricServiceRequest } from '@opentelemetry/exporter-metrics-otlp-http'
import { toOTLPExportMetricServiceRequest } from '@opentelemetry/exporter-metrics-otlp-http';
import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
import {
OTLPExporterConfigNode,
Expand Down Expand Up @@ -45,7 +45,7 @@ export class OTLPMetricExporter
const headers = baggageUtils.parseKeyPairsIntoRecord(getEnv().OTEL_EXPORTER_OTLP_METRICS_HEADERS);
this.metadata ||= new Metadata();
for (const [k, v] of Object.entries(headers)) {
this.metadata.set(k, v)
this.metadata.set(k, v);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { MetricRecord, MetricExporter } from '@opentelemetry/sdk-metrics-base';
import {
import {
OTLPExporterNodeBase,
OTLPExporterNodeConfigBase,
otlpTypes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,6 @@ export class HttpInstrumentation extends InstrumentationBase<Http> {
captureRequestHeaders: utils.headerCapture('request', config.headersToSpanAttributes?.server?.requestHeaders ?? []),
captureResponseHeaders: utils.headerCapture('response', config.headersToSpanAttributes?.server?.responseHeaders ?? []),
}
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
import {
Span,
SpanAttributes,
} from '@opentelemetry/api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export function headerCapture(type: 'request' | 'response', headers: string[]) {
return (span: Span, getHeader: (key: string) => undefined | string | string[] | number) => {
for (const [capturedHeader, normalizedHeader] of normalizedHeaders) {
const value = getHeader(capturedHeader);

if (value === undefined) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('HttpInstrumentation', () => {
describe('disable()', () => {
let provider: TracerProvider;
let startSpanStub: sinon.SinonStub;

before(() => {
provider = {
getTracer: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
context,
propagation,
Span as ISpan,
SpanKind,
SpanKind,
trace,
SpanAttributes,
} from '@opentelemetry/api';
Expand Down Expand Up @@ -100,13 +100,13 @@ export const responseHookFunction = (
export const startIncomingSpanHookFunction = (
request: IncomingMessage
): SpanAttributes => {
return {guid: request.headers?.guid}
return {guid: request.headers?.guid};
};

export const startOutgoingSpanHookFunction = (
request: RequestOptions
): SpanAttributes => {
return {guid: request.headers?.guid}
return {guid: request.headers?.guid};
};

describe('HttpInstrumentation', () => {
Expand Down Expand Up @@ -507,12 +507,12 @@ describe('HttpInstrumentation', () => {
hostname: 'localhost',
pathname: '/',
forceStatus: {
code: SpanStatusCode.ERROR,
code: SpanStatusCode.ERROR,
message: err.message,
},
component: 'http',
noNetPeer: true,
}
};
assertSpan(spans[0], SpanKind.CLIENT, validations);
return true;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('HttpsInstrumentation', () => {
describe('disable()', () => {
let provider: TracerProvider;
let startSpanStub: sinon.SinonStub;

before(() => {
provider = {
getTracer: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,12 +475,12 @@ describe('Utility', () => {
request.headers = {
'user-agent': 'chrome',
'x-forwarded-for': '<client>, <proxy1>, <proxy2>'
}
const attributes = utils.getIncomingRequestAttributes(request, { component: 'http'})
assert.strictEqual(attributes[SemanticAttributes.HTTP_ROUTE], undefined)
};
const attributes = utils.getIncomingRequestAttributes(request, { component: 'http'});
assert.strictEqual(attributes[SemanticAttributes.HTTP_ROUTE], undefined);
});
});

describe('headers to span attributes capture', () => {
let span: Span;

Expand Down Expand Up @@ -539,6 +539,6 @@ describe('Utility', () => {

assert.deepStrictEqual(span.attributes['http.request.header.origin'], ['localhost']);
assert.deepStrictEqual(span.attributes['http.request.header.accept'], undefined);
})
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const assertSpan = (
assert.ok(
span.attributes[SemanticAttributes.NET_PEER_PORT],
'must have PEER_PORT'
);
);
}
assert.ok(
(span.attributes[SemanticAttributes.HTTP_URL] as string).indexOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export abstract class InstrumentationBase<T = any>
} catch (error) {
diag.warn('Failed extracting version', baseDir);
}

return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ describe('InstrumentationBase', () => {

let instrumentation: TestInstrumentation;
let modulePatchSpy: sinon.SinonSpy;

beforeEach(() => {
instrumentation = new TestInstrumentation();
// @ts-expect-error access internal property for testing
instrumentation._enabled = true;
modulePatchSpy = sinon.spy();
});

describe('when patching a module', () => {
describe('AND there is no wildcard supported version', () => {
it('should not patch module', () => {
Expand All @@ -56,15 +56,15 @@ describe('InstrumentationBase', () => {
name: MODULE_NAME,
patch: modulePatchSpy as unknown,
} as InstrumentationModuleDefinition<unknown>;

// @ts-expect-error access internal property for testing
instrumentation._onRequire<unknown>(
instrumentationModule,
moduleExports,
MODULE_NAME,
MODULE_DIR
);

assert.strictEqual(instrumentationModule.moduleVersion, undefined);
assert.strictEqual(instrumentationModule.moduleExports, undefined);
sinon.assert.notCalled(modulePatchSpy);
Expand All @@ -79,28 +79,28 @@ describe('InstrumentationBase', () => {
name: MODULE_NAME,
patch: modulePatchSpy as unknown,
} as InstrumentationModuleDefinition<unknown>;

// @ts-expect-error access internal property for testing
instrumentation._onRequire<unknown>(
instrumentationModule,
moduleExports,
MODULE_NAME,
MODULE_DIR
);

assert.strictEqual(instrumentationModule.moduleVersion, undefined);
assert.strictEqual(instrumentationModule.moduleExports, moduleExports);
sinon.assert.calledOnceWithExactly(modulePatchSpy, moduleExports, undefined);
});
});
});

describe('when patching module files', () => {
let filePatchSpy: sinon.SinonSpy;

beforeEach(() => {
filePatchSpy = sinon.spy();
})
});

describe('AND there is no wildcard supported version', () => {
it('should not patch module file', () => {
Expand All @@ -116,15 +116,15 @@ describe('InstrumentationBase', () => {
patch: filePatchSpy as unknown
}]
} as InstrumentationModuleDefinition<unknown>;

// @ts-expect-error access internal property for testing
instrumentation._onRequire<unknown>(
instrumentationModule,
moduleExports,
MODULE_FILE_NAME,
MODULE_DIR
);

assert.strictEqual(instrumentationModule.moduleVersion, undefined);
assert.strictEqual(instrumentationModule.moduleExports, undefined);
sinon.assert.notCalled(modulePatchSpy);
Expand All @@ -146,15 +146,15 @@ describe('InstrumentationBase', () => {
patch: filePatchSpy as unknown
}]
} as InstrumentationModuleDefinition<unknown>;

// @ts-expect-error access internal property for testing
instrumentation._onRequire<unknown>(
instrumentationModule,
moduleExports,
MODULE_FILE_NAME,
MODULE_DIR
);

assert.strictEqual(instrumentationModule.moduleVersion, undefined);
assert.strictEqual(instrumentationModule.files[0].moduleExports, moduleExports);
sinon.assert.notCalled(modulePatchSpy);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import * as api from '@opentelemetry/api'
import { Attributes } from '@opentelemetry/api-metrics-wip'
import * as api from '@opentelemetry/api';
import { Attributes } from '@opentelemetry/api-metrics-wip';

// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/api.md#measurement

Expand All @@ -24,4 +24,4 @@ export type Measurement = {
// TODO use common attributes
attributes: Attributes
context?: api.Context;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { MetricCollector } from './state/MetricCollector';

export type MeterProviderOptions = {
resource?: Resource;
}
};

export class MeterProvider {
private _sharedState: MeterProviderSharedState;
Expand All @@ -42,7 +42,7 @@ export class MeterProvider {
getMeter(name: string, version = '', options: metrics.MeterOptions = {}): metrics.Meter {
// https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#meter-creation
if (this._shutdown) {
api.diag.warn('A shutdown MeterProvider cannot provide a Meter')
api.diag.warn('A shutdown MeterProvider cannot provide a Meter');
return metrics.NOOP_METER;
}

Expand Down Expand Up @@ -84,7 +84,7 @@ export class MeterProvider {
} catch (e) {
// Log all Errors.
if (e instanceof Error) {
api.diag.error(`Error shutting down: ${e.message}`)
api.diag.error(`Error shutting down: ${e.message}`);
}
}
}
Expand All @@ -103,7 +103,7 @@ export class MeterProvider {

// do not flush after shutdown
if (this._shutdown) {
api.diag.warn('invalid attempt to force flush after shutdown')
api.diag.warn('invalid attempt to force flush after shutdown');
return;
}

Expand All @@ -113,7 +113,7 @@ export class MeterProvider {
} catch (e) {
// Log all Errors.
if (e instanceof Error) {
api.diag.error(`Error flushing: ${e.message}`)
api.diag.error(`Error flushing: ${e.message}`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ export class HistogramAggregator implements Aggregator<HistogramAccumulation> {
startTime,
endTime,
point: accumulation.toPoint(),
}
};
})
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export class LastValueAggregator implements Aggregator<LastValueAccumulation> {
startTime,
endTime,
point: accumulation.toPoint(),
}
};
})
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export class SumAggregator implements Aggregator<SumAccumulation> {
startTime,
endTime,
point: accumulation.toPoint(),
}
};
})
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

import { Attributes } from '@opentelemetry/api-metrics-wip'
import { Context, HrTime } from '@opentelemetry/api'
import { Attributes } from '@opentelemetry/api-metrics-wip';
import { Context, HrTime } from '@opentelemetry/api';
import { ExemplarFilter } from './ExemplarFilter';


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export type Exemplar = {
// trace_id may be missing if the measurement is not recorded inside a trace
// or if the trace is not sampled.
traceId?: string;
}
};
Loading