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

Add beta-switch package #1263

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Oksamies
Copy link
Contributor

No description provided.

Copy link
Contributor Author

Oksamies commented Nov 13, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment on lines +31 to +33
const desireCookie = new RegExp("betaDesire=([^;]+);").exec(
document.cookie[-1] === ";" ? document.cookie : document.cookie + ";"
)?.[1];
Copy link

Choose a reason for hiding this comment

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

JavaScript does not support negative array indexing. To check if the last character is a semicolon, replace document.cookie[-1] with document.cookie[document.cookie.length - 1]. This will properly access the last character of the string.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +23 to +29
enabledPages.forEach((regPath) => {
const regExecuted = new RegExp(regPath).exec(window.location.pathname);
const found = regExecuted !== null && regExecuted.length < 2;
if (!betaIsAvailable && found) {
betaIsAvailable = true;
}
}, betaIsAvailable);
Copy link

Choose a reason for hiding this comment

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

The forEach has a second argument betaIsAvailable passed as thisArg which appears unintentional and could lead to bugs. The thisArg parameter is meant to set the value of this inside the callback function, but isn't needed here. Consider removing the second argument to forEach.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +6 to +8
"main": "dist/thunderstore-beta-switch.cjs.js",
"module": "dist/thunderstore-beta-switch.esm.js",
"types": "dist/thunderstore-beta-switch.cjs.d.ts",
Copy link

Choose a reason for hiding this comment

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

There appears to be a mismatch between the output paths specified in package.json and TypeScript's actual output. TypeScript's tsc command will generate different file names than what's listed here. To resolve this, either:

  1. Add a bundler (like Rollup or esbuild) to generate the .cjs.js and .esm.js files, or
  2. Update these paths to match TypeScript's output format (typically .js and .d.ts files)

This will ensure the built files are available at the locations the package declares.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant