Skip to content

Commit 7f90cb0

Browse files
authored
Merge pull request #12 from gitKrystan/docs
documentation: Update docs
2 parents de5722b + d127bc0 commit 7f90cb0

9 files changed

Lines changed: 134 additions & 76 deletions

File tree

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Try it out
2+
3+
1. Edit `example.gjs` or `example.gts` to make the ugliest component file you can think of.
4+
1. Run `pnpm run example` or `pnpm run example-ts`
5+
6+
## Prior art and useful links
7+
8+
https://prettier.io/docs/en/plugins.html#developing-plugins
9+
10+
https://medium.com/@fvictorio/how-to-write-a-plugin-for-prettier-a0d98c845e70
11+
12+
https://github.com/ember-template-imports/ember-template-imports/blob/master/src/preprocess-embedded-templates.ts#L180
13+
14+
https://github.com/ember-template-imports/ember-template-imports/blob/master/src/parse-templates.ts
15+
16+
https://github.com/glimmerjs/glimmer-experimental/tree/master/packages/%40glimmerx/prettier-plugin-component-templates
17+
18+
https://github.com/ember-template-lint/ember-template-lint/pull/2483/files
19+
20+
https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAgGEItoECAzHE-AcgAEBzAGw3ThwHpJSpzaA3AB0oI-PgDaAfSkBxADIBJALLKAogCUpAFTXKACvICCugBQADEWPwAeABYBGAHzj8ACTjNmEfAHVczAAm+A7unt5+AcEOHl4+-jhBIbERCUkx4fFRyZmRidEpWfk5cXnphWXR4jacjk4i5gA0+MD4AM4wOKhgMMoQgXBI+J0ArnD4AL4AlAC6VlCQUB346CPMMKisfPgAvJIyCirqWroGxmaWolDVda4VacEATGGlD-iP99kfuW-fr1+fYp-VIAn5faq1ZwNZqtDpdHp9AZDUbjaZzK6cABUmLEmPwRmucAAHgBDLDMcayABSAGV8BRNuNoPgAO52bp2VnjMAk644EbXGB2cb6HBwGAbDj03D4al0zDMEaMVBQAB0uM4ImJ2Dw+AGFBJawIYGYJLabXwygAnsReORrMT4FBAhbbdg+LAWtZpHIlKpNDo9IYTGoLNYbs47mDigBmF4g2OApIxpPBFPR5Op-Dp-6JjNpiF1axNFrtTrdXr9QbDfmo2bzcRskkEPbmeDk5vjVjwHAk5jDOzN-CoC1QCAEEnDOAd+CXBuuBecTj4ABWI2Wk9Y-Z47FgIgmIEaIAgmA20DayFAJJw1BZ+mvCAvKD7LJJVovR4ARr2wABrcU0mScDyCqcDIAazBtHAX4-v+MA0pgJJgCqjDICiR7Tp+cCBAMgTyLyjAjCSjBwAAYrg6DNhsUCoc+IwwBAh4gHYMDoMwvjsvAbSIWAcA0o+qAbAAboJVrIOA5pMSqUF4KKxGUeBfZQUeK5tESNIoRSACKIzjmBSAQcpICITgMniZ+JJYcwTGYF0sC+KggRCsgAAcAAMR62RAUG+L2mDibZcAyUJYFHgAjrp8CiieT4gGaAC0fDYdhTFihFqBinJjAKQZSnQSAUHoKgaG1kebSaXAOl6YpkH5TAlkOU5djII8R6dCSmwobaOUgEFACsTHrnA2iWU+hn5UJYyKM65A0mAXSngSgQ0jAVoUjVUETBMQA
21+
22+
https://github.com/prettier/prettier/blob/main/commands.md
23+
24+
## Tests
25+
26+
`pnpm test`
27+
28+
## Bugs
29+
30+
HACKs and FIXMEs

README.md

Lines changed: 88 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,103 @@
1-
# Very WIP Prettier Support for Ember template tags
1+
# prettier-plugin-ember-template-tag
22

