Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Latest commit

 

History

History
32 lines (24 loc) · 796 Bytes

no-global-jquery.md

File metadata and controls

32 lines (24 loc) · 796 Bytes

No global jQuery (no-global-jquery)

Do not use global $ or jQuery.

Rule Details

In general, we want application code to reference the version of jQuery that's been directly pinned to the version of Ember used. This helps avoid version conflicts, and ensures that code inside modules isn't reliant on global variables.

Examples of incorrect code for this rule:

export default Component.extend({
  init() {
    $('.foo').addClass('bar'); //global usage
  }
});

Examples of correct code for this rule:

import Ember from 'ember';

const { $ } = Ember;
export default Component.extend({
  init() {
    Ember.$('.foo').addClass('bar') //usage from Ember object
    // or even better
    $('.foo').addClass('bar'); // deconstruction from Ember object
  }
});