Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
jotai-label-ts-plugin
Advanced tools
Jotai is based on object references and not keys (like Recoil). This means there's no identifier for atoms. To identify atoms, it's possible to add a debugLabel
to an atom, which can be found in React devtools.
However, this can quickly become cumbersome to add a debugLabel
to every atom.
This ts plugin adds a debugLabel
to every atom, based on its identifier.
The plugin transforms this code:
export const countAtom = atom(0)
Into:
export const countAtom = atom(0)
countAtom.debugLabel = 'countAtom'
Default exports are also handled, based on the file naming:
// countAtom.ts
export default atom(0)
Which transform into:
// countAtom.ts
const countAtom = atom(0)
countAtom.debugLabel = 'countAtom'
export default countAtom
npm install jotai-label-ts-plugin --save-dev
With a webpack
configuration file:
const { join } = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { createJotaiLabelTransformer } = require('jotai-label-ts-plugin')
module.exports = {
entry: './tests/fixtures/simple.tsx',
output: {
filename: '[name].[hash].js',
path: join(process.cwd(), 'dist'),
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx'],
},
mode: 'development',
devtool: 'cheap-module-source-map',
module: {
rules: [
{
test: /\.(j|t)sx?$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
getCustomTransformers: () => ({
before: [
// <------------------- here
createJotaiLabelTransformer({
// this can add debug label to your own custom atom
customAtomNames: ['myCustomAtom']
}),
],
}),
compilerOptions: {
jsxFactory: 'jsx',
},
},
exclude: /node_modules/,
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader?minimize'],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: join(process.cwd(), 'tests', 'fixtures', 'index.html'),
}),
],
}
FAQs
TypeScript Jotai Debug Label Plugin
We found that jotai-label-ts-plugin demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.