3-
## Try it out
3+
[![CI](https://github.com/gitKrystan/prettier-plugin-ember-template-tag/actions/workflows/ci.yml/badge.svg)](https://github.com/gitKrystan/prettier-plugin-ember-template-tag/actions/workflows/ci.yml)
4+
[![npm](https://img.shields.io/npm/v/prettier-plugin-ember-template-tag.svg)](https://www.npmjs.com/package/prettier-plugin-ember-template-tag)
5+
[![license](https://img.shields.io/npm/l/prettier-plugin-ember-template-tag.svg)](https://github.com/gitKrystan/prettier-plugin-ember-template-tag/blob/main/LICENSE.md)
46

5-
1. Edit `example.gjs` or `example.gts` to make the ugliest component file you can think of.
6-
1. Run `pnpm run example > temp.gjs` or `pnpm run example-ts > temp.gts`
7+
A [Prettier](https://prettier.io/) plugin for formatting [Ember template tags](https://rfcs.emberjs.com/id/0779-first-class-component-templates/).
78

8-
## Prior art and useful links
9+
## Usage
910

10-
https://prettier.io/docs/en/plugins.html#developing-plugins
11+
1. Install:
1112

12-
https://medium.com/@fvictorio/how-to-write-a-plugin-for-prettier-a0d98c845e70
13+
NPM:
1314

14-
https://github.com/ember-template-imports/ember-template-imports/blob/master/src/preprocess-embedded-templates.ts#L180
15+
```bash
16+
npm install --save-dev prettier prettier-plugin-ember-template-tag
17+
```
1518

16-
https://github.com/ember-template-imports/ember-template-imports/blob/master/src/parse-templates.ts
19+
Yarn:
1720

18-
https://github.com/glimmerjs/glimmer-experimental/tree/master/packages/%40glimmerx/prettier-plugin-component-templates
21+
```bash
22+
yarn add --save-dev prettier prettier-plugin-ember-template-tag
23+
```
1924

20-
https://github.com/ember-template-lint/ember-template-lint/pull/2483/files
25+
PNPM:
2126

22-
https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAgGEItoECAzHE-AcgAEBzAGw3ThwHpJSpzaA3AB0oI-PgDaAfSkBxADIBJALLKAogCUpAFTXKACvICCugBQADEWPwAeABYBGAHzj8ACTjNmEfAHVczAAm+A7unt5+AcEOHl4+-jhBIbERCUkx4fFRyZmRidEpWfk5cXnphWXR4jacjk4i5gA0+MD4AM4wOKhgMMoQgXBI+J0ArnD4AL4AlAC6VlCQUB346CPMMKisfPgAvJIyCirqWroGxmaWolDVda4VacEATGGlD-iP99kfuW-fr1+fYp-VIAn5faq1ZwNZqtDpdHp9AZDUbjaZzK6cABUmLEmPwRmucAAHgBDLDMcayABSAGV8BRNuNoPgAO52bp2VnjMAk644EbXGB2cb6HBwGAbDj03D4al0zDMEaMVBQAB0uM4ImJ2Dw+AGFBJawIYGYJLabXwygAnsReORrMT4FBAhbbdg+LAWtZpHIlKpNDo9IYTGoLNYbs47mDigBmF4g2OApIxpPBFPR5Op-Dp-6JjNpiF1axNFrtTrdXr9QbDfmo2bzcRskkEPbmeDk5vjVjwHAk5jDOzN-CoC1QCAEEnDOAd+CXBuuBecTj4ABWI2Wk9Y-Z47FgIgmIEaIAgmA20DayFAJJw1BZ+mvCAvKD7LJJVovR4ARr2wABrcU0mScDyCqcDIAazBtHAX4-v+MA0pgJJgCqjDICiR7Tp+cCBAMgTyLyjAjCSjBwAAYrg6DNhsUCoc+IwwBAh4gHYMDoMwvjsvAbSIWAcA0o+qAbAAboJVrIOA5pMSqUF4KKxGUeBfZQUeK5tESNIoRSACKIzjmBSAQcpICITgMniZ+JJYcwTGYF0sC+KggRCsgAAcAAMR62RAUG+L2mDibZcAyUJYFHgAjrp8CiieT4gGaAC0fDYdhTFihFqBinJjAKQZSnQSAUHoKgaG1kebSaXAOl6YpkH5TAlkOU5djII8R6dCSmwobaOUgEFACsTHrnA2iWU+hn5UJYyKM65A0mAXSngSgQ0jAVoUjVUETBMQA
27+
```bash
28+
pnpm add --save-dev prettier prettier-plugin-ember-template-tag
29+
```
2330

24-
https://github.com/prettier/prettier/blob/main/commands.md
31+
1. Configure with [prettierrc](https://prettier.io/docs/en/configuration.html):
2532

26-
## Tests
33+
```js
34+
// .prettierrc.js
35+
module.exports = {
36+
// ...
37+
plugins: ['prettier-plugin-ember-template-tag'],
38+
};
39+
```
2740

28-
`pnpm test`
41+
1. Run `npm prettier --write .`
2942

30-
## TODOs and known issues
43+
## Ignoring code
3144

32-
- [ ] Fix HAX
33-
- [ ] Add tests
34-
- [ ] Verify quotes configuration works properly
45+
Because gts/gjs files include both JavaScript and Glimmer template code, you'll need to use the appropriate prettier-ignore comment for the code you are ignoring:
46+
47+
```js
48+
export default class MyComponent extends Component {
49+
// prettier-ignore
50+
cells = matrix(
51+
1, 0, 0,
52+
0, 1, 0,
53+
0, 0, 1
54+
)
55+
56+
<template>
57+
{{! prettier-ignore }}
58+
{{#each cells as |cell|}}{{cell.contents}}{{/each}}
59+
</template>
60+
}
61+
```
62+
63+
To ignore the entire template, use a JavaScript `//prettier-ignore` comment before the opening `<template>` tag:
64+
65+
```js
66+
export default class MyComponent extends Component {
67+
// prettier-ignore
68+
<template>
69+
This whole template is ignored
70+
<MyUglyComponent "shall" be="preserved">
71+
<ThisPart
72+
is = "also preserved as is"
73+
/>
74+
</MyUglyComponent>
75+
</template>
76+
}
77+
```
78+
79+
## Bugs
80+
81+
If there are errors, please file a bug report so that they can be fixed.
82+
83+
TODO: Process
84+
85+
## Opinions
86+
87+
TODO: link to RFC
88+
89+
<!-- TODO: ### Configuration
90+
91+
These configuration options are available in addition to [Prettier's standard
92+
config for JavaScript files](https://prettier.io/docs/en/configuration.html).
93+
94+
| Name | Default | Description |
95+
| --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
96+
| `templatePrintWidth` | `80` | [Same as in Prettier](https://prettier.io/docs/en/options.html#print-width) but affecting only template tags |
97+
| `templateSingleQuote` | `false` | Same as in Prettier](https://prettier.io/docs/en/options.html#print-width) but affecting only template tags | -->
98+
99+
<!-- ## Editor integration
100+
101+
### VScode
102+
103+
TODO -->

RELEASE.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,26 @@ When reviewing merged PR's the labels to be used are:
2323

2424
## Release
2525

26-
Once the prep work is completed, the actual release is straight forward:
26+
### CI
2727

28-
- First, ensure that you have obtained a [GitHub personal access token][generate-token] with the `repo` scope (no other permissions are needed). Make sure the token is available as the `GITHUB_TOKEN` environment variable.
28+
Click "Run workflow" [here](https://github.com/gitKrystan/prettier-plugin-ember-template-tag/actions/workflows/release.yml).
29+
30+
### Manual
31+
32+
- First, ensure that you have obtained a [GitHub personal access token][generate-token] with the `repo` scope (no other permissions are needed). Make sure the token is available as the `GITHUB_AUTH` environment variable.
2933

3034
For instance:
3135

3236
```bash
33-
export GITHUB_TOKEN=abc123def456
37+
export GITHUB_AUTH=abc123def456
3438
```
3539

36-
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_TOKEN+env+variable
40+
[generate-token]: https://github.com/settings/tokens/new?scopes=repo&description=GITHUB_AUTH+env+variable
3741

3842
- Then do your release. If you're nervous, try `pnpm release:debug` first.
3943

40-
```sh
41-
pnpm release
42-
```
44+
```bash
45+
pnpm release
46+
```
4347

4448
[release-it](https://github.com/release-it/release-it/) manages the actual release process. It will prompt you to to choose the version number after which you will have the chance to hand tweak the changelog to be used (for the `CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging, pushing the tag and commits, deploying the docs, etc.
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"name": "Krystan HuffMenne"
1515
},
1616
"type": "commonjs",
17-
"main": "dist/prettier-plugin-ember-template-tag.cjs",
17+
"main": "dist/prettier-plugin-ember-template-tag.js",
1818
"license": "MIT",
1919
"repository": {
2020
"type": "git",
@@ -30,8 +30,8 @@
3030
"scripts": {
3131
"dev": "vite",
3232
"build": "tsc && vite build",
33-
"example": "vite build && ./node_modules/.bin/prettier --plugin . example.gjs > temp.gjs",
34-
"example-ts": "vite build && ./node_modules/.bin/prettier --plugin . example.gts",
33+
"example": "vite build && ./node_modules/.bin/prettier --plugin . --write examples/example.gjs",
34+
"example-ts": "vite build && ./node_modules/.bin/prettier --plugin . --write examples/example.gts",
3535
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
3636
"lint:fix": "npm-run-all --aggregate-output --continue-on-error --parallel lint:*:fix",
3737
"lint:eslint": "eslint . --cache",

src/print/template.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export function printTemplateTag(
3434
const contents = textToDoc(text.trim(), {
3535
...options,
3636
parser: 'glimmer',
37-
// TODO: Support glimmerTemplateSingleQuote option
38-
// singleQuote: options.hbsSingleQuote,
37+
// TODO: Support templateSingleQuote option
38+
// singleQuote: options.templateSingleQuote,
3939
});
4040
return group([
4141
TEMPLATE_TAG_OPEN,

temp.gjs

Lines changed: 0 additions & 22 deletions
This file was deleted.

temp.gts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)