
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@cozy/codemods
Advanced tools
A collection of utils and transforms for jscodeshift.
Codeshifts are automatic transformations of Javascript code. They can be used for
See jscodeshift-docs for more information on codeshifts.
Here are nice examples about import manipulation and React & JSX manipulation.
The API doc can be usefull too.
You can install @cozy/codemods globally so that you do not have to pollute your package.json and yarn.lock in every project where you use it.
yarn global add @cozy/codemods
$ cozy-codemods --help
$ cozy-codemods list # List available transforms
$ cozy-codemods showExample apply-flag # Show an example of what a transform does
$ cozy-codemods run apply-flag -- --flag=my-flag # Run a transform, pass jscodeshift args after --
Transforms flag()
calls into true
then remove dead code and dead imports
Before
import Old from 'old'
import New from 'new'
flag("hello") ? <Old /> : <New />
After
import New from 'new'
<New />
Simpler version of Apply flag only for boolean variables.
Before
import Old from 'old'
import New from 'new'
true ? <Old /> : <New />
After
<New />
hoc-replacer.js
remove-unused-imports.js
Removes unused imports by counting usage. JSX identifiers are counted as React usage.
Boolean
Returns true if path is Program or a Block
Replaces path.node
with newNode
without keeping blocks, flattening
newNode
into path
. Useful when removing if
/else
.
Statically evaluates boolean conditions
Removes unused imports by counting usage. JSX identifiers are counted as React usage.
Kind: global function
Param | Type |
---|---|
root | PathNode |
j | Object |
Boolean
Returns true if path is Program or a Block
Kind: global function
Param | Type |
---|---|
path | PathNode |
Replaces path.node
with newNode
without keeping blocks, flattening
newNode
into path
. Useful when removing if
/else
.
Kind: global function
Param | Type |
---|---|
path | PathNode |
newNode | Node |
Statically evaluates boolean conditions
Kind: global function
Param | Type |
---|---|
root | NodePath |
j | Object |
Example
`if (true) { foo } else { bar }` -> `foo`
`true ? foo : bar` -> `foo`
`!true ? foo : bar` -> `bar`
FAQs
Codeshifts used inside Cozies
The npm package @cozy/codemods receives a total of 34 weekly downloads. As such, @cozy/codemods popularity was classified as not popular.
We found that @cozy/codemods demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.