Skip to content

Rule request: kebab-case scripts #61

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

Open
Zamiell opened this issue Oct 30, 2023 · 4 comments
Open

Rule request: kebab-case scripts #61

Zamiell opened this issue Oct 30, 2023 · 4 comments
Labels
status: in discussion Not yet ready for implementation or a pull request type: feature New enhancement or request 🚀

Comments

@Zamiell
Copy link
Contributor

Zamiell commented Oct 30, 2023

It is conventional for scripts in the "package.json" file to be in kebab-case, as evidenced here:

Thus, this plugin should warn when incorrectly named scripts exist such as "fooBar" (i.e. camelCase) or "FooBar" (i.e. PascalCase) or "foo_bar" (i.e. snake_case) or "FOO_BAR" (i.e. SCREAMING_SNAKE_CASE).

@JoshuaKGoldberg
Copy link
Owner

Makes sense! I can see value in having a naming conventions rule that enforces kebab-case. Other efforts have popped up to standardize them too:

I think for the first few iterations of this rule we probably wouldn't want it to be enabled by default - as it's rather pedantic and doesn't directly catch runtime issues (only indirectly). But strong +1 to it existing.

Questions that I think would need to be resolved:

  • What other conventions exist?
  • What "preset" conventions should it allow?
  • How should it be configured, in general?

@JoshuaKGoldberg JoshuaKGoldberg added status: in discussion Not yet ready for implementation or a pull request type: feature New enhancement or request 🚀 labels Nov 6, 2023
@ic4l4s9c
Copy link

I'm interested in implementing this (as part of #903), so I'm curious to know what is the current stance on implementing naming conventions is.

In particular:

@michaelfaith
Copy link
Collaborator

I think it makes sense to have this be an opt-in configuration for valid-scripts, but I'm not sure that I'd recommend it being the default. Since it's going to be part of the recommended config, I'd propose the rule's default behavior sticks to purely validating that the shape is correct (i.e. an object with literal string values). I do like the idea of having an option to enforce conventional scripts. It's always good to have a standard to point to like that. What do you think @JoshuaKGoldberg?

@JoshuaKGoldberg
Copy link
Owner

JoshuaKGoldberg commented Feb 19, 2025

Good questions!

For the sake of doing one thing at a time, my vote is leaving it as a followup. It's non-trivial and I'm sure we'll discover edge cases to be discussed in review.

  • If so, should kebab-case be a default option?

Agreed that it should not be. This isn't an industry standard at all (yet?), so it would inconvenience a lot of users to have it enabled by default.

  • Any suggestions/recommendations on how should configuration look like?

Ideating: maybe an option value like "conventional" | "lowercase"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: in discussion Not yet ready for implementation or a pull request type: feature New enhancement or request 🚀
Projects
None yet
Development

No branches or pull requests

4 participants