-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
avoid-leaking-state-in-ember-objects is showing for ember-cli-mirage Factory objects #202
Comments
Sorry you are having troubles here! TBH, I don't think we can do much more to detect (statically) if a given import is going to be an Ember object or not other than what we are already doing. Basically, if something "duck types" like an Ember object, we consider it one... I think the best solution here would be to add an additional entry to // default .eslintrc.js for [email protected]
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
},
plugins: [
'ember'
],
extends: [
'eslint:recommended',
'plugin:ember/recommended'
],
env: {
browser: true
},
rules: {
},
overrides: [
// node files
{
files: [
'index.js',
'testem.js',
'ember-cli-build.js',
'config/**/*.js',
'tests/dummy/config/**/*.js'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
},
env: {
browser: false,
node: true
}
},
// test files
{
files: ['tests/**/*.js'],
excludedFiles: ['tests/dummy/**/*.js'],
env: {
embertest: true
}
},
// mirage files
{
files: ['mirage/**'],
rules: {
'ember/avoid-leaking-state-in-ember-objects': 'off'
}
}
]
}; |
Once we have figured out the right subset of overrides to use for |
Hi @rwjblue, Thank for the advice on disabling the rule for Mirage files. Sadly, it didn't work. I added it to both
I tried changing the excluded path from After that, I tried adding This is really hampering my ability to upgrade Ember to 2.18, as my build keeps erroring when the code isn't at fault. Right now, I don't care if I can disable this rule globally, but it seems that I'm unable to do that (or don't know the correct syntax to do so). Here's my Thanks
|
Aah - I seem to have found a workaround. I can define my object property data outside of the class, and reference it inside. As the linting is probably only looking for curly braces or square brackets inside the class, this will pass as it finds neither of those. So, changing this:
to this:
fixes the problem for me with no disabling of linting rules required. |
Hmmm, my suggestion should generally work... 🤔 Can you push up a demo app that I can help debug? |
I've moved on to debugging a very different problem at the moment, and as I have a workaround for the linting issue (in my previous comment), it's unlikely that I'll be given any time to knock up a demo app. If I do, I'll let you know. Thanks |
I think it's because the mirage folder is under
|
Ya, in an addon that is definitely correct. I didn't catch that this issue was RE: an addon. |
[QUESTION] 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
I wouldn't have noticed that if I didn't copy pasted @rwjblue example. Although it's probably not even regarding ember, but eslint instead, but it's worth a note I guess. |
I've just upgraded
ember-cli
from2.17.0
to2.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'sCoreObject
, but is instead defined as:In addition, those Factories don't have an
init()
method, and nor doesFactory.extend
set any_super
property, so section in the docs for fixingember/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 anextend
method?Thanks.
The text was updated successfully, but these errors were encountered: