Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@putout/plugin-strict-mode

coderaiser37.5kMIT10.0.2

🐊Putout plugin adds ability to add or remove strict mode directive

putout, putout-plugin, plugin, strict-mode

readme

@putout/plugin-strict-mode NPM version

Strict mode makes several changes to normal JavaScript semantics:

  • Eliminates some JavaScript silent errors by changing them to throw errors.
  • Fixes mistakes that make it difficult for JavaScript engines to perform optimizations: strict mode code can sometimes be made to run faster than identical code that's not strict mode.
  • Prohibits some syntax likely to be defined in future versions of ECMAScript.

(c) MDN

🐊Putout plugin adds ability to add strict mode to CommonJS, and remove from ESM, where it enabled by default. Moved to @putout/plugin-nodejs.

Install

npm i @putout/plugin-strict-mode -D

Rule

{
    "rules": {
        "strict-mode/add-missing": "on",
        "strict-mode/remove-useless": "on"
    }
}

❌ Example of incorrect code

ESM:

'strict mode';

import a from 'b';

CommonJS:

const a = require('b');

✅ Example of correct code

ESM:

import a from 'b';

CommonJS:

'strict mode';

const a = require('b');

License

MIT