Generated controllers source files have 'use strict'

Since es6 (back in 2015), modules are strict by default, and we don’t have to add ‘use strict’ to the javascript source files. 6 years have been passed since ES6 initial rollout, and all javascript engines and platform (node.js, browsers, …) have strict mode by default. I think it would improve code quality, if Strapi removes this both from its source code and the generate controllers.

1 Like

@code-guru we are not using es6 modules in the backend as it’s based on Koa.js just good old common javascript so this doesn’t apply.

If we are looking at the react part of Strapi (admin panel) then yes it would apply.

see: NodeJS modularizaton & strict mode - DEV Community

Great to know, thanks for you reply! It is perhaps something for far future; Node.js has started to support ECMAScript modules as their stable api, possible to enable it in package.json using “type”: “module”.

Once they move into Node v16 we can consider it, but we never support “odd” node releases as those are development versions that include tons of breaking changes. The only time we update our Node support is after the standard October release dates of major “even” versions once a year.