eslint-plugin-ember icon indicating copy to clipboard operation
eslint-plugin-ember copied to clipboard

New rule: `no-reserved-imports`

Open michalsnik opened this issue 8 years ago • 9 comments

According to https://github.com/ember-cli/ember-rfc176-data I think we can add a rule that will check if reserved identifiers like Object are being imported.

Incorrect:

import Object from '@ember/object';

Correct:

import EmberObject from '@ember/object';

All reserved keys are here: https://github.com/ember-cli/ember-rfc176-data/blob/master/reserved.json

michalsnik avatar Jul 06 '17 12:07 michalsnik

cc @Turbo87 ☝️

michalsnik avatar Jul 10 '17 12:07 michalsnik

You can already do this with ESLint with this rule:

'no-shadow': ['error', { 'builtinGlobals': true }]

t-sauer avatar Jul 27 '17 21:07 t-sauer

Oh, true @t-sauer. Then I think we should add this to recommended config.

michalsnik avatar Aug 01 '17 07:08 michalsnik

Then I think we should add this to recommended config.

that would require a breaking change release again and I'm very much against that in the foreseeable future. IMHO we should only do breaking change releases if we actually need to break how a rule behaves, the recommended config should ideally live outside of this repo/project.

Turbo87 avatar Aug 01 '17 07:08 Turbo87

@t-sauer the potential advantage of having a custom rule would be that it can be --fix-able, but it's probably not worth it in this case 🤔

Turbo87 avatar Aug 01 '17 07:08 Turbo87

I found that there was a similar suggestion made to the Airbnb eslint base and it was not merged, with this as the reasoning: https://github.com/airbnb/javascript/pull/667#issuecomment-169913792 So similarly, I don't think we should be including the builtinGlobals option in our configuration.

kevinkucharczyk avatar Aug 01 '17 09:08 kevinkucharczyk

I think that having a dedicated fixable rule just for the ember object, string, etc. might be a good idea, I'd personally find it valuable.

jbandura avatar Aug 08 '17 09:08 jbandura

Ok, so it looks like indeed having a dedicated rule will be most valuable in this case.

michalsnik avatar Aug 15 '17 11:08 michalsnik

Picking this up then - will probably make a PR around saturday/sunday

jbandura avatar Nov 15 '17 16:11 jbandura