Skip to content

Commit b773df4

Browse files
committed
Sync with ember-template-lint
1 parent 533ba5b commit b773df4

2 files changed

Lines changed: 25 additions & 64 deletions

File tree

docs/rules/template-no-trailing-spaces.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,30 @@
44

55
<!-- end auto-generated rule header -->
66

7-
Disallows trailing whitespace at the end of lines.
8-
9-
Trailing whitespace is unnecessary and can cause issues with version control systems, where it may be flagged as changes.
10-
11-
## Rule Details
12-
13-
This rule detects and removes trailing spaces or tabs at the end of lines.
7+
Disallow trailing whitespace at the end of lines.
148

159
## Examples
1610

17-
Examples of **incorrect** code for this rule:
11+
In examples below, `` represents a trailing space character.
1812

19-
```gjs
20-
<template>
21-
<div>Hello</div>
22-
</template>
13+
This rule **forbids** the following:
14+
15+
```hbs
16+
<div>test</div>••
17+
•••••
2318
```
2419

2520
```gjs
2621
<template>
27-
<div>Hello</div>
22+
<div>Hello</div>••
2823
</template>
2924
```
3025

31-
Examples of **correct** code for this rule:
26+
This rule **allows** the following:
27+
28+
```hbs
29+
<div>test</div>
30+
```
3231

3332
```gjs
3433
<template>
@@ -42,4 +41,4 @@ Examples of **correct** code for this rule:
4241

4342
## References
4443

45-
- [eslint-plugin-ember template-no-trailing-spaces](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-trailing-spaces.md)
44+
- [git/formatting and whitespace](https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_formatting_and_whitespace)

tests/lib/rules/template-no-trailing-spaces.js

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,9 @@ hbsRuleTester.run('template-no-trailing-spaces', rule, {
144144
valid: [
145145
'test',
146146
' test',
147-
`test
148-
`,
149-
`
150-
`,
151-
` test
152-
`,
153-
`{{#my-component}}
154-
test
155-
{{/my-component}}`,
147+
'test\n',
148+
'test\n' + '\n',
149+
'{{#my-component}}\n' + ' test\n' + '{{/my-component}}',
156150
`import { hbs } from 'ember-cli-htmlbars';
157151
158152
test('it renders', async (assert) => {
@@ -177,55 +171,23 @@ test('it renders', async (assert) => {
177171
errors: [{ message: 'Trailing whitespace detected.' }],
178172
},
179173
{
180-
code: `import { hbs } from 'ember-cli-htmlbars';
181-
182-
test('it renders', async (assert) => {
183-
await render(hbs\`
184-
<div class="parent">
185-
<div class="child"></div>
186-
</div>
187-
\`);
188-
});`,
189-
output: `import { hbs } from 'ember-cli-htmlbars';
190-
191-
test('it renders', async (assert) => {
192-
await render(hbs\`
193-
<div class="parent">
194-
<div class="child"></div>
195-
</div>
196-
\`);
197-
});`,
174+
code: 'test\n \n',
175+
output: 'test\n\n',
198176
errors: [{ message: 'Trailing whitespace detected.' }],
199177
},
200178
{
201-
code: `import { hbs } from 'ember-cli-htmlbars';
202-
203-
test('it renders', async (assert) => {
204-
await render(hbs\`
205-
<div></div>
206-
207-
<div></div>
208-
\`);
209-
});`,
210-
output: `import { hbs } from 'ember-cli-htmlbars';
211-
212-
test('it renders', async (assert) => {
213-
await render(hbs\`
214-
<div></div>
215-
216-
<div></div>
217-
\`);
218-
});`,
179+
code: '{{#my-component}}\n test \n{{/my-component}}',
180+
output: '{{#my-component}}\n test\n{{/my-component}}',
219181
errors: [{ message: 'Trailing whitespace detected.' }],
220182
},
221183
{
222-
code: 'test\n \n',
223-
output: 'test\n\n',
184+
code: "import { hbs } from 'ember-cli-htmlbars';\n\ntest('it renders', async (assert) => {\n await render(hbs` \n <div class=\"parent\">\n <div class=\"child\"></div>\n </div>\n `);\n});",
185+
output: "import { hbs } from 'ember-cli-htmlbars';\n\ntest('it renders', async (assert) => {\n await render(hbs`\n <div class=\"parent\">\n <div class=\"child\"></div>\n </div>\n `);\n});",
224186
errors: [{ message: 'Trailing whitespace detected.' }],
225187
},
226188
{
227-
code: '{{#my-component}}\n test \n{{/my-component}}',
228-
output: '{{#my-component}}\n test\n{{/my-component}}',
189+
code: "import { hbs } from 'ember-cli-htmlbars';\n\ntest('it renders', async (assert) => {\n await render(hbs`\n <div></div>\n \n <div></div>\n `);\n});",
190+
output: "import { hbs } from 'ember-cli-htmlbars';\n\ntest('it renders', async (assert) => {\n await render(hbs`\n <div></div>\n\n <div></div>\n `);\n});",
229191
errors: [{ message: 'Trailing whitespace detected.' }],
230192
},
231193
],

0 commit comments

Comments
 (0)