-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Bug] Invalid formatting of render
function in tests when running prettier via eslint-plugin-ember + eslint-plugin-prettier
#81
[Bug] Invalid formatting of render
function in tests when running prettier via eslint-plugin-ember + eslint-plugin-prettier
#81
Comments
Upon looking further into this it appears to be the same issue as #20 |
I agree that this is an issue with the eslint-plugin-ember/eslint-plugin-prettier integration, related to #20. If it were exactly the same issue, however, we'd see I think these regexes incorrectly assume that the intermediate |
render
function in tests using .gtsrender
function in tests when running prettier via eslint-plugin-ember + eslint-plugin-prettier
@gitKrystan FWIW I do see the For example, adding an extra space: |
Interesting! I still suspect that regex is related somehow. I forgot to mention that I added tests for this after you opened this issue (#83) bc it's definitely something this plugin should avoid breaking. Can you confirm my suspicion that this only happens when you run prettier via eslint-plugin-ember/eslint-plugin-prettier and not when you run |
yes that is the case. Running |
It does however work with inline comments (which was the problem earlier). So this my test line of my config: await render(<template><Greeting @hello="hi" @to="me"/></template>); which stays in tact after all. But when I ripped it apart: await render(
<template>
<Greeting @hello="hi" @to="me"/>
</template>
); it turned into, only the opening await render([
<template>
<Greeting @hello="hi" @to="me"/>
</template>
); When this is indented: await render(
<template>
<Greeting @hello="hi" @to="me"/>
</template>
); will be formatted as above: await render([
<template>
<Greeting @hello="hi" @to="me"/>
</template>
]); entire code: import { render } from '@ember/test-helpers';
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import Greeting from 'ember-app-gts/components/greeting';
module('Rendering | <Button>', function (hooks) {
setupRenderingTest(hooks);
test('it renders with defaults', async function (assert) {
await render(
<template>
<Greeting @hello="hi" @to="me"/>
</template>
);
assert.dom().hasText('hi to me');
});
}); apparently the indentation has an effect on this. |
I fixed it in my app by updating eslint-plugin-ember and adding the right config: https://github.com/ember-cli/eslint-plugin-ember?tab=readme-ov-file#gtsgjs |
🐞 Describe the Bug
Prettier is trying to format tests written as
.gts
in a way that is invalid. I'm not sure if I have something configured incorrectly or if this is a bug with the library but I figured I'd add this here in case anyone else runs into this before I can get an example repo set up to confirm.Edit: It seems this is related to #20 and is likely a bug that is from using
eslint-plugin-prettier
.Using
prettier
directly results in the correct formatting but usingprettier
througheslint-plugin-prettier
does not.eslint-plugin-prettier
also reports some somewhat confusing errors but they do go away if things are formatted correctly usingprettier
directly.🔬 Minimal Reproduction
See examples below. I'll try to get an example repo set up and add a link here.
😕 Actual Behavior
Prettier wants render in my test formatted as:
🤔 Expected Behavior
Prettier should format call to render as:
Which causes the following error:
🌍 Environment
➕ Additional Context
The text was updated successfully, but these errors were encountered: