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

feat(lint): add rule useStrictMode #3370

Merged
merged 4 commits into from
Jul 10, 2024
Merged

feat(lint): add rule useStrictMode #3370

merged 4 commits into from
Jul 10, 2024

Conversation

ematipico
Copy link
Member

@ematipico ematipico commented Jul 7, 2024

Summary

Adds a new rule called useStrictMode that enforces the use of "use strict" inside script files (CJS).

This PR updates the logic of the workspace to "guess" the module kind by reading the type field inside the manifest.

If the manifest has "commonjs", all .js files are marked as scripts.

I know that commonjs is the default value, but nowadays, nobody uses it, they use some sort of bundler and transpiler to handle the transformation of the code. I'd be happy to change the default value to commonjs if you think it's the correct approach.

Test Plan

Added tests

@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages A-Diagnostic Area: diagnostocis labels Jul 7, 2024
Copy link
Contributor

github-actions bot commented Jul 7, 2024

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 48284 48284 0
Passed 47087 47087 0
Failed 1197 1197 0
Panics 0 0 0
Coverage 97.52% 97.52% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6538 6538 0
Passed 2198 2198 0
Failed 4340 4340 0
Panics 0 0 0
Coverage 33.62% 33.62% 0.00%

ts/babel

Test result main count This PR count Difference
Total 669 669 0
Passed 597 597 0
Failed 72 72 0
Panics 0 0 0
Coverage 89.24% 89.24% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18250 18250 0
Passed 13987 13987 0
Failed 4263 4263 0
Panics 0 0 0
Coverage 76.64% 76.64% 0.00%

Copy link

codspeed-hq bot commented Jul 7, 2024

CodSpeed Performance Report

Merging #3370 will degrade performances by 8.4%

Comparing feat/use-strict-mode (469b813) with main (a77c00b)

Summary

❌ 1 regressions
✅ 107 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark main feat/use-strict-mode Change
db_2930068967297060348.json[cached] 12.7 ms 13.9 ms -8.4%

@ematipico ematipico marked this pull request as ready for review July 9, 2024 10:50
@ematipico ematipico requested review from a team July 9, 2024 10:51
@ematipico ematipico requested a review from Conaclos July 9, 2024 15:50
@ematipico ematipico merged commit b791bb3 into main Jul 10, 2024
15 of 16 checks passed
@ematipico ematipico deleted the feat/use-strict-mode branch July 10, 2024 09:52
@Conaclos Conaclos added the A-Changelog Area: changelog label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Parser Area: parser A-Project Area: project L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants