layout | title |
---|---|
default |
Help |
- Write only one statement
// bad
const inputs = [
`
$.isArray(foobar)
throw Error()
`
]
const outputs = [
`
Array.isArray(foobar)
throw new Error()
`
]
// good
const inputs = [
"$.isArray(foobar);"
]
const outputs = [
"Array.isArray(foobar);"
]
- Write same node type
// bad
const inputs = [
"$.isArray(foobar)",
"throw Error()",
]
const outputs = [
"Array.isArray(foobar)",
"throw new Error()",
]
// good
const inputs = [
"$.isArray(foobar)",
"$.isArray(array)",
]
const outputs = [
"Array.isArray(foobar)",
"Array.isArray(array)",
]
- Write as small as possible
// bad
const inputs = [
`
class PasswordField extends React.Component {
render() {
return <Field name="password" type="password" />
}
}
`
]
const outputs = [
`
class PasswordField extends React.Component {
render() {
return <Field name="password" type="password" autoComplete="current-password" />
}
}
`
]
// good
const inputs = ['<Field name="password" type="password" />']
const outputs = ['<Field name="password" type="password" autoComplete="current-password" />']