Skip to content
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

fix: Make it possible to annotate nodes #154

Merged
merged 2 commits into from
Oct 25, 2019
Merged

fix: Make it possible to annotate nodes #154

merged 2 commits into from
Oct 25, 2019

Conversation

dcyriller
Copy link
Member

@dcyriller dcyriller commented Oct 24, 2019

I've added a test that fails with this error:

  stack: Error: ember-template-recast could not handle the mutations of `_isElseIfBlock` on BlockStatement
    at ParseResult.print (d:\a\ember-template-recast\ember-template-recast\src\parse-result.js:993:13)
    at ParseResult.print (d:\a\ember-template-recast\ember-template-recast\src\parse-result.js:805:38)
    at ast.body.map.node (d:\a\ember-template-recast\ember-template-recast\src\parse-result.js:366:52)
    at Array.map (<anonymous>)
    at ParseResult.print (d:\a\ember-template-recast\ember-template-recast\src\parse-result.js:366:35)
    at print (d:\a\ember-template-recast\ember-template-recast\src\index.js:16:22)
    at Object.<anonymous> (d:\a\ember-template-recast\ember-template-recast\tests\parse-result-test.js:1060:20)
    at runTest (d:\a\ember-template-recast\ember-template-recast\node_modules\qunit\qunit\qunit.js:3041:30)
    at Test.run (d:\a\ember-template-recast\ember-template-recast\node_modules\qunit\qunit\qunit.js:3027:6)
    at d:\a\ember-template-recast\ember-template-recast\node_modules\qunit\qunit\qunit.js:3258:12

It looks impossible to annotate an else if node right now. The type of the node is BlockStatement.

This is an issue I ran into while switching to use ember-template-recast in ember-template-lint. The rule involved there is: lint-block-indentation.

I'm not quite sure in which direction to go. I see two options: 1/ refactor the visitor on ember-template-lint side to annotate the node in a different way; 2/ fix the annotation here in ember-template-recast. I would go for the second option, but may you confirm @rwjblue?

EDIT: added the error stacktrace

@rwjblue
Copy link
Member

rwjblue commented Oct 25, 2019

Ya, we should try to fix here.

I think the path forward would be to make the error (Error: ember-template-recast could not handle the mutations of _isElseIfBlock on BlockStatement) only get fired if the property exists on the AST node of that type 🤔

@dcyriller dcyriller changed the title fix: Make it possible to annotate an else if node fix: Make it possible to annotate nodes Oct 25, 2019
@dcyriller
Copy link
Member Author

dcyriller commented Oct 25, 2019

Thanks! It's implemented now.

@rwjblue rwjblue added the enhancement New feature or request label Oct 25, 2019
@rwjblue rwjblue merged commit 5bbcf89 into ember-template-lint:master Oct 25, 2019
@rwjblue
Copy link
Member

rwjblue commented Oct 25, 2019

Released in v3.2.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants