Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
github.com/vscodeshift/material-ui-codemorphs
sweet codemod commands for everyday work with Material UI ✨
Position the cursor inside a funcitonal component before running this command.
Wraps the functional component in withStyles
,
adds a const styles = (theme: Theme) => ({ })
declaration,
and adds a classes
type annotation and prop destructuring if possible.
Supports Flow, TypeScript, and plain JS!
You can override where the Theme
type is imported from by adding the following to your package.json
:
{
"material-ui-codemorphs": {
"themeImport": "import { type Theme } from './src/universal/theme'"
}
}
You can override where makeStyles
is imported from by adding the following to your package.json
:
{
"material-ui-codemorphs": {
"makeStylesImport": "import { makeStyles } from '@material-ui/core'"
}
}
import * as React from 'react'
interface Props {
text: string
}
export const Test = ({ text }: Props): React.ReactNode => <div>{text}</div>
import * as React from 'react'
+ import { makeStyles, Theme } from '@material-ui/core/styles'
interface Props {
text: string
}
+ const useStyles = makeStyles((theme: Theme) => ({}))
- export const Test = ({ text }: Props): React.ReactNode => (
- <div>{text}</div>
- )
+ export const Test = ({ text }: Props): React.ReactNode => {
+ const classes = useStyles()
+ return <div>{text}</div>
+ }
Position the cursor inside a component before running this command.
Wraps the component in withStyles
,
adds a const styles = (theme: Theme) => ({ })
declaration,
and adds a classes
type annotation and prop destructuring if possible.
Supports Flow, TypeScript, and plain JS!
You can override where the Theme
type is imported from by adding the following to your package.json
:
{
"material-ui-codemorphs": {
"themeImport": "import { type Theme } from './src/universal/theme'"
}
}
You can override where withStyles
is imported from by adding the following to your package.json
:
{
"material-ui-codemorphs": {
"withStylesImport": "import { withStyles } from '@material-ui/core'"
}
}
import * as React from 'react'
interface Props {
text: string
}
const Test = ({ text }: Props): React.ReactNode => {
return <div>{text}</div>
}
import * as React from 'react'
+ import { withStyles, Theme, WithStyles } from '@material-ui/core/styles'
- interface Props {
+ interface Props extends WithStyles<typeof styles> {
text: string
}
+ const styles = (theme: Theme) => ({})
- const Test = ({ text }: Props): React.ReactNode => {
+ const TestWithStyles = ({ text, classes }: Props): React.ReactNode => {
<div>{text}</div>
}
+ const Test = withStyles(styles)(TestWithStyles)
Creates/updates the declaration for Box
based upon which props you pass to
<Box>
elements in your code.
import * as React from 'react'
const Foo = () => (
<Box
sm={{ marginLeft: 2, fontSize: 12 }}
md={{ marginLeft: 3, fontSize: 16 }}
/>
)
const Bar = () => <Box boxShadow={1} />
import * as React from 'react'
+ import { styled } from '@material-ui/styles'
+ import {
+ spacing,
+ typography,
+ shadows,
+ breakpoints,
+ compose,
+ } from '@material-ui/system'
+ const Box = styled('div')(breakpoints(compose(shadows, spacing, typography)))
const Foo = () => (
<Box
sm={{ marginLeft: 2, fontSize: 12 }}
md={{ marginLeft: 3, fontSize: 16 }}
/>
)
const Bar = () => <Box boxShadow={1} />
FAQs
Unknown package
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
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.