Skip to content

Commit 554776e

Browse files
committed
chore: update copilot instructions
1 parent fedfcd4 commit 554776e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/copilot-instructions.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ If you run `xc` you can get see a list of the development tasks that can be run,
2323
The most useful tasks for local development are:
2424

2525
* `xc install-snapshot` - builds the templ CLI and installs it into `~/bin`. Ensure that this is in your path.
26+
* `xc generate` - generates Go code from the templ files in the project.
2627
* `xc test` - regenerates all templates, and runs the unit tests.
2728
* `xc fmt` - runs `gofmt` to format all Go code.
2829
* `xc lint` - run the same linting as run in the CI process.
2930
* `xc docs-run` - run the Docusaurus documentation site.
3031

3132
templ has a code generation step, this is automatically carried out using `xc test`.
3233

34+
Don't install templ globally using `xc install-snapshot` or `go install`. Use the `xc generate` or `xc test` tasks to generate the code, which will also run the tests.
35+
3336
## Commit messages
3437

3538
The project using https://www.conventionalcommits.org/en/v1.0.0/
@@ -60,3 +63,24 @@ Examples:
6063
* Use the `xc fmt` and `xc lint` build tasks to format and lint code before committing.
6164
* Don't use unnecessary comments that explain what the code does.
6265
* If comments are used, ensure that they are full sentences, and use proper punctuation, including ending with a full stop.
66+
67+
## Tests
68+
69+
* Tests for generated code are in the `./generator` directory. Each test is in a subdirectory.
70+
* Tests for the templ CLI are in the `./cmd/templ` directory.
71+
* Tests for the templ runtime are in the root directory.
72+
* Tests for formatting templ files are in `./parser/v2/formattestdata` - it uses txtar to store tests.
73+
* The `htmldiff` library does not take whitespace into account, so cannot be used to test output whitespace handling.
74+
* Don't attempt to run tests individually, use the `xc test` task to run all tests, because it regenerates templates, and there's minimal performance penalty due to Go's test caching.
75+
76+
## Moving and renaming files
77+
78+
* templ files have the `.templ` extension.
79+
* If a `project.templ` file is created, after generation a `project_templ.go` file will be created.
80+
* If a `project.templ` file is renamed, you must also rename the generated `project_templ.go` file.
81+
* If a `project.templ` file is moved, you must also move the generated `project_templ.go` file.
82+
* If a `project.templ` file is deleted, you must also delete the generated `project_templ.go` file.
83+
84+
# Files
85+
86+
* Don't attempt to create helper or utility tests in the `./tmp` or `/tmp` directory. Create unit tests in the relevant directory instead.

0 commit comments

Comments
 (0)