Skip to content

chore(eslint): Turn on quotes rules #4671

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

Merged
merged 2 commits into from
Mar 2, 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
4 changes: 2 additions & 2 deletions packages/browser/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,14 @@ export function injectReportDialog(options: ReportDialogOptions = {}): void {

if (!options.eventId) {
if (isDebugBuild()) {
logger.error(`Missing eventId option in showReportDialog call`);
logger.error('Missing eventId option in showReportDialog call');
}
return;
}

if (!options.dsn) {
if (isDebugBuild()) {
logger.error(`Missing dsn option in showReportDialog call`);
logger.error('Missing dsn option in showReportDialog call');
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/integrations/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Dedupe implements Integration {
// Juuust in case something goes wrong
try {
if (_shouldDropEvent(currentEvent, self._previousEvent)) {
logger.warn(`Event dropped due to being a duplicate of previously captured event.`);
logger.warn('Event dropped due to being a duplicate of previously captured event.');
return null;
}
} catch (_oO) {
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/stack-parsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const gecko: StackLineParser = line => {

if (subMatch) {
// throw out eval line/column and use top-most line number
parts[1] = parts[1] || `eval`;
parts[1] = parts[1] || 'eval';
parts[3] = subMatch[1];
parts[4] = subMatch[2];
parts[5] = ''; // no column when eval
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/transports/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getNativeFetchImplementation(): FetchImpl {
const document = global.document;
let fetchImpl = global.fetch;
// eslint-disable-next-line deprecation/deprecation
if (document && typeof document.createElement === `function`) {
if (document && typeof document.createElement === 'function') {
try {
const sandbox = document.createElement('iframe');
sandbox.hidden = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/test/package/npm-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ webpack(

function runTests() {
const bundlePath = path.join(__dirname, 'tmp.js');
const { window } = new JSDOM(``, { runScripts: 'dangerously' });
const { window } = new JSDOM('', { runScripts: 'dangerously' });

window.onerror = function () {
console.error('ERROR thrown in manual test:');
Expand Down
8 changes: 4 additions & 4 deletions packages/browser/test/unit/tracekit/safari.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ describe('Tracekit - Safari Tests', () => {

it('should parse exceptions for safari-extension with frames-only stack', () => {
const SAFARI_EXTENSION_EXCEPTION = {
message: `undefined is not an object (evaluating 'e.groups.includes')`,
name: `TypeError`,
message: "undefined is not an object (evaluating 'e.groups.includes')",
name: 'TypeError',
stack: `isClaimed@safari-extension://com.grammarly.safari.extension.ext2-W8F64X92K3/ee7759dd/Grammarly.js:2:929865
safari-extension://com.grammarly.safari.extension.ext2-W8F64X92K3/ee7759dd/Grammarly.js:2:1588410
promiseReactionJob@[native code]`,
Expand Down Expand Up @@ -219,8 +219,8 @@ describe('Tracekit - Safari Tests', () => {

it('should parse exceptions for safari-web-extension with frames-only stack', () => {
const SAFARI_EXTENSION_EXCEPTION = {
message: `undefined is not an object (evaluating 'e.groups.includes')`,
name: `TypeError`,
message: "undefined is not an object (evaluating 'e.groups.includes')",
name: 'TypeError',
stack: `p_@safari-web-extension://46434E60-F5BD-48A4-80C8-A422C5D16897/scripts/content-script.js:29:33314
safari-web-extension://46434E60-F5BD-48A4-80C8-A422C5D16897/scripts/content-script.js:29:56027
promiseReactionJob@[native code]`,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/transports/noop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class NoopTransport implements Transport {
*/
public sendEvent(_: Event): PromiseLike<Response> {
return resolvedSyncPromise({
reason: `NoopTransport: Event has been skipped because no Dsn is configured.`,
reason: 'NoopTransport: Event has been skipped because no Dsn is configured.',
status: 'skipped',
});
}
Expand Down
14 changes: 7 additions & 7 deletions packages/core/test/lib/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const api = initAPIDetails(ingestDsn, {
sdk: {
integrations: ['AWSLambda'],
name: 'sentry.javascript.browser',
version: `12.31.12`,
packages: [{ name: 'npm:@sentry/browser', version: `12.31.12` }],
version: '12.31.12',
packages: [{ name: 'npm:@sentry/browser', version: '12.31.12' }],
},
});

Expand Down Expand Up @@ -77,8 +77,8 @@ describe('eventToSentryRequest', () => {
sdk: {
integrations: ['AWSLambda'],
name: 'sentry.javascript.browser',
version: `12.31.12`,
packages: [{ name: 'npm:@sentry/browser', version: `12.31.12` }],
version: '12.31.12',
packages: [{ name: 'npm:@sentry/browser', version: '12.31.12' }],
},
}),
);
Expand All @@ -88,7 +88,7 @@ describe('eventToSentryRequest', () => {
event.sdk = {
integrations: ['Clojure'],
name: 'foo',
packages: [{ name: 'npm:@sentry/clj', version: `12.31.12` }],
packages: [{ name: 'npm:@sentry/clj', version: '12.31.12' }],
version: '1337',
};

Expand All @@ -101,8 +101,8 @@ describe('eventToSentryRequest', () => {
integrations: ['Clojure', 'AWSLambda'],
name: 'foo',
packages: [
{ name: 'npm:@sentry/clj', version: `12.31.12` },
{ name: 'npm:@sentry/browser', version: `12.31.12` },
{ name: 'npm:@sentry/clj', version: '12.31.12' },
{ name: 'npm:@sentry/browser', version: '12.31.12' },
],
version: '1337',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config-sdk/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,7 @@ module.exports = {
// `.filter` and `.reduce`. If we are not, we should be using
// `.forEach()` or an explicit for loop.
'array-callback-return': ['error', { allowImplicit: true }],

quotes: ['error', 'single', { avoidEscape: true }],
},
};
2 changes: 1 addition & 1 deletion packages/integrations/src/dedupe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class Dedupe implements Integration {
// Juuust in case something goes wrong
try {
if (_shouldDropEvent(currentEvent, self._previousEvent)) {
logger.warn(`Event dropped due to being a duplicate of previously captured event.`);
logger.warn('Event dropped due to being a duplicate of previously captured event.');
return null;
}
} catch (_oO) {
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/src/config/webpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function addFilesToExistingEntryPoint(
console.error(
'Sentry Logger [Error]:',
`Could not inject SDK initialization code into entry point ${entryPointName}, as its current value is not in a recognized format.\n`,
`Expected: string | Array<string> | { [key:string]: any, import: string | Array<string> }\n`,
'Expected: string | Array<string> | { [key:string]: any, import: string | Array<string> }\n',
`Got: ${currentEntryPoint}`,
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nextjs/test/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ describe('Sentry webpack plugin config', () => {
project: 'simulator', // from user webpack plugin config
authToken: 'dogsarebadatkeepingsecrets', // picked up from env
stripPrefix: ['webpack://_N_E/'], // default
urlPrefix: `~/_next`, // default
urlPrefix: '~/_next', // default
entries: expect.any(Function), // default, tested separately elsewhere
release: 'doGsaREgReaT', // picked up from env
dryRun: false, // based on buildContext.dev being false
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function extractExpressTransactionName(
info += method;
}
if (options.method && options.path) {
info += ` `;
info += ' ';
}
if (options.path && path) {
info += path;
Expand Down
2 changes: 1 addition & 1 deletion packages/node/test/transports/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ describe('HTTPTransport', () => {
const retryAfterSeconds = 60;
mockReturnCode = 429;
mockHeaders = {
'x-sentry-rate-limits': `sgthrthewhertht`,
'x-sentry-rate-limits': 'sgthrthewhertht',
};
const transport = createTransport({ dsn });
const now = Date.now();
Expand Down
2 changes: 1 addition & 1 deletion packages/serverless/test/google-cloud-http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('GoogleCloudHttp tracing', () => {
200,
'{"kind":"bigquery#getQueryResultsResponse","etag":"0+ToZZTzCJ4lyhNI3v4rGg==","schema":{"fields":[{"name":"foo","type":"BOOLEAN","mode":"NULLABLE"}]},"jobReference":{"projectId":"project-id","jobId":"8874c5d5-9cfe-4daa-8390-b0504b97b429","location":"US"},"totalRows":"1","rows":[{"f":[{"v":"true"}]}],"totalBytesProcessed":"0","jobComplete":true,"cacheHit":false}',
);
const resp = await bigquery.query(`SELECT true AS foo`);
const resp = await bigquery.query('SELECT true AS foo');
expect(resp).toEqual([[{ foo: true }]]);
// @ts-ignore see "Why @ts-ignore" note
expect(Sentry.fakeTransaction.startChild).toBeCalledWith({
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/hubextensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function sample<T extends Transaction>(transaction: T, options: Options, samplin
// Since this is coming from the user (or from a function provided by the user), who knows what we might get. (The
// only valid values are booleans or numbers between 0 and 1.)
if (!isValidSampleRate(sampleRate)) {
logger.warn(`[Tracing] Discarding transaction because of invalid sample rate.`);
logger.warn('[Tracing] Discarding transaction because of invalid sample rate.');
transaction.sampled = false;
return transaction;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/idletransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class IdleTransaction extends Transaction {
this._prevHeartbeatString = heartbeatString;

if (this._heartbeatCounter >= 3) {
logger.log(`[Tracing] Transaction finished because of no change for 3 heart beats`);
logger.log('[Tracing] Transaction finished because of no change for 3 heart beats');
this.setStatus('deadline_exceeded');
this.setTag(FINISH_REASON_TAG, IDLE_TRANSACTION_FINISH_REASONS[0]);
this.finish();
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/integrations/node/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class Mongo implements Integration {
namespace: collection.namespace,
};
const spanContext: SpanContext = {
op: `db`,
op: 'db',
description: operation,
data,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/tracing/src/integrations/node/mysql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Mysql implements Integration {
const parentSpan = scope?.getSpan();
const span = parentSpan?.startChild({
description: typeof options === 'string' ? options : (options as { sql: string }).sql,
op: `db`,
op: 'db',
});

if (typeof callback === 'function') {
Expand Down
4 changes: 2 additions & 2 deletions packages/tracing/src/integrations/node/postgres.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class Postgres implements Integration {
}

if (this._usePgNative && !pkg.native?.Client) {
logger.error(`Postgres Integration was unable to access 'pg-native' bindings.`);
logger.error("Postgres Integration was unable to access 'pg-native' bindings.");
return;
}

Expand All @@ -61,7 +61,7 @@ export class Postgres implements Integration {
const parentSpan = scope?.getSpan();
const span = parentSpan?.startChild({
description: typeof config === 'string' ? config : (config as { text: string }).text,
op: `db`,
op: 'db',
});

if (typeof callback === 'function') {
Expand Down
17 changes: 10 additions & 7 deletions packages/tracing/test/browser/browsertracing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ describe('BrowserTracing', () => {
});

it("doesn't return meta tags other than the one specified", () => {
document.head.innerHTML = `<meta name="cat-cafe">`;
document.head.innerHTML = '<meta name="cat-cafe">';

const metaTagValue = getMetaContent('dogpark');
expect(metaTagValue).toBe(null);
Expand All @@ -382,7 +382,7 @@ describe('BrowserTracing', () => {
const name = 'sentry-trace';
const content = '126de09502ae4e0fb26c6967190756a4-b6e54397b12a2a0f-1';
const sentryTraceMeta = `<meta name="${name}" content="${content}">`;
const otherMeta = `<meta name="cat-cafe">`;
const otherMeta = '<meta name="cat-cafe">';
document.head.innerHTML = `${sentryTraceMeta} ${otherMeta}`;

const metaTagValue = getMetaContent(name);
Expand All @@ -392,7 +392,8 @@ describe('BrowserTracing', () => {

describe('getHeaderContext', () => {
it('correctly parses a valid sentry-trace meta header', () => {
document.head.innerHTML = `<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">`;
document.head.innerHTML =
'<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">';

const headerContext = getHeaderContext();

Expand All @@ -403,15 +404,15 @@ describe('BrowserTracing', () => {
});

it('returns undefined if the header is malformed', () => {
document.head.innerHTML = `<meta name="sentry-trace" content="12312012-112120121-0">`;
document.head.innerHTML = '<meta name="sentry-trace" content="12312012-112120121-0">';

const headerContext = getHeaderContext();

expect(headerContext).toBeUndefined();
});

it("returns undefined if the header isn't there", () => {
document.head.innerHTML = `<meta name="dogs" content="12312012123120121231201212312012-1121201211212012-0">`;
document.head.innerHTML = '<meta name="dogs" content="12312012123120121231201212312012-1121201211212012-0">';

const headerContext = getHeaderContext();

Expand All @@ -422,7 +423,8 @@ describe('BrowserTracing', () => {
describe('using the data', () => {
it('uses the data for pageload transactions', () => {
// make sampled false here, so we can see that it's being used rather than the tracesSampleRate-dictated one
document.head.innerHTML = `<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">`;
document.head.innerHTML =
'<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">';

// pageload transactions are created as part of the BrowserTracing integration's initialization
createBrowserTracing(true);
Expand All @@ -437,7 +439,8 @@ describe('BrowserTracing', () => {

it('ignores the data for navigation transactions', () => {
mockChangeHistory = () => undefined;
document.head.innerHTML = `<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">`;
document.head.innerHTML =
'<meta name="sentry-trace" content="12312012123120121231201212312012-1121201211212012-0">';

createBrowserTracing(true);

Expand Down
6 changes: 3 additions & 3 deletions packages/tracing/test/integrations/node/mongo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('patchOperation()', () => {
doc: JSON.stringify(doc),
namespace: 'mockedNamespace',
},
op: `db`,
op: 'db',
description: 'insertOne',
});
expect(childSpan.finish).toBeCalled();
Expand All @@ -91,7 +91,7 @@ describe('patchOperation()', () => {
doc: JSON.stringify(doc),
namespace: 'mockedNamespace',
},
op: `db`,
op: 'db',
description: 'insertOne',
});
expect(childSpan.finish).toBeCalled();
Expand All @@ -106,7 +106,7 @@ describe('patchOperation()', () => {
dbName: 'mockedDbName',
namespace: 'mockedNamespace',
},
op: `db`,
op: 'db',
description: 'initializeOrderedBulkOp',
});
expect(childSpan.finish).toBeCalled();
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function supportsNativeFetch(): boolean {
let result = false;
const doc = global.document;
// eslint-disable-next-line deprecation/deprecation
if (doc && typeof (doc.createElement as unknown) === `function`) {
if (doc && typeof (doc.createElement as unknown) === 'function') {
try {
const sandbox = doc.createElement('iframe');
sandbox.hidden = true;
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/test/build.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';

const testStrings = [`/// <reference types="node" />`];
const testStrings = ['/// <reference types="node" />'];

describe('build', () => {
test('not contains types', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/test/envelope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('envelope', () => {
it('serializes an envelope', () => {
const env = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, []);
expect(serializeEnvelope(env)).toMatchInlineSnapshot(
`"{\\"event_id\\":\\"aa3ff046696b4bc6b609ce6d28fde9e2\\",\\"sent_at\\":\\"123\\"}"`,
'"{\\"event_id\\":\\"aa3ff046696b4bc6b609ce6d28fde9e2\\",\\"sent_at\\":\\"123\\"}"',
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const formatComponentName = (vm?: ViewModel, includeFile?: boolean): stri
}

return (
(name ? `<${classify(name)}>` : ANONYMOUS_COMPONENT_NAME) + (file && includeFile !== false ? ` at ${file}` : ``)
(name ? `<${classify(name)}>` : ANONYMOUS_COMPONENT_NAME) + (file && includeFile !== false ? ` at ${file}` : '')
);
};

Expand Down