Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: "import-rsvp/jquery" #61

Closed
Turbo87 opened this issue May 10, 2017 · 3 comments
Closed

New rule: "import-rsvp/jquery" #61

Turbo87 opened this issue May 10, 2017 · 3 comments
Labels
New Rule Idea for a new lint rule

Comments

@Turbo87
Copy link
Member

Turbo87 commented May 10, 2017

Instead of accessing Ember.$ and Ember.RSVP we should:

import $ from 'jquery';
import RSVP from 'rsvp';

I think it might be a good idea to encode that in an ESLint rule

@michalsnik
Copy link
Member

Hmm, okay. This makes sense 👍

But, currently lots of us do smth like:

import Ember from 'ember';
const { $, RSVP } = Ember;

So we already use $ and RSVP directly which complicates this rule a bit.

I'm thinking about actual implementation of this rule. And it looks like apart from looking for Ember.$ and Ember.RSVP we need to check for the existence of import $ from 'jquery'; and import RSVP from 'rsvp' and then if they don't exist but $ or RSVP are being used - we can assume they're from Ember namespace so we can point that they are supposed to be imported directly, not destructed from Ember.

What do you think @Turbo87 about naming this rule require-direct-imports or something similar? We can mention in documentation which modules are now supported. In the future I guess there will be more of them, so making it more generic now might have a sense.

@Turbo87
Copy link
Member Author

Turbo87 commented Jul 1, 2017

FWIW https://github.com/ember-cli/ember-rfc176-data has more information on the suggested new import paths

@michalsnik
Copy link
Member

michalsnik commented Jul 14, 2017

I'm wondering if we should add this rule or create one that will report all global imports regarding this list: https://github.com/ember-cli/ember-rfc176-data/blob/master/globals.json as part of #86

@bmish bmish added the New Rule Idea for a new lint rule label May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New Rule Idea for a new lint rule
Projects
None yet
Development

No branches or pull requests

3 participants