Commit 96e57e1
committed
Port autofix for template-sort-invocations
ember-template-lint's sort-invocations rebuilds the AST via
ember-template-recast to produce a fully-sorted result. The autofix
was lost when the rule was extracted.
Restores the autofix using a bubble-sort single-swap pattern: each
fixer call swaps just one out-of-order adjacent pair, and ESLint's
fix loop reruns until convergence (up to 10 passes). This is simpler
and produces better output than upstream's full-rebuild approach:
- Whitespace and indentation are preserved (upstream collapses
multi-line attributes to one line via the recast rebuild)
- Glint comments stay in place (upstream displaces them to the end
of the attribute list)
createSwapFix strips trailing whitespace from each side before
swapping, which is necessary because Glimmer attribute and modifier
nodes can have trailing whitespace absorbed into their range — a
naive `textB + interNodeText + textA` reconstruction fails 7 of the
50 tests. The trailing whitespace is re-appended after the swap.1 parent c97528a commit 96e57e1
4 files changed
Lines changed: 1014 additions & 38 deletions
File tree
- docs/rules
- lib/rules
- tests/lib/rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
287 | | - | |
| 287 | + | |
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
29 | 47 | | |
30 | 48 | | |
31 | 49 | | |
| |||
171 | 189 | | |
172 | 190 | | |
173 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
174 | 195 | | |
175 | 196 | | |
176 | 197 | | |
| |||
186 | 207 | | |
187 | 208 | | |
188 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
189 | 213 | | |
190 | 214 | | |
191 | 215 | | |
192 | 216 | | |
193 | 217 | | |
194 | 218 | | |
195 | 219 | | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
196 | 232 | | |
197 | 233 | | |
198 | 234 | | |
| |||
203 | 239 | | |
204 | 240 | | |
205 | 241 | | |
| 242 | + | |
206 | 243 | | |
207 | 244 | | |
208 | 245 | | |
209 | 246 | | |
210 | 247 | | |
| 248 | + | |
211 | 249 | | |
212 | 250 | | |
213 | 251 | | |
| |||
225 | 263 | | |
226 | 264 | | |
227 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
228 | 269 | | |
229 | 270 | | |
230 | 271 | | |
| |||
244 | 285 | | |
245 | 286 | | |
246 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
247 | 292 | | |
248 | 293 | | |
249 | 294 | | |
| |||
252 | 297 | | |
253 | 298 | | |
254 | 299 | | |
| 300 | + | |
255 | 301 | | |
256 | 302 | | |
257 | 303 | | |
| |||
261 | 307 | | |
262 | 308 | | |
263 | 309 | | |
| 310 | + | |
264 | 311 | | |
265 | 312 | | |
266 | 313 | | |
| |||
279 | 326 | | |
280 | 327 | | |
281 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
282 | 332 | | |
283 | 333 | | |
284 | 334 | | |
| |||
0 commit comments