Skip to content

feat(eslint): Allow short circuit expressions #4697

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

Merged
merged 1 commit into from
Mar 9, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Mar 9, 2022

This changes the default eslint config in order to allow expressions of the form someBoolean && doStuff() or someBoolean && (someVariable = someValue) (which are just alternate, slightly shorter forms of single-line if blocks), in order to be able to use them when checking whether or not to emit logs.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2022

size-limit report

Path Base Size (21a623b) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.42 KB 20.42 KB +0.01% 🔺
@sentry/browser - ES5 CDN Bundle (minified) 65.23 KB 65.23 KB 0%
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19 KB 19 KB -0.01% 🔽
@sentry/browser - ES6 CDN Bundle (minified) 58.25 KB 58.25 KB 0%
@sentry/browser - Webpack (gzipped + minified) 22.25 KB 22.25 KB 0%
@sentry/browser - Webpack (minified) 76.26 KB 76.26 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.28 KB 22.28 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.4 KB 46.4 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 27.25 KB 27.25 KB -0.01% 🔽
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.61 KB 25.61 KB -0.01% 🔽

Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

Can we please name this feat(eslint) as it’ll affect the downstream consumers of our eslint config package.

@lobsterkatie lobsterkatie force-pushed the kmclb-allow-short-circuit-expressions branch from 523b8bc to d93ebc6 Compare March 9, 2022 17:21
@lobsterkatie lobsterkatie marked this pull request as ready for review March 9, 2022 17:22
@lobsterkatie lobsterkatie changed the title feat(dev): Allow short circuit expressions feat(eslint): Allow short circuit expressions Mar 9, 2022
@lobsterkatie lobsterkatie enabled auto-merge (squash) March 9, 2022 17:32
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

We’ll have to take care in code review to make sure we don’t all any non-debug usages of this to proliferate, which is slightly annoying tbh.

I’m fine with the slightly more verbose code from the if statements 🤷‍♂️ (Also makes git blame a lot cleaner)

Will leave it up to you though, I trust your judgment here (I often have unfounded worries lol)

@lobsterkatie
Copy link
Member Author

We’ll have to take care in code review to make sure we don’t all any non-debug usages of this to proliferate, which is slightly annoying tbh.

I’m fine with the slightly more verbose code from the if statements 🤷‍♂️ (Also makes git blame a lot cleaner)

Will leave it up to you though, I trust your judgment here (I often have unfounded worries lol)

If I can make the thing I was attempting a few days ago work (automatically injecting isDebugBuild() so we don't have to remember to write it next to every logger call, and so that users of our npm packages can use it to treeshake their own apps), then we actually won't need this, because only our built code will include the checks. Writing it this way, with the short circuit, is actually geared towards that, since that's a much easier form in which to inject the check. In the meantime, though, in the interests of moving things along, I'm doing it manually, which requires this change.

@lobsterkatie lobsterkatie merged commit b664554 into master Mar 9, 2022
@lobsterkatie lobsterkatie deleted the kmclb-allow-short-circuit-expressions branch March 9, 2022 17:58
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.

2 participants