error 'use strict' is unnecessary inside of modules
See original GitHub issueI am writing Node.js code and am getting error 'use strict' is unnecessary inside of modules
because i use 'use strict';
at the top of all my files. However, if I remove the 'use strict';
, then it tells me that I cannot use let
or const
because they are only available in strict mode. Can you tell me how to solve this?
I am using https://github.com/mastertinner/eslint-config-mastertinner-nodejs for the configuration and eslint 2.1.0
.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top Results From Across the Web
javascript: use strict is unnecessary inside of modules
Remove 'use strict' . As the error mentions, it's unnecessary. Modules are expected to execute in strict mode. Compilers will add it for...
Read more >eslint/eslint - Gitter
i'm getting 'use strict' is unnecessary inside of modules when adding 'use ... Something is enabling sourceType: module (or, if you are using...
Read more >The modern mode, "use strict"
Worth noting that 'use strict' is unnecessary when using ES6 modules ('import' syntax). Its strict out of the box. TWG • 2 years...
Read more >Deep dive into 'use strict' in JavaScript | Maisie Johnson's blog
ES6 modules It turns out that strict mode is always enabled for modules. I wasn't aware of this behavior. Since modules are a...
Read more >strict - ESLint - Pluggable JavaScript Linter
In ECMAScript modules, which always have strict mode semantics, the directives are unnecessary. Rule Details. This rule requires or disallows strict mode ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mastertinner,
sourceType: "module"
is only for ES6 modules (export
, etc). Your modules are Node.js modules (module.exports
, etc). You should keep the strict-mode directives in your modules, and removesourceType: "module"
from your config.(I made a similar mistake in #4832).
Thanks so much, @nre! That solved it.