Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
new-component
Advanced tools
This project is a CLI tool that allows you to quickly scaffold new components. All of the necessary boilerplate will be generated automatically.
This project uses an opinionated file structure discussed in this blog post: Delightful React File/Directory Structure.
NOTE: This project is not actively maintained. I continue to use it in my own projects, but I don't have the bandwidth to review PRs or triage issues. Feel free to fork this project and tweak it however you wish. ❤️
Version 5: The new version adds support for TypeScript, and removes support for passing a custom file extension;
Install via NPM:
# Using Yarn:
$ yarn global add new-component
# or, using NPM
$ npm i -g new-component
cd
into your project's directory, and try creating a new component:
$ new-component MyNewComponent
Your project will now have a new directory at src/components/MyNewComponent
. This directory has two files:
// `MyNewComponent/index.js`
export { default } from './MyNewComponent';
// `MyNewComponent/MyNewComponent.js`
import React from 'react';
function MyNewComponent() {
return <div></div>;
}
export default MyNewComponent;
These files will be formatted according to your Prettier configuration.
Configuration can be done through 3 different ways:
.new-component-config.json
in your home directory (~/.new-component-config.json
)..new-component-config.json
in your project's root directory.The resulting values are merged, with command-line values overwriting local values, and local values overwriting global ones.
Controls which language, JavaScript or TypeScript, should be used.
js
— creates a .jsx
file (default).ts
— creates a .tsx
file.As of Version 6, JavaScript files always have the .jsx
extension, since Vite doesn’t tolerate JSX inside .js
files. If you wish to keep generating .js
files, you can use Version 5, or fork this project and change this line.
Usage:
Command line: --lang <value>
or -l <value>
JSON config: { "lang": <value> }
Controls the desired directory for the created component. Defaults to src/components
Usage:
Command line: --dir <value>
or -d <value>
JSON config: { "dir": <value> }
This has only been tested in macOS. I think it'd work fine in linux, but I haven't tested it. Windows is a big question mark.
If you try to use this package with the Next.js App Router, you’ll run into an error:
**Syntax error:** the name `default` is exported multiple times
This issue is described in depth in my blog post about this package. To solve this problem, you’ll need to fork this library and remove the wildcard export.
To get started with development:
cd
into the directory and install dependencies (yarn install
or npm install
)npm link
, while in the new-component
directory. This will ensure that the new-component
command uses this locally-cloned project, rather than the global NPM installation.new-component
command to create components and test that your changes are working.FAQs
CLI for creating new React components
The npm package new-component receives a total of 156 weekly downloads. As such, new-component popularity was classified as not popular.
We found that new-component demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.