fresh icon indicating copy to clipboard operation
fresh copied to clipboard

kebab-case files not supported for islands

Open delanebob opened this issue 2 years ago • 5 comments

I started a project using the project creation tool and included twind for styling. I generally use kebab-case for file names to avoid case clashing.

I have ran into an issue when running the locally (haven't tried in deno deploy) where it's using the name in the code. But it's getting Unexpected token '-' as you can't use a dash in a variable name/import reference.

Import of island in my code: import DarkModeButton from "../islands/dark-mode-button.tsx";

Import in rendered code: Screenshot 2022-07-04 at 00 31 04

Error in console Uncaught SyntaxError: Unexpected token '-' (at (index):64:12)

You can even rename the counter island that comes with the project to reproduce the issue.

delanebob avatar Jul 04 '22 00:07 delanebob

I have just created a PR to fix the issue I was having above. If someone could leave some feedback, that would be great.

https://github.com/denoland/fresh/pull/404

delanebob avatar Jul 04 '22 11:07 delanebob

Just don't use a kebab-case. PascalCase is a generally accepted naming convention for .tsx/.jsx components/islands. Doing otherwise, in my opinion, should be strongly discouraged in order to preserve the convention.

synalice avatar Jul 05 '22 11:07 synalice

I would disagree with you there as some companies have moved away from this naming convention as it can get confusing when having one convention for components (PascalCase) vs page routes (kebab-case).

This can lead some developers to using the wrong convention for some areas of the app and when asked to change it, they can run into issues similar to the one linked below. This is why it can be just easier to go with kebab-case for all filenames.

https://twitter.com/kentcdodds/status/1361536960876085248?s=20

delanebob avatar Jul 05 '22 13:07 delanebob

It's true that pascal case is an extremely pervasive convention, but it also is a source of a lot of last-minute bugs because different operating systems have different case sensitivity. It's not a good convention, but even worse, there's literally no reason to ban the one that is less error-prone.

thebearingedge avatar Jul 07 '22 22:07 thebearingedge

Well, yea, I guess I agree with you. This kebab-case does seem like a good naming practice.

Anyway, I think that this issues can be closed since the PR #404 about it has been merged. @lucacasonato

synalice avatar Jul 08 '22 14:07 synalice

Is there more work to be done (are there any file-naming bugs remaining, and if so should they be raised in this issue) or should this issue be closed @lucacasonato?

lino-levan avatar Sep 06 '22 15:09 lino-levan

@lino-levan this can be closed as the change I made to support kebab-case islands was released as part of 1.0.2

delanebob avatar Sep 06 '22 17:09 delanebob