question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

avoid-leaking-state-in-ember-objects is showing for ember-cli-mirage Factory objects

See original GitHub issue

I’ve just upgraded ember-cli from 2.17.0 to 2.18.0, and haver fixed most of the new linting errors (which are really informative, btw - thanks for that).

However, I’m seeing ember/avoid-leaking-state-in-ember-objects being flagged on an object that isn’t an Ember object, and thus can’t be fixed using the suggested workaround.

The class in question is an ember-cli-mirage Factory. Looking at the source code, it doesn’t extend Ember’s CoreObject, but is instead defined as:

let Factory = function() {
    ...
};

In addition, those Factories don’t have an init() method, and nor does Factory.extend set any _super property, so section in the docs for fixing ember/avoid-leaking-state-in-ember-objects that show how to fix this wouldn’t apply to these Factories.

We’re using ember-cli-mirage 0.2.1, but the latest source code (0.4.1) shows exactly the same issues.

Is there any way these errors can be removed globally for non-Ember objects, but kept for other Ember objects in the test folders, without having to add overrides on a file-by-file basis? Perhaps isEmberObject can be beefed up to check for more than just an extend method?

Thanks.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
BobrImperatorcommented, Jan 25, 2018

[QUESTION] Is it intended for

  overrides: [
    // node files
    // override rules for serializers
    {
      files: [
        'index.js',
        'testem.js',
        'ember-cli-build.js',
        'config/**/*.js',
        'tests/dummy/config/**/*.js',
        'serializers/*.js',
      ],
      parserOptions: {
        sourceType: 'script',
        ecmaVersion: 2017,
      },
      env: {
        browser: true,
      },
      rules: {
        'ember/avoid-leaking-state-in-ember-objects': 'off',
      },
    },
  ],

and especially this

      files: [
        'index.js',
        'testem.js',
        'ember-cli-build.js',
        'config/**/*.js',
        'tests/dummy/config/**/*.js',
        'serializers/*.js',
      ],

to skip all index.js files without paying attention to where they are nested? I mean, that when sourceType has value 'script', linter thinks that my users/index.js is not a module, but script, therefore it doesn’t allow for import export keywords

Parsing error: 'import' 'export' may appear only with 'sourceType: module'

I wouldn’t have noticed that if I didn’t copy pasted @rwjblue example. and of course, when I change back to sourceType: 'module' everything’s fine.

Although it’s probably not even regarding ember, but eslint instead, but it’s worth a note I guess. I’m sorry in advance if something is not right in my post, I’m new to the business 🔢

1reaction
Dhaulagiricommented, Jan 16, 2018

Hmmm, my suggestion should generally work…

I think it’s because the mirage folder is under tests/dummy/. I used this and it worked:

// mirage files
    {
      files: ['tests/dummy/mirage/**'],
      rules: {
        'ember/avoid-leaking-state-in-ember-objects': 'off'
      }
    }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Factories - Ember CLI Mirage
Factories have attributes, and you create objects from factory definitions using create and createList . Defining factories. Attributes can be static (strings, ...
Read more >
How to create a object in ember-cli-mirage? - Stack Overflow
One option would be to have the bar factory create its own baz : // factories/bar.js export default Factory.extend({ afterCreate(bar, ...
Read more >
Seeding Relations in Ember Mirage with Factories
And you also have created the comment object: import { Model, belongsTo } from 'ember-cli-mirage'; export default Model.extend({ post:belongsTo ...
Read more >
Ember CLI Mirage Tutorial and Examples - Program With Erik
The loadFixtures() method loads all the fixture data so it's available for the application. Alternatively we can create posts using a factory.
Read more >
Testing Ember with Ember CLI Mirage - YouTube
From the July 2015 Ember London meetup.See more at http://emberlondon.com.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found