test: add validation tests for esbuild and eslint config#27068
test: add validation tests for esbuild and eslint config#27068gaurav0107 wants to merge 5 commits into
Conversation
Adds unit tests covering the invariants called out in google-gemini#16114: - esbuild.config.js: native modules (node-pty, @github/keytar) and @google/gemini-cli-devtools remain external; baseConfig targets node+ESM+bundle with the .node file loader; commonAliases preserves the trailing slash on the userland punycode remap; createWasmPlugins() returns a wasm-binary plugin plus the esbuild-plugin-wasm loader and resolves absolute/relative .wasm?binary paths. - eslint.config.js: global ignores cover build outputs; no-restricted- imports blocks node:os and bare os homedir/tmpdir; no-debugger and no-console are enforced as errors; headers/header-format requires Apache-2.0; import/enforce-node-protocol-usage is set to 'always'. esbuild.config.js gains named exports (external, baseConfig, commonAliases, createWasmPlugins) so the test can reach them without running the top-level Promise.allSettled build trailer, which is short-circuited in the test by mocking the esbuild module. Runtime behavior of `node esbuild.config.js` is unchanged. Fixes google-gemini#16114
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a suite of unit tests to validate the integrity of the project's build and linting configurations. By asserting structural and functional invariants, these tests help prevent regressions in esbuild settings and ESLint rules, ensuring that security, license compliance, and module resolution policies remain strictly enforced. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request exports key configuration objects from esbuild.config.js and introduces comprehensive unit tests for both the esbuild and ESLint configurations. The new tests verify bundling settings, external module exclusions, path aliasing, and various linting rules including security restrictions, production safety, and license header requirements. I have no feedback to provide.
|
As we are re-prioritizing our works, we are going to close issues that are not high priority for now. Thanks for understanding! |
Summary
Adds unit tests for
esbuild.config.jsandeslint.config.jscovering the invariants called out in #16114: native-module externalization, WASM plugin resolution, and the security / license-header /node:protocol rules in the ESLint flat config.This is a deliberately narrow, additive PR. It does not refactor
esbuild.config.jsinto a helpers file, it does not touch unrelated subsystems, and it does not change runtime behavior ofnode esbuild.config.js.Details
esbuild.config.js(4 line-touches)Prepends
exportto four existing declarations so a test can reach them:external,baseConfig,commonAliasescreateWasmPlugins()No other changes. The script's top-level
Promise.allSettled([esbuild.build(cliConfig), esbuild.build(a2aServerConfig)])trailer still runs onnode esbuild.config.js. The test short-circuits it by mocking theesbuildmodule soesbuild.build()becomes a no-op that returns{ metafile: { inputs: {}, outputs: {} } }— the module can be safely imported from a test without kicking off a real build.scripts/tests/esbuild.config.test.ts(new, 13 tests)Asserts:
externalcontainsnode-pty,@lydell/node-pty(plus every platform-specific prebuild),@github/keytar, and@google/gemini-cli-devtools.baseConfigtargetsnode, emitsesm, hasbundle: true,write: true, and routes.nodethrough thefileloader.baseConfig.externalis the same reference as the exportedexternalarray (single source of truth).commonAliases.punycode === 'punycode/'— the trailing slash is load-bearing (without it, Node's built-inpunycodemodule shadows the npm package).createWasmPlugins()returns two plugins: a named'wasm-binary'plugin plus theesbuild-plugin-wasmloader.wasm-binaryplugin registers anonResolvehandler with a\.wasm\?binary$filter that correctly strips the?binarysuffix for absolute and relative paths and returns them in thewasm-embeddednamespace.scripts/tests/eslint-config.test.ts(new, 8 tests)Imports the real
eslint.config.js(it alreadyexport defaults a flat-config array) and asserts structural invariants:**/node_modules/**,bundle/**,dist/**,**/coverage/**.no-restricted-importsblocksnode:oswithimportNames: ['homedir', 'tmpdir'], and separately blocks the bareosspecifier for the same imports (defense in depth).no-debuggerandno-consoleare enforced as errors.headers/header-formatrequiresSPDX-License-Identifier: Apache-2.0.import/enforce-node-protocol-usageis set to['error', 'always'].No linter actually runs during the test — these are pure configuration-shape assertions.
Related Issues
Fixes #16114
How to Validate
Expected: 21 tests pass (13 in
esbuild.config.test.ts, 8 ineslint-config.test.ts).Regression probe — prove the tests catch real breakage:
Two pre-existing failures on
maininscripts/tests/generate-settings-doc.test.tsandscripts/tests/generate-settings-schema.test.tsare unrelated to this change and reproduce onmainprior to the diff.Pre-Merge Checklist
npm run lintpasses on the full repository (exit 0, no warnings with--max-warnings 0).npm run test:scriptsruns; the two new test files add 21 passing tests. Pre-existing failures ingenerate-settings-*are unrelated and reproduce onmain.esbuild.config.jsruntime behavior is unchanged — onlyexportkeywords added to four existing declarations; no reordering, no side-effect changes, no new imports.headers/header-formatrule.