Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
chore: remove ESLint directives from tests file (#703)
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Oct 6, 2021
1 parent 9442aaf commit 55b5529
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 37 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ module.exports = {
files: 'tests/*.js',
rules: {
'import/max-dependencies': 'off',
'import/no-dynamic-require': 'off',
'max-lines-per-function': 'off',
'max-statements': 'off',
'node/global-require': 'off',
},
},
],
Expand Down
38 changes: 1 addition & 37 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ testMany(
opts: options,
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)

t.deepEqual(func, { mock: { stack: 'jam' }, stack: 'jam' })
Expand Down Expand Up @@ -227,7 +226,6 @@ testMany(
t.false(await pathExists(`${tmpDir}/node_modules/aws-sdk`))

try {
// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)

func()
Expand Down Expand Up @@ -519,7 +517,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(require(`${tmpDir}/function.js`))
t.is(files[0].mainFile, join(FIXTURES_DIR, fixtureName, 'function', 'index.js'))
},
Expand Down Expand Up @@ -1059,7 +1056,6 @@ testMany(
async (options, t) => {
const { files, tmpDir } = await zipFixture(t, 'node-fetch', { opts: options })
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(typeof require(`${tmpDir}/function.js`) === 'function')
},
)
Expand All @@ -1072,7 +1068,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.is(require(`${tmpDir}/function.js`), 'function-js-file-in-directory')
},
)
Expand All @@ -1085,7 +1080,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.is(require(`${tmpDir}/function.js`), 'index-js-file-in-directory')
},
)
Expand All @@ -1098,7 +1092,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.is(require(`${tmpDir}/function.js`).type, 'index-js-file-in-directory')
},
)
Expand All @@ -1111,7 +1104,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.is(require(`${tmpDir}/function.js`).type, 'function-js-file')
},
)
Expand All @@ -1124,7 +1116,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.is(require(`${tmpDir}/function.js`).type, 'function-js-file')
},
)
Expand All @@ -1137,7 +1128,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(typeof require(`${tmpDir}/function.js`).type === 'string')
},
)
Expand All @@ -1150,7 +1140,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(typeof require(`${tmpDir}/function.js`).type === 'string')
},
)
Expand All @@ -1163,7 +1152,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(typeof require(`${tmpDir}/function.js`).type === 'string')
},
)
Expand All @@ -1176,7 +1164,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(typeof require(`${tmpDir}/function.js`).type === 'string')
},
)
Expand All @@ -1197,11 +1184,9 @@ testMany(
t.is(file.bundler, 'esbuild')
})

/* eslint-disable import/no-dynamic-require, node/global-require */
t.true(require(`${tmpDir}/func1.js`).handler())
t.true(require(`${tmpDir}/func2.js`).handler())
t.true(require(`${tmpDir}/func3.js`).handler())
/* eslint-enable import/no-dynamic-require, node/global-require */
},
)

Expand All @@ -1213,7 +1198,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(require(`${tmpDir}/function.js`).value)
},
)
Expand All @@ -1226,7 +1210,6 @@ testMany(
opts: options,
})
await unzipFiles(files)
// eslint-disable-next-line import/no-dynamic-require, node/global-require
t.true(require(`${tmpDir}/function.js`).value)
},
)
Expand All @@ -1240,7 +1223,6 @@ testMany(
})
await unzipFiles(files)

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const result = require(`${tmpDir}/function.js`)

// We want to assert that the `target` specified in the tsconfig file (es5)
Expand Down Expand Up @@ -1367,7 +1349,6 @@ testMany(
opts,
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const functionEntry = require(`${files[0].path}/function.js`)

t.true(functionEntry)
Expand All @@ -1391,7 +1372,6 @@ testMany(
opts,
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/func1.js`)

const { body: body1 } = await func.handler({ queryStringParameters: { name: 'post1' } })
Expand Down Expand Up @@ -1453,7 +1433,6 @@ testMany(
t.false(files[0].inputs.includes(join(FIXTURES_DIR, fixtureName, 'node_modules', 'test-child', 'unused_file.js')))
}

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const functionEntry = require(`${tmpDir}/function.js`)

t.true(functionEntry)
Expand All @@ -1477,7 +1456,6 @@ testMany(
opts,
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const function1Entry = require(`${tmpDir}/func1.js`)

// The function should not be on a `src/` namespace.
Expand Down Expand Up @@ -1509,7 +1487,6 @@ testMany(
opts,
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const function2Entry = require(`${tmpDir}/func2.js`)

// The function should be on a `src/` namespace because there's a conflict
Expand Down Expand Up @@ -1540,11 +1517,9 @@ testMany(
opts,
})

/* eslint-disable import/no-dynamic-require, node/global-require */
const functionCommon = require(`${tmpDir}/function.js`)
const functionInternal = require(`${tmpDir}/function_internal.js`)
const functionUser = require(`${tmpDir}/function_user.js`)
/* eslint-enable import/no-dynamic-require, node/global-require */

// Functions from rightmost directories in the array take precedence.
t.is(functionCommon, 'user')
Expand Down Expand Up @@ -1579,7 +1554,6 @@ test('When generating a directory for a function with `archiveFormat: "none"`, i
archiveFormat: 'none',
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const functionEntry = require(`${functionDirectory}/function.js`)

t.true(functionEntry)
Expand Down Expand Up @@ -1658,7 +1632,6 @@ test('Adds a runtime shim and includes the files needed for dynamic imports usin
},
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)
const values = func('one')
const expectedLength = 5
Expand Down Expand Up @@ -1694,7 +1667,6 @@ test('Adds a runtime shim and includes the files needed for dynamic imports usin
},
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)

t.deepEqual(func('en')[0], ['yes', 'no'])
Expand All @@ -1713,7 +1685,6 @@ test('The dynamic import runtime shim handles files in nested directories', asyn
},
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)

t.deepEqual(func('en')[0], ['yes', 'no'])
Expand All @@ -1735,7 +1706,6 @@ test('The dynamic import runtime shim handles files in nested directories when u
},
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function/function.js`)

t.deepEqual(func('en')[0], ['yes', 'no'])
Expand All @@ -1756,7 +1726,6 @@ test('Negated files in `included_files` are excluded from the bundle even if the
},
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)

t.deepEqual(func('pt')[0], ['sim', 'não'])
Expand All @@ -1777,7 +1746,6 @@ test('Creates dynamic import shims for functions with the same name and same shi
})

for (let ind = 1; ind <= FUNCTION_COUNT; ind++) {
// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function${ind}.js`)

t.deepEqual(func('en')[0], ['yes', 'no'])
Expand All @@ -1798,7 +1766,6 @@ test('Creates dynamic import shims for functions using `zipFunction`', async (t)

await unzipFiles([result])

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const func = require(`${tmpDir}/function.js`)

t.deepEqual(func('en')[0], ['yes', 'no'])
Expand Down Expand Up @@ -2100,7 +2067,6 @@ test('Creates a manifest file with the list of created functions if the `manifes
opts: { manifest: manifestPath },
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const manifest = require(manifestPath)

t.is(manifest.version, 1)
Expand All @@ -2124,8 +2090,6 @@ testMany('Correctly follows node_modules via symlink', ['bundler_esbuild'], asyn
opts: options,
})

// eslint-disable-next-line import/no-dynamic-require, node/global-require
const isEven = require(`${tmpDir}/function`)
// eslint-disable-next-line no-magic-numbers
t.is(isEven(10), '10 is even')
t.is(isEven(2), '2 is even')
})

1 comment on commit 55b5529

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 11.7s

largeDepsZisi: 59.5s

Please sign in to comment.