-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Ensure lintTree
results cannot clobber tests.
#7036
Conversation
Nice work, @rwjblue! Thanks for tracking this down! |
|
||
app.project.addons.push({ | ||
lintTree(type, tree) { | ||
return stew.map(tree, function(string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed (along with a few other linting errors).
b582bb9
to
0d4b4ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds reasonable 👍
lintTree(type, tree) { | ||
return stew.map(tree, string => string.toUpperCase()); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this doing? could use a short comment explaining it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, will do.
The prior logic resulted in the result of `lintTree` being **after** the actual processed `tests/` tree. When those trees were then passed to `MergeTrees` the `lintTree` result would clobber the normal processed `tests/` tree. In general, when a linter is actually emitting linting tests, this is fine because the files that it emits are not the same names as the original (e.g. `tests/test-helper.js` becomes `tests/test-helper.lint-test.js`), but when the `lintTree` implementation does not emit different names than the input tree the `lintTree` versions "win". In Ember CLI < 2.13, this setup still worked properly because we would fully process the result of `lintTree` through the consuming applications JS processor pipeline (e.g. babel). This _sounds_ neat but actually means that we were transpiling all of `tests/` twice. In Ember CLI 2.13 and above, we only process the result of `lintTree` for modules (not a full "transpile down to ES5"). This means that any babel processing that would have been done for `tests/` normally is thrown away when the transpiled versions are clobbered by the untranspiled `lintTree`. This change corrects the ordering of trees, so that the correctly proccessed `tests/` tree "wins" when the `lintTree` tree emits files with the same names.
0d4b4ec
to
7ac7d9f
Compare
Updated with more comments around the test adding a fake |
@homu r+ |
📌 Commit 7ac7d9f has been approved by |
Ensure `lintTree` results cannot clobber tests. The prior logic resulted in the result of `lintTree` being **after** the actual processed `tests/` tree. When those trees were then passed to `MergeTrees` the `lintTree` result would clobber the normal processed `tests/` tree. In general, when a linter is actually emitting linting tests, this is fine because the files that it emits are not the same names as the original (e.g. `tests/test-helper.js` becomes `tests/test-helper.lint-test.js`), but when the `lintTree` implementation does not emit different names than the input tree the `lintTree` versions "win". In Ember CLI < 2.13, this setup still worked properly because we would fully process the result of `lintTree` through the consuming applications JS processor pipeline (e.g. babel). This _sounds_ neat but actually means that we were transpiling all of `tests/` twice. In Ember CLI 2.13 and above, we only process the result of `lintTree` for modules (not a full "transpile down to ES5"). This means that any babel processing that would have been done for `tests/` normally is thrown away when the transpiled versions are clobbered by the untranspiled `lintTree`. This change corrects the ordering of trees, so that the correctly proccessed `tests/` tree "wins" when the `lintTree` tree emits files with the same names.
☀️ Test successful - status |
The prior logic resulted in the result of
lintTree
being after the actual processedtests/
tree. When those trees were then passed toMergeTrees
thelintTree
result would clobber the normal processedtests/
tree. In general, when a linter is actually emitting linting tests, this is fine because the files that it emits are not the same names as the original (e.g.tests/test-helper.js
becomestests/test-helper.lint-test.js
), but when thelintTree
implementation does not emit different names than the input tree thelintTree
versions "win".In Ember CLI < 2.13, this setup still worked properly because we would fully process the result of
lintTree
through the consuming applications JS processor pipeline (e.g. babel). This sounds neat but actually means that we were transpiling all oftests/
twice.In Ember CLI 2.13 and above, we only process the result of
lintTree
for modules (not a full "transpile down to ES5"). This means that any babel processing that would have been done fortests/
normally is thrown away when the transpiled versions are clobbered by the untranspiledlintTree
.This change corrects the ordering of trees, so that the correctly proccessed
tests/
tree "wins" when thelintTree
tree emits files with the same names.