ember-cli / ember-cli/eslint-plugin-ember

`no-computed-properties-in-native-classes` fails with multiple class definitions

Open
#1,267 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
263
Forks
214
Avg merge
30m
Merged PRs (30d)
5

Description

If there are 2 classes defined in a file, one with the @classic decorator and one without, this rule will throw even if the class without the classic decorator doesn't have any computed properties. See example:

This fails (some code removed for brevity)
```
import classic from 'ember-classic-decorator';
// 👇 ❌ THE FOLLOWING LINE IS FAILING ESLINT
import { readOnly } from '@ember/object/computed';
import Component from '@ember/component';
// 👇 ❌ THE FOLLOWING LINE IS FAILING ESLINT
import { setProperties, get, getProperties, computed } from '@ember/object';
import layout from 'reports/templates/components/jobs-page/jobs-page-graph';

// 👇 HERE is the class that doesn't need the classic decorator. Removing it fixes the error.
class InchartsTooltip extends Tooltip {
constructor(params, valueFormatter) {
super(params);
this.valueFormatter = ({ y }) => valueFormatter(y);
}
}

// 👇 HERE is the class with the computed properties, appropriately marked with the classic decorator
@classic
@templateLayout(layout)
export default class JobsPageGraph extends Component {
@readOnly('tabName')
'data-test-jobs-page-line-graph';

@(computed('tabName').readOnly())
get displayStrings() {
const seriesName = get(this, 'tabName');

return get(this, 'displayStringsMap')[seriesName] || {};
}
}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.