-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Node requires that ESM imports must always have an extension. Fixes #5
- Loading branch information
Showing
16 changed files
with
84 additions
and
39 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
pnpm-lock.yaml | ||
docs |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
// typed-htmx declares mostly ambient types so this is all you need. | ||
import 'typed-htmx'; | ||
import "typed-htmx"; | ||
|
||
// A demo of how to augment foreign types with htmx attributes. | ||
// In this case, Hono sources its types from its own namespace, so we do the same | ||
// and directly extend its namespace. | ||
declare global { | ||
namespace Hono { | ||
interface HTMLAttributes extends HtmxAttributes {} | ||
} | ||
namespace Hono { | ||
interface HTMLAttributes extends HtmxAttributes {} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
// This is (usually) the only setting to change when swapping renderers. | ||
"jsxImportSource": "hono/jsx" | ||
} | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
// This is (usually) the only setting to change when swapping renderers. | ||
"jsxImportSource": "hono/jsx" | ||
} | ||
} |
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,28 @@ | ||
id: no-extensionless-relative-import | ||
message: Relative imports must end in .js | ||
severity: error | ||
language: ts | ||
rule: | ||
pattern: "$IMPORT" | ||
regex: "/([^.]+)[^/]$" | ||
kind: string_fragment | ||
any: | ||
- inside: | ||
stopBy: end | ||
kind: import_statement | ||
- inside: | ||
stopBy: end | ||
kind: export_statement | ||
- inside: | ||
stopBy: end | ||
kind: call_expression | ||
has: | ||
field: function | ||
regex: "^import$" | ||
transform: | ||
OUTPUT: | ||
replace: | ||
replace: '.*' | ||
by: '$0.js' | ||
source: $IMPORT | ||
fix: "$OUTPUT" |
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,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euxo pipefail | ||
rm -rf ./dist | ||
tsc -b | ||
tsc -p tsconfig.esm.json | ||
echo '{"type":"module"}' > ./dist/esm/package.json |
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 @@ | ||
ruleDirs: [rules] |
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
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 |
---|---|---|
@@ -1,11 +1,19 @@ | ||
describe("html templator", () => { | ||
it("works", () => { | ||
expect(<div data-foo={123} />).toBe('<div data-foo="123" />'); | ||
expect(<div data-foo={123} />).toBe('<div data-foo="123"></div>'); | ||
}); | ||
it("processes json attributes", () => { | ||
expect(<div hx-vals={{ foo: "It's joever" }} />).toBe(`<div hx-vals='{"foo":"It's joever"}'/>`); | ||
expect(<div hx-vals={{ foo: "It's joever" }} />).toBe(`<div hx-vals='{"foo":"It's joever"}'></div>`); | ||
}); | ||
it("skips falsy attributes", () => { | ||
expect(<div data-foo={false} {...{ foobar: false }} />).toBe("<div />"); | ||
expect(<div data-foo={false} {...{ foobar: false }} />).toBe("<div></div>"); | ||
}); | ||
it("correctly handles void elements", () => { | ||
expect( | ||
<> | ||
<img /> | ||
<br /> | ||
</>, | ||
).toBe("<img><br>"); | ||
}); | ||
}); |
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