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 support for specifying package manager #91

Open
idkgene opened this issue Dec 25, 2024 · 4 comments
Open

Add support for specifying package manager #91

idkgene opened this issue Dec 25, 2024 · 4 comments
Labels
status: wip is being worked on by someone

Comments

@idkgene
Copy link

idkgene commented Dec 25, 2024

What is the problem you're trying to solve?

Currently, when initializing a new stylelint configuration using npm init stylelint, the process implicitly assumes the use of npm as the package manager. This can be inconvenient for projects that utilize other package managers like pnpm or yarn. For instance, as demonstrated in the provided terminal output, when initializing ESLint with @eslint/config, the tool explicitly asks "Which package manager do you want to use?".

1. Example eslint init output:

npm init @eslint/config@latest
Need to install the following packages:
@eslint/[email protected]
Ok to proceed? (y) y


> [email protected] npx
> create-config

@eslint/create-config: v1.4.0

√ How would you like to use ESLint? · problems    
√ What type of modules does your project use? · esm
√ Which framework does your project use? · none
√ Does your project use TypeScript? · typescript
√ Where does your code run? · browser
The config that you've selected requires the following dependencies:

eslint, globals, @eslint/js, typescript-eslint
√ Would you like to install them now? · No / Yes
√ Which package manager do you want to use? · pnpm
☕️Installing...

When stylelint initializes and installs dependencies, it uses npm. If a project is using pnpm, for example, the developer then needs to manually manage the dependencies. This extra step can be streamlined.

2. Example stylelint init output:

> [email protected] npx
> create-stylelint

✔ Created .stylelintrc.json.
✔ Installed packages.

You can now lint your CSS files using:
npx stylelint "**/*.css"

We recommend customizing Stylelint:
https://stylelint.io/user-guide/customize/

What solution would you like to see?

I propose adding an interactive option during the npm init stylelint process that allows users to select their preferred package manager. This could be implemented as a prompt similar to the one used by @eslint/create-config.

Which package manager do you want to use for installing dependencies?
  npm
> pnpm
  yarn
@idkgene
Copy link
Author

idkgene commented Dec 25, 2024

The @eslint/create-config utility provides a good reference implementation for this. Specifically, it uses the installSyncSaveDev function to handle package installations, allowing the user's choice of package manager to be respected. Adopting a similar approach in stylelint would greatly improve the UX for those not using npm.

UPD: Another point of friction is the requirement for a package.json file to exist before running npm init stylelint. The command fails if package.json is missing, requiring the user to manually create it using npm init. Perhaps the tool could prompt the user to create one without throwing an error or even generate a basic package.json file automatically if one is not found.

I would be happy to contribute a Pull Request to implement this feature.

@Mouvedia
Copy link
Member

Mouvedia commented Dec 25, 2024

@jeddy3 can you transfer this issue to stylelint/create-stylelint?

@idkgene
Copy link
Author

idkgene commented Dec 25, 2024

@jeddy3 can you transfer this issue to stylelint/create-stylelint?

Yep, I've found I've posted this in the wrong repo right after opening this. Sorry about that. Working on a PR rn. When the issue is transfered I'm opening it

UPD: Ready with the PR.

@jeddy3 jeddy3 changed the title Allow specifying package manager during stylelint initialization Add support for specifying package manager Dec 25, 2024
@jeddy3 jeddy3 added the status: wip is being worked on by someone label Dec 25, 2024
@jeddy3 jeddy3 transferred this issue from stylelint/stylelint Dec 25, 2024
@jeddy3
Copy link
Member

jeddy3 commented Dec 25, 2024

@idkgene Thank you for the clearly-written suggestion and for preparing a PR. I've transferred the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: wip is being worked on by someone
Projects
None yet
Development

No branches or pull requests

3 participants