-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds lint rules for
data-astro-reload
and data-astro-rerun
on scr…
…ipt tags (#965) * Adds transition:reload directive * add warnings and test * Update internal/printer/printer.go Co-authored-by: Happydev <[email protected]> * adds review suggestions and additional warning * Update internal/printer/printer.go * Update internal/printer/printer.go * adds review suggestions * warn on unsupported data-astro-rerun attribute on scripts * reactivate reload checks and tests * update changeset * with suggestios from review * fixes tests after merge --------- Co-authored-by: Happydev <[email protected]>
- Loading branch information
1 parent
4eaa5a9
commit d587ca6
Showing
4 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/compiler': patch | ||
--- | ||
|
||
Adds warnings indicating that the `data-astro-rerun` attribute can not be used on an external module `<script>` and that `data-astro-reload` is only supported on `<a>`, `<area>` and `<form>` elements. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { test } from 'uvu'; | ||
import * as assert from 'uvu/assert'; | ||
import { transform } from '@astrojs/compiler'; | ||
|
||
const FIXTURE = ` | ||
<div data-astro-reload> | ||
<a href="/" data-astro-reload>/</a> | ||
<form data-astro-reload="x">.</form> | ||
<area data-astro-reload/> | ||
<svg xmlns="http://www.w3.org/2000/svg"><a data-astro-reload>.</a></svg> | ||
<script is:inline data-astro-rerun src="some.js" type="module" /> | ||
<script is:inline data-astro-rerun>"Bar"</script> | ||
</div>`; | ||
|
||
test('Issues warnings for data-astro-* attributes', async () => { | ||
const result = await transform(FIXTURE); | ||
assert.equal(result.diagnostics.length, 3); | ||
assert.equal(result.diagnostics[0].code, 2000); | ||
assert.equal(result.diagnostics[1].code, 2005); | ||
assert.equal(result.diagnostics[2].code, 2010); | ||
}); | ||
|
||
test.run(); |