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

ESLint: Require await inside async functions #5263

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ addHook({ name: 'apollo-server-core', file: 'dist/runHttpQuery.js', versions: ['
const HttpQueryError = runHttpQueryModule.HttpQueryError

shimmer.wrap(runHttpQueryModule, 'runHttpQuery', function wrapRunHttpQuery (originalRunHttpQuery) {
// The original function is async, but no need to mark it as such as long as it returns a promise
return function runHttpQuery () {
if (!requestChannel.start.hasSubscribers) {
return originalRunHttpQuery.apply(this, arguments)
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/apollo-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const requestChannel = dc.tracingChannel('datadog:apollo:request')
let HeaderMap

function wrapExecuteHTTPGraphQLRequest (originalExecuteHTTPGraphQLRequest) {
// The original function is async, but no need to mark it as such as long as it returns a promise
return function executeHTTPGraphQLRequest () {
if (!HeaderMap || !requestChannel.start.hasSubscribers) {
return originalExecuteHTTPGraphQLRequest.apply(this, arguments)
Expand Down
3 changes: 3 additions & 0 deletions packages/datadog-instrumentations/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ addHook({
}, getTestEnvironment)

function getWrappedScheduleTests (scheduleTests, frameworkVersion) {
// The original function is async, but no need to mark it as such as long as it returns a promise
return function (tests) {
if (!isSuitesSkippingEnabled || hasFilteredSkippableSuites) {
return scheduleTests.apply(this, arguments)
Expand Down Expand Up @@ -741,6 +742,7 @@ function coverageReporterWrapper (coverageReporter) {
* This calculation adds no value, so we'll skip it, as long as the user has not manually opted in to code coverage,
* in which case we'll leave it.
*/
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(CoverageReporter.prototype, '_addUntestedFiles', addUntestedFiles => function () {
// If the user has added coverage manually, they're willing to pay the price of this execution, so
// we will not skip it.
Expand Down Expand Up @@ -898,6 +900,7 @@ addHook({
}, transformPackage => {
const originalCreateScriptTransformer = transformPackage.createScriptTransformer

// The original function is async, but no need to mark it as such as long as it returns a promise
transformPackage.createScriptTransformer = function (config) {
const { testEnvironmentOptions, ...restOfConfig } = config
const {
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/mocha/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ addHook({
versions: ['>=5.2.0'],
file: 'lib/cli/run-helpers.js'
}, (run) => {
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(run, 'runMocha', runMocha => function () {
if (!testStartCh.hasSubscribers) {
return runMocha.apply(this, arguments)
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-instrumentations/src/nyc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ addHook({
name: 'nyc',
versions: ['>=17']
}, (nycPackage) => {
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(nycPackage.prototype, 'wrap', wrap => function () {
// Only relevant if the config `all` is set to true
try {
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-instrumentations/src/vitest.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ addHook({
const { VitestTestRunner } = vitestPackage

// `onBeforeRunTask` is run before any repetition or attempt is run
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(VitestTestRunner.prototype, 'onBeforeRunTask', onBeforeRunTask => function (task) {
const testName = getTestName(task)

Expand Down Expand Up @@ -361,6 +362,7 @@ addHook({
})

// `onAfterRunTask` is run after all repetitions or attempts are run
// The original function is async, but no need to mark it as such as long as it returns a promise
shimmer.wrap(VitestTestRunner.prototype, 'onAfterRunTask', onAfterRunTask => function (task) {
const { isEarlyFlakeDetectionEnabled, isQuarantinedTestsEnabled } = getProvidedContext()

Expand Down
Loading