node --use_strict is possible but not practical, as it will apply strict mode to all dependencies.
strict mode is on by default in node when using ECMAScript modules, but ECMAScript modules are only stable as of node v15 (the latest, at the time of writing).
we will be using CommonJS modules (where strict mode is not on by default) for some time yet, I imagine.
So we are mainly using CommonJS modules, and they require 'use strict'; at the top of each file to trigger strict mode. It's boilerplate, but IMO well worth it. This PR amends the linter to throw errors if a node module is not being run in strict mode.
This change may inconvenience authors of new node projects, if so I think they can override in their project .eslintrc. Personally I think it's a better default to enforce strict mode when linting existing projects and see how it impacts ECMAScript module authors later...
Note the eslint strict syntax looks a bit weird IMO, but it seems to work as desired.
We want to use strict mode in node.
node --use_strict
is possible but not practical, as it will apply strict mode to all dependencies.So we are mainly using CommonJS modules, and they require
'use strict';
at the top of each file to trigger strict mode. It's boilerplate, but IMO well worth it. This PR amends the linter to throw errors if a node module is not being run in strict mode.This change may inconvenience authors of new node projects, if so I think they can override in their project
.eslintrc
. Personally I think it's a better default to enforce strict mode when linting existing projects and see how it impacts ECMAScript module authors later...Note the eslint strict syntax looks a bit weird IMO, but it seems to work as desired.