Skip to content

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Jun 24, 2025

Add a few tests to no-console rule, to make sure it catches e.g. console['log'](foo).

The test for console[`lo\\x67`](foo) ensures the correct operation of ComputedMemberExpression::static_property_name - that it uses cooked not raw for TemplateLiterals.

@github-actions github-actions bot added A-linter Area - Linter C-test Category - Testing. Code is missing test cases, or a PR is adding them labels Jun 24, 2025
Copy link
Member Author

overlookmotel commented Jun 24, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

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

@codspeed-hq
Copy link

codspeed-hq bot commented Jun 24, 2025

CodSpeed Instrumentation Performance Report

Merging #11878 will improve performances by 19.62%

Comparing 06-24-test_linter_no-console_add_more_tests (168f776) with main (9a2548a)

Summary

⚡ 1 improvements
✅ 37 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
mangler[cal.com.tsx] 3.5 ms 3 ms +19.62%

@overlookmotel overlookmotel marked this pull request as ready for review June 24, 2025 12:51
@overlookmotel overlookmotel requested a review from camc314 as a code owner June 24, 2025 12:51
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Jun 24, 2025
Copy link
Contributor

camc314 commented Jun 24, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Jun 24, 2025
Add a few tests to `no-console` rule, to make sure it catches e.g. `console['log'](foo)`.

The test for `console[`lo\\x67`](foo)` ensures the correct operation of `ComputedMemberExpression::static_property_name` - that it uses `cooked` not `raw` for `TemplateLiteral`s.
@graphite-app graphite-app bot force-pushed the 06-24-test_linter_no-console_add_more_tests branch from 887d15a to a1a7b50 Compare June 24, 2025 12:57
@overlookmotel overlookmotel marked this pull request as draft June 24, 2025 12:57
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jun 24, 2025
@overlookmotel
Copy link
Member Author

overlookmotel commented Jun 24, 2025

Actually this doesn't test what I wanted it to. No matter how the string is interpreted (cooked or raw), it'll still be a fail. console[`lo\\x67`](foo) is a fail, same as console[`batman`](foo) is a fail - because any property of console is disallowed by default.

@camc314
Copy link
Contributor

camc314 commented Jun 24, 2025

Actually this doesn't test what I wanted it to. No matter how the string is interpreted (cooked or raw), it'll still be a fail. console[`lo\\x67`](foo) is a fail, same as console[`batman`](foo) is a fail - because any property of console is disallowed by default.

you can customize the allowed console console methods via config? does that get what you're looking for?

(
"console.info(foo)",
Some(serde_json::json!([{ "allow": ["warn", "error", "log"] }])),
None,
),

@overlookmotel overlookmotel force-pushed the 06-24-test_linter_no-console_add_more_tests branch from a1a7b50 to 3e1d6cf Compare June 24, 2025 13:12
@overlookmotel overlookmotel marked this pull request as ready for review June 24, 2025 13:12
@overlookmotel
Copy link
Member Author

I think fixed now. This test fails if switch to using MemberExpression::static_property_info, which does have a bug (which I'll fix in next PR).

Add a few tests to `no-console` rule, to make sure it catches e.g. `console['log'](foo)`.

The test for ``console[`lo\\x67`](foo)`` ensures the correct operation of `ComputedMemberExpression::static_property_name` - that it uses `cooked` not `raw` for `TemplateLiteral`s.
@graphite-app graphite-app bot force-pushed the 06-24-test_linter_no-console_add_more_tests branch from 3e1d6cf to 168f776 Compare June 24, 2025 13:35
graphite-app bot pushed a commit that referenced this pull request Jun 24, 2025
Instead of iterating over `allow` and recalculating the static property name on each turn of the loop, check if the property name is allowed once it's already calculated with `MemberExpression::static_property_info`.

This PR also ensures that the fix made in #11879 works. If not stacked on top of that PR, one of the tests added in #11878 fails.
@graphite-app graphite-app bot merged commit 168f776 into main Jun 24, 2025
23 checks passed
@graphite-app graphite-app bot deleted the 06-24-test_linter_no-console_add_more_tests branch June 24, 2025 13:38
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-test Category - Testing. Code is missing test cases, or a PR is adding them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants