Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auto-strict

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auto-strict

Add 'use strict'; to all code not in node_modules

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

auto-strict

Makes all local modules (that is, everything except the stuff in node_modules/) in Node get loaded in strict mode. To add 'use strict' to all modules including the ones in node_modules, take a look at https://github.com/isaacs/use-strict (which was my inspiration for this module). Or use node --use_strict to get the same effect.

Usage

In your entrypoint file, put this at the very top:

'use strict';
require('auto-strict')
// That's it, now all your modules included after this line is strict forever.

Yeah, that's right, you still have to manually put 'use strict'; in your entrypoint file, because at that point, we haven't yet had a chance to patch the module compilation. All modules required after the require('auto-strict') line will have it.

Remarks

The implementation works by patching Node's internal module.prototype._compile function. The only thing it does, is check whether the file is not under the node_modules folder, and then prefixes the file content with 'use strict';

Keywords

FAQs

Package last updated on 10 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc