A curated list of browser globals that commonly cause confusion and are not recommended to use without an explicit window qualifier
Overall
score
97%
Create a utility that helps developers configure and manage a React development server with custom settings. The utility should provide functions to generate development server configuration and handle common customization scenarios.
Your utility should provide the following capabilities:
The utility should read from environment variables and configuration objects to determine appropriate settings. All functions should handle edge cases gracefully.
Create a module devServerConfig.js that exports four functions:
getPortConfig(defaultPort, envPort) - Returns the port to use, preferring environment variable over defaultshouldUseHttps(envHttps, envSslCert, envSslKey) - Returns boolean indicating if HTTPS should be enabledgetBrowserConfig(envBrowser) - Returns the browser to launch or 'none' to disable auto-launchvalidateProxyConfig(proxyConfig) - Returns true if proxy config is valid (string or object), false otherwise@generates
envPort is '3005' and defaultPort is 3000, getPortConfig returns 3005 @testenvPort is undefined and defaultPort is 3000, getPortConfig returns 3000 @testenvHttps is 'true', shouldUseHttps returns true regardless of cert/key presence @testshouldUseHttps returns false @testenvBrowser is 'chrome', getBrowserConfig returns 'chrome' @testenvBrowser is 'none', getBrowserConfig returns 'none' @testproxyConfig is 'http://localhost:5000', validateProxyConfig returns true @testproxyConfig is an object with a target property, validateProxyConfig returns true @testproxyConfig is null or a number, validateProxyConfig returns false @test/**
* Determines the port to use for the development server
* @param {number} defaultPort - The default port (usually 3000)
* @param {string|undefined} envPort - Port from environment variable
* @returns {number} The port number to use
*/
function getPortConfig(defaultPort, envPort) {
// Implementation here
}
/**
* Determines if HTTPS should be enabled
* @param {string|undefined} envHttps - HTTPS flag from environment
* @param {string|undefined} envSslCert - Path to SSL certificate
* @param {string|undefined} envSslKey - Path to SSL key
* @returns {boolean} Whether HTTPS should be enabled
*/
function shouldUseHttps(envHttps, envSslCert, envSslKey) {
// Implementation here
}
/**
* Determines which browser to open
* @param {string|undefined} envBrowser - Browser name from environment
* @returns {string} Browser name or 'none' to disable
*/
function getBrowserConfig(envBrowser) {
// Implementation here
}
/**
* Validates proxy configuration
* @param {*} proxyConfig - Proxy configuration (string or object)
* @returns {boolean} Whether the proxy config is valid
*/
function validateProxyConfig(proxyConfig) {
// Implementation here
}
module.exports = {
getPortConfig,
shouldUseHttps,
getBrowserConfig,
validateProxyConfig
};Provides the development server infrastructure and configuration system for Create React App projects.
Install with Tessl CLI
npx tessl i tessl/npm-confusing-browser-globalsdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10