Skip to content

Conversation

lerouxb
Copy link
Contributor

@lerouxb lerouxb commented Aug 30, 2023

I'm leaving or ticketing the rest of the eslint rules that we overrode to be warnings rather than errors.

if (${JSON.stringify(flags ?? '')}) {
assert.deepStrictEqual((${JSON.stringify(
flags
// eslint-disable-next-line no-useless-escape
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I this case I think the no-useless-escape rule was a false positive. It doesn't seem to know about \s.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It’s because this whole section is inside a template string, so the actual regex ends up being /s+/, which is of course actually wrong.

This might be another good use case for String.raw? Either way, not a false positive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aah I see now. OMG that code is hard to read.

Copy link
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

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

Left a few very minor questions and small suggestions that can be ignored, looks good otherwise!

if (${JSON.stringify(flags ?? '')}) {
assert.deepStrictEqual((${JSON.stringify(
flags
// eslint-disable-next-line no-useless-escape
Copy link
Collaborator

Choose a reason for hiding this comment

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

It’s because this whole section is inside a template string, so the actual regex ends up being /s+/, which is of course actually wrong.

This might be another good use case for String.raw? Either way, not a false positive


bus.on('mongosh:connect', function (args: ConnectEvent) {
const connectionUri = redactURICredentials(args.uri);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Copy link
Collaborator

Choose a reason for hiding this comment

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

Really wish these rules would understand underscore-prefixed names or at least some kind of pattern for avoiding false positives 🙂

if (
settings !== null &&
Object.prototype.hasOwnProperty.call(settings, 'activeWindow')
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

LGTM, if you prefer not to use String.raw here I can do that in a follow-up PR

@lerouxb lerouxb merged commit 591bb7c into main Sep 4, 2023
@lerouxb lerouxb deleted the js-rules branch September 4, 2023 16:04
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.

3 participants