Skip to content

Commit

Permalink
fix: crash with this.extend() in no-classic-classes rule
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Mar 9, 2021
1 parent ec54b86 commit 0f8778e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rules/no-classic-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ module.exports = {
// Invalid if there are no arguments because that is equivalent to not called `extend` at all
// Invalid with an object as an argument because that logic needs conversion to a native class
// Still allows `.extend` if some other identifier is passed, like a Mixin
if (hasNoArguments(callExpression) || hasObjectArgument(callExpression)) {
if (
(hasNoArguments(callExpression) || hasObjectArgument(callExpression)) &&
['Identifier', 'MemberExpression'].includes(node.object.type)
) {
const classImportedFrom = getSourceModuleNameForIdentifier(context, node.object);
if (isEmberImport(classImportedFrom)) {
reportNode(callExpression);
Expand Down
1 change: 1 addition & 0 deletions tests/lib/rules/no-classic-classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ ruleTester.run('no-classic-classes', rule, {
export default SomeOtherThing.extend({});
`,
'export default Component.extend({});', // No import
"import thing from 'place'; this.extend();",
],

invalid: [
Expand Down

0 comments on commit 0f8778e

Please sign in to comment.