question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Way to enforce strict mode on ES6 modules when not implicit due to transpiling issue?

See original GitHub issue

In my .eslint.js I have something like

module.exports = {
    parserOptions: {
        ecmaVersion: 6,
        sourceType: 'module',
        ecmaFeatures: {
            impliedStrict: false
        }
    },
    rules: {
        strict: ['error', 'global'],
        ...
    }
    ...
};

When I place 'use strict'; on the top of my JavaScript files ESLint gives me the error:

‘use strict’ is unnecessary inside of modules. (strict)

I was hoping this error wouldn’t appear since I’m disabling the impliedStrict parser option.

However impliedStrict is defined as

impliedStrict - enable global strict mode (if ecmaVersion is 5 or greater)

And I’m inside a module there, so perhaps this is a request to extend the definition of impliedStrict to include modules, or provide another ecmaFeatures named something like impliedStrictModules?

Background

Meteor 1.3’s ecmascript module enables ES2015 support but it doesn’t include implicit strict mode.

If this gets resolved in Meteor, I won’t have a need for this rule. However I don’t think Meteor would fix this until a Major release because breaking changes. I’m guessing other frameworks may have this issue as well if they chose not to enable strict mode in their babel parsing options.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AnthonyAstigecommented, May 15, 2016
1reaction
ilyavolodincommented, May 15, 2016

I agree. Meteor plugin could just clone strict rule and modify it to work specifically for meteor’s needs. Closing as it doesn’t look like we need to address anything here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ES6 In Depth: Modules - the Web developer blog
ES6 modules are automatically strict-mode code, even if you don't write "use strict"; in them. You can use import and export in modules....
Read more >
Making transpiled ES modules more spec-compliant - 2ality
A proposed “spec mode” for Babel makes transpiled ES modules more spec-compliant. That's a crucial step in preparing for native ES modules.
Read more >
Using Node.js require vs. ES6 import/export - Stack Overflow
The important part is that the declarations are statically analyzable, so that dependencies can be determined without executing the code. This would allow...
Read more >
How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >
How JavaScript works: the module pattern + comparing ...
Before ES6, modules were not built into the JavaScript programming language ... ES6 modules are stored in files and run in strict mode....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found