Skip to content

Avoid some false positives when detecting if a file is an Ember component, controller, etc #821

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

Merged
merged 2 commits into from
May 20, 2020
Merged

Avoid some false positives when detecting if a file is an Ember component, controller, etc #821

merged 2 commits into from
May 20, 2020

Conversation

bmish
Copy link
Member

@bmish bmish commented May 20, 2020

Many of our rules still use the current filepath to detect if they are running on an Ember component/route/controller/etc. Long-term, we should change this to check import/exports instead (i.e. a route is only a default export that extends from @ember/routing/route). But that's a large refactor.

One easy improvement we can make now is to look at specific segments of a filepath instead of the entire filepath when performing our checks. For example, a filepath represents a component only if a folder segment is components, or if the file segment is component.js. This is an improvement over the previous behavior of simply looking for components or component.js anywhere in the entire filepath string.

This partially addresses #235. CC: @amk221.

…nent, controller, etc

Many of our rules still use the current filepath to detect if they are running on an Ember component/route/controller/etc. Long-term, we should change this to check import/exports instead (i.e. a route is only a default export that extends from `@ember/router/route`). But that's a large refactor.

One easy improvement we can make now is to look at specific segments of a filepath instead of the entire filepath when performing our checks. For example, a filepath represents a component only if a folder segment is `components`, or if the file segment is `component.js`. This is an improvement over the previous behavior of simply looking for `components` or `component.js` anywhere in the entire filepath string.
@bmish bmish added the bug label May 20, 2020
@bmish bmish requested review from rwjblue and Turbo87 May 20, 2020 15:42
@bmish bmish changed the title Avoid false positives when detecting if a file is an Ember component, controller, etc Avoid some false positives when detecting if a file is an Ember component, controller, etc May 20, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Co-authored-by: Robert Jackson <me@rwjblue.com>
@bmish bmish merged commit f1d0b9e into ember-cli:master May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants