Comments (15)
I'm using VScode and below is the config I wrote to omit the final newline in hbs
settings.json
"[handlebars]": {
"files.insertFinalNewline": false
},
from ember-template-lint-plugin-prettier.
the --fix
still removes the newline at EOF. Any updates on this? We have configured our IDEs to auto insert new line at EOF. Running npm run lint:hbs
throws error error Delete ⏎
Is there any way to not remove the newline at EOF while running npm run lint:hbs:fix
OR is there any way to ignore this error? error Delete ⏎
My .template-lintrc.js
'use strict';
module.exports = {
plugins: ['ember-template-lint-plugin-prettier'],
extends: ['octane', 'ember-template-lint-plugin-prettier:recommended'],
rules: {
"eol-last": "always"
}
};
I have explicitly mentioned "eol-last": "always"
. So now,
- when there is no new line it throws
error template must end with newline eol-last
- when there is new line it throws
error Delete
⏎prettier
from ember-template-lint-plugin-prettier.
Hey @jcardali,
This is actually an expected behavior of Prettier. Indeed, Prettier for handlebars does remove the newline at EOF. I made one attempt at changing that: see prettier/prettier#6243 but it would require more work to refine the approach.
from ember-template-lint-plugin-prettier.
Opened josephfrazier/editorconfig-to-prettier#8
from ember-template-lint-plugin-prettier.
Thanks for the quick response @dcyriller! Will definitely be keeping my eye on the PR you opened.
For the sake of completeness, I also investigated whether this issue was surmountable with ember-template-lint
's eol-last
rule, and sadly it was not :(
from ember-template-lint-plugin-prettier.
When you use Prettier to format your templates, it's recommended to turn ember-template-lint's stylistic
preset off (eol-last
rule belongs to that set). To do so, you would remove it from your .template-lintrc.js. :)
from ember-template-lint-plugin-prettier.
When you use Prettier to format your templates, it's recommended to turn ember-template-lint's
stylistic
preset off (eol-last
rule belongs to that set). To do so, you would remove it from your .template-lintrc.js. :)
Yep, just did it out of curiousity.
from ember-template-lint-plugin-prettier.
Okay, then it doesn't work when you specify eol-last: "never"
? Or eol-last: "editorconfig"
?
from ember-template-lint-plugin-prettier.
Okay, then it doesn't work when you specify
eol-last: "never"
? Oreol-last: "editorconfig"
?
"never" only seemingly works because that is the default behavior of Pretter in this case. We have insert_final_newline = true
at the top level of our repo, and "editorconfig" does not work.
from ember-template-lint-plugin-prettier.
Hi @dcyriller, any update on this?
from ember-template-lint-plugin-prettier.
editorconfig-to-prettier now supports the insert_final_newline
option.
Next step would be to use the option in Prettier's handlebars printer.
from ember-template-lint-plugin-prettier.
Seems like there is support for that approach prettier/prettier#9067.
I looked at this a bit today, I am not seeing how exactly to achieve it without having minimist throw a warning...
from ember-template-lint-plugin-prettier.
It will have to be probably implemented on this line: https://github.com/prettier/prettier/blob/2.1.2/src/language-handlebars/printer-glimmer.js#L51
from ember-template-lint-plugin-prettier.
Hi @rinoldsimon,
the --fix still removes the newline at EOF.
This is expected. Indeed, Prettier will always remove the last eol for now.
I have opened prettier/prettier#10759 to read insert_final_newline
from editorconfig and insert a final newline if insert_final_newline is true. You can follow there to see if the PR is accepted.
We have configured our IDEs to auto insert new line at EOF. Running npm run lint:hbs throws error error Delete ⏎
As a workaround, you could change your editor config to insert final newlines for all files but hbs.
from ember-template-lint-plugin-prettier.
I would like to understand the use case better. Mainly to decide if this should be considered a blocker for emberjs/rfcs#777.
Why do you want to have a final new line in Ember / Glimmer templates?
from ember-template-lint-plugin-prettier.
Related Issues (20)
- Support latest ember-template-lint and prettier HOT 2
- peerDeps don't cover latest ember-template-lint or prettier versions HOT 5
- Update documentation to no longer say Prettier support is experimental HOT 1
- Thank you HOT 2
- `Delete ⏎⏎⏎⏎⏎⏎⏎⏎⏎⏎⏎····················· (fixable)` always appears in test files HOT 3
- Deprecation warning added to base rule's log method in v3.8.0
- Add release-it setup HOT 4
- Shouldn't the `no-whitespace-for-layout` be disabled by this plugin? HOT 2
- Single quotes inside curlies and double quotes outside is not possible HOT 2
- Not compatible with ember-template-lint v4 HOT 2
- Not compatible with ember-template-lint v4 HOT 2
- Does not work in monorepos HOT 4
- Integration with Prettier VSC extension HOT 6
- Support ember-template-lint v5 HOT 3
- Release new version supporting ember-template-lint v5 HOT 1
- Incorrect linting of `.gjs` files with `<template>` ttags HOT 8
- Doesn't work with Prettier v3
- Regression {{#else if}} are splitted into {{else}}{{#if}} HOT 6
- Cannot serialize worker response HOT 2
- Re-formatting inline hbs tags in tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-template-lint-plugin-prettier.