Skip to content

[ENHANCEMENT] Add 'use strict' directive to cjs files #774

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

Closed
Fdawgs opened this issue Mar 25, 2025 · 1 comment · Fixed by #780
Closed

[ENHANCEMENT] Add 'use strict' directive to cjs files #774

Fdawgs opened this issue Mar 25, 2025 · 1 comment · Fixed by #780

Comments

@Fdawgs
Copy link
Contributor

Fdawgs commented Mar 25, 2025

It would be beneficial to add the 'use strict' directive to all cjs files in this repo. Strict mode can improve performance by eliminating some JavaScript features that hinder optimizations. It also helps avoid subtle bugs by enforcing more consistent scoping and variable declarations.

At present this directive is dotted around a handful of files in the repo.

The MDN article on strict mode alludes to it, but the V8 JS engine used by Node will use more optimised execution paths when strict mode is enabled. See related Stack Overflow discussion for an example.

Happy to make a PR to resolve this.

@ljharb
Copy link
Contributor

ljharb commented Mar 25, 2025

This is a great idea, and it can be enforced with the eslint strict rule.

wraithgar pushed a commit that referenced this issue May 12, 2025
<!-- What / Why -->
<!-- Describe the request in detail. What it does and why it's being
changed. -->
Adds missing `'use strict'` directives; this directive is dotted around
a handful of files in the repo so this PR adds it to the rest of the CJS
files.


The local eslint file has been updated to enforce this going forward, as
suggested in the linked issue.

## References
Closes #774 
<!-- Examples:
  Related to #0
  Depends on #0
  Blocked by #0
  Fixes #0
  Closes #0
-->
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 a pull request may close this issue.

2 participants