Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint rule for implicit is:inline on script tags. #970

Merged
merged 16 commits into from
Feb 21, 2024
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
lilnasy and sarah11918 authored Feb 20, 2024
commit 9b54fb747408e2afc5ec42703b878e4bd5c62bdc
2 changes: 1 addition & 1 deletion internal/transform/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,31 +412,31 @@
}
h.AppendHint(&loc.ErrorWithRange{
Code: loc.HINT,
Text: "Astro processes your script tags to allow using TypeScript and npm packages, and to optimize browser performance.\n\nAttributes cannot be used on Astro-processed script tags. Therefore, this script tag will be treated as if it has the `is:inline` directive, opting it out of the processing steps and its features.\n\nFor clarity, you might want to add the `is:inline` directive explicitly.\n\nSee docs for more details: https://docs.astro.build/en/guides/client-side-scripts/#script-processing.",
Text: "This script contains an attribute (ex: `type="module"`, `type="text/partytown"`, `async`) or a directive (`define:vars`) and will not be processed and bundled for optimized browser performance.\n\nThis script will be treated as if it has the `is:inline` directive and therefore features that require processing (e.g. using TypeScript or npm packages in the script) are unavailable.\n\nSee docs for more details: https://docs.astro.build/en/guides/client-side-scripts/#script-processing.",
Range: loc.Range{Loc: n.Attr[0].KeyLoc, Len: len(n.Attr[0].Key)},
})
}
}

Check failure on line 419 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / test-wasm (ubuntu-latest)

syntax error: unexpected module in composite literal; possibly missing comma or }

Check failure on line 419 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' in composite literal (typecheck)

Check failure on line 419 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected module in composite literal; possibly missing comma or }

Check failure on line 420 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / test-wasm (ubuntu-latest)

syntax error: unexpected ] in argument list; possibly missing comma or )

Check failure on line 420 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected ] in argument list; possibly missing comma or )
func AddComponentProps(doc *astro.Node, n *astro.Node, opts *TransformOptions) {

Check failure on line 421 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / test-wasm (ubuntu-latest)

syntax error: unexpected ) after top level declaration

Check failure on line 421 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected ) after top level declaration
if n.Type == astro.ElementNode && (n.Component || n.CustomElement) {
for _, attr := range n.Attr {
if strings.HasPrefix(attr.Key, "client:") {
parts := strings.Split(attr.Key, ":")
directive := parts[1]

Check failure on line 426 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' in composite literal (typecheck)

Check failure on line 427 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

expected operand, found 'for' (typecheck)
// Add the hydration directive so it can be extracted statically.

Check failure on line 428 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' in composite literal (typecheck)
doc.HydrationDirectives[directive] = true

hydrationAttr := astro.Attribute{
Key: "client:component-hydration",
Val: directive,

Check failure on line 433 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

expected '==', found '=' (typecheck)
}
n.Attr = append(n.Attr, hydrationAttr)

if attr.Key == "client:only" {
doc.ClientOnlyComponentNodes = append([]*astro.Node{n}, doc.ClientOnlyComponentNodes...)

Check failure on line 438 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

missing ',' before newline in composite literal (typecheck)

Check failure on line 439 in internal/transform/transform.go

View workflow job for this annotation

GitHub Actions / lint

expected '==', found '=' (typecheck)
match := matchNodeToImportStatement(doc, n)
if match != nil {
doc.ClientOnlyComponents = append(doc.ClientOnlyComponents, &astro.HydratedComponentMetadata{
Expand Down
Loading