strict-mode

enables strict mode in your package

strict-mode

enables strict mode in your package

Installation

With npm do

npm install strict-mode

Usage

Suppose that the main attribute in your package.json is index.js.

If you want that all the modules in your package has strict mode enabled, just wrap your index.js this way

require('strict-mode')(function () {
 
// your index.js content
 
// every *require* call inside this function will have strict mode enabled
 
})

Motivation

Strict mode is a best practice but adding a "use strict"; on top of every .js file in your package could

  • require a big effort
  • be error proning
  • make complain jshint
  • be a problem when concatenating files

On the other hand the use-strict package solution is too invasive, cause it applies strictness to all future modules loaded.

Credits

Code stolen from isaacs' use-strict.

License

MIT