Skip to content

embermap/eslint-plugin-ember-data-sync-relationships

Repository files navigation

eslint-plugin-ember-data-sync-relationships

npm version Build Status

An ESLint plugin that ensures all of your Ember Data relationships are sync.

Why?

We think async relationships do more harm than good. If you agree, you can use this ESLint plugin to help you migrate an app away from async relationships and ensure no new async relationships are added by mistake.

Installation

Install the plugin as a dev dependency in your Ember CLI project.

npm install --save-dev eslint-plugin-ember-data-sync-relationships

This makes the plugin available to ESLint.

Usage

Add the plugin and rule to your app's .eslintrc.js:

// .eslintrc.js

module.exports = {

  plugins: [
    'ember-data-sync-relationships'
  ],

  rules: {
    "ember-data-sync-relationships/no-async-relationships": "warn" // warn or error
  }

};

You can make the rule either "warn" or "error".

Using warn will show ESLint warnings whenever you build your app, for example when you run ember serve.

If you'd like to start removing async relationships from an existing app that relies on them, this is a good option, since it won't fail your test suite. You can eliminate async relationships one at a time until you arrive at fully synchronous bliss, at which time you can switch this ESLint rule to "error".

Using error will add any failures to your test suite. This is a stronger way to enforce all relationships stay sync, since Ember Data's default is async and it can be easy to forget the additional { async: false }.

Mirage model false-positives

If you use Mirage you may see their relationships coming up as false-positives. Exclude them by adding the following to your app's .eslint.js overrides array:

overrides: [
  // don't check mirage models
  {
    files: 'mirage/**/*.js',
    rules: {
      "ember-data-sync-relationships/no-async-relationships": "off"
    },
  }
]

About

This library is developed and maintained by EmberMap. If your company is looking to see how it can get the most out of Ember, please get in touch!

About

An ESLint plugin that ensures all Ember Data relationships are sync

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •