xojs / eslint-config-xo

ESLint shareable config for XO

Home Page:https://github.com/xojs/xo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strict mode

zckrs opened this issue · comments

In https://github.com/sindresorhus/eslint-config-xo/blob/master/index.js#L105
you mention issue was closed.

Do you reactive the strict rule ?

I'm aware, but it's not released in a stable ESLint version yet. Will do it when that happens.

Not yet released. Sorry I didnt check

Hi Sindre,

IMO now strict mode is fix by ESLint

Not that easy. I tried, but we end up with another violation:

1:1 error 'use strict' is unnecessary inside of modules strict

That's because we set sourceType: 'module' in https://github.com/sindresorhus/eslint-config-xo/blob/ca1b4801b723fac6a8dca09db00165afdf513ed0/index.js#L6. We set module so we can use import in AVA tests without having to specify an config. So I don't really see a good solution here. I'd rather have import than warnings for missing 'use strict';.

// @jamestalmage

Could we look for hints that a file was an ES2015 module?

Import declaration is a dead giveaway.
Any other code constructs that imply strict mode?

Like, if there are arrow functions - does that mean it's ES2015 and strict mode is guaranteed?

This would mean writing our own rule that did this intelligent detection. But that seems doable

Could we look for hints that a file was an ES2015 module?
Import declaration is a dead giveaway.

Nope... https://www.nczonline.net/blog/2016/04/es6-module-loading-more-complicated-than-you-think/

Like, if there are arrow functions - does that mean it's ES2015 and strict mode is guaranteed?

No, you can use arrow functions outside of modules.

Closing as there's no good solution for this.

Is there any way to enable the use strict error but keep sourceType set to module?