chore(eslint): curly [skip-lint] (#7959)
Now enforcing curly brackets on all if statements. Includes auto-fixer. ```ts // ❌ Bad if (foo) foo++; // ✅ Good if (foo) { foo++; } ``` Note: this did not lint the `drizzle` package or any `db-*` packages. This will be done in the future.
This commit is contained in:
@@ -13,7 +13,9 @@ export const richTextValidate: Validate<
|
||||
const { t } = req
|
||||
if (required) {
|
||||
const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue)
|
||||
if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true
|
||||
if (value && JSON.stringify(value) !== stringifiedDefaultValue) {
|
||||
return true
|
||||
}
|
||||
return t('validation:required')
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,9 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
const isButton = child.tagName === 'BUTTON'
|
||||
const isDisabling = clickState === 'disabled'
|
||||
child.setAttribute('tabIndex', isDisabling ? '-1' : '0')
|
||||
if (isButton) child.setAttribute('disabled', isDisabling ? 'disabled' : null)
|
||||
if (isButton) {
|
||||
child.setAttribute('disabled', isDisabling ? 'disabled' : null)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -307,7 +309,9 @@ const RichTextField: React.FC<LoadedSlateFieldProps> = (props) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (!valueToRender) valueToRender = defaultRichTextValue
|
||||
if (!valueToRender) {
|
||||
valueToRender = defaultRichTextValue
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -23,8 +23,12 @@ export const createFeatureMap = (
|
||||
}
|
||||
}
|
||||
|
||||
if (key.startsWith('leaf.button.')) features.leaves[leafName].Button = value
|
||||
if (key.startsWith('leaf.component.')) features.leaves[leafName].Leaf = value
|
||||
if (key.startsWith('leaf.button.')) {
|
||||
features.leaves[leafName].Button = value
|
||||
}
|
||||
if (key.startsWith('leaf.component.')) {
|
||||
features.leaves[leafName].Leaf = value
|
||||
}
|
||||
}
|
||||
|
||||
if (key.startsWith('element.button.') || key.startsWith('element.component.')) {
|
||||
@@ -38,8 +42,12 @@ export const createFeatureMap = (
|
||||
}
|
||||
}
|
||||
|
||||
if (key.startsWith('element.button.')) features.elements[elementName].Button = value
|
||||
if (key.startsWith('element.component.')) features.elements[elementName].Element = value
|
||||
if (key.startsWith('element.button.')) {
|
||||
features.elements[elementName].Button = value
|
||||
}
|
||||
if (key.startsWith('element.component.')) {
|
||||
features.elements[elementName].Element = value
|
||||
}
|
||||
}
|
||||
|
||||
if (key.startsWith('leaf.plugin.') || key.startsWith('element.plugin.')) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { Editor, Element } from 'slate'
|
||||
|
||||
export const isElementActive = (editor: Editor, format: string, blockType = 'type'): boolean => {
|
||||
if (!editor.selection) return false
|
||||
if (!editor.selection) {
|
||||
return false
|
||||
}
|
||||
|
||||
const [match] = Array.from(
|
||||
Editor.nodes(editor, {
|
||||
|
||||
@@ -3,7 +3,9 @@ import { Editor, Element } from 'slate'
|
||||
import { nodeIsTextNode } from '../../types.js'
|
||||
|
||||
export const isLastSelectedElementEmpty = (editor: Editor): boolean => {
|
||||
if (!editor.selection) return false
|
||||
if (!editor.selection) {
|
||||
return false
|
||||
}
|
||||
|
||||
const currentlySelectedNodes = Array.from(
|
||||
Editor.nodes(editor, {
|
||||
|
||||
@@ -3,10 +3,14 @@ import { Editor, Element } from 'slate'
|
||||
import { getCommonBlock } from './getCommonBlock.js'
|
||||
|
||||
export const isListActive = (editor: Editor, format: string): boolean => {
|
||||
if (!editor.selection) return false
|
||||
if (!editor.selection) {
|
||||
return false
|
||||
}
|
||||
const [topmostSelectedNode, topmostSelectedNodePath] = getCommonBlock(editor)
|
||||
|
||||
if (Editor.isEditor(topmostSelectedNode)) return false
|
||||
if (Editor.isEditor(topmostSelectedNode)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const [match] = Array.from(
|
||||
Editor.nodes(editor, {
|
||||
|
||||
@@ -46,7 +46,9 @@ const insertChange = (editor, fields) => {
|
||||
url: data.url,
|
||||
}
|
||||
|
||||
if (data.fields) newNode.fields = data.fields
|
||||
if (data.fields) {
|
||||
newNode.fields = data.fields
|
||||
}
|
||||
|
||||
Transforms.setNodes(editor, newNode, { at: parentPath })
|
||||
|
||||
@@ -214,7 +216,9 @@ export const LinkElement = () => {
|
||||
className={[`${baseClass}__popup-toggler`].filter(Boolean).join(' ')}
|
||||
onClick={() => setRenderPopup(true)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') setRenderPopup(true)
|
||||
if (e.key === 'Enter') {
|
||||
setRenderPopup(true)
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
|
||||
@@ -9,8 +9,12 @@ import { unwrapList } from './unwrapList.js'
|
||||
export const toggleList = (editor: Editor, format: string): void => {
|
||||
let currentListFormat: string
|
||||
|
||||
if (isListActive(editor, 'ol')) currentListFormat = 'ol'
|
||||
if (isListActive(editor, 'ul')) currentListFormat = 'ul'
|
||||
if (isListActive(editor, 'ol')) {
|
||||
currentListFormat = 'ol'
|
||||
}
|
||||
if (isListActive(editor, 'ul')) {
|
||||
currentListFormat = 'ul'
|
||||
}
|
||||
|
||||
// If the format is currently active,
|
||||
// remove the list
|
||||
|
||||
@@ -61,11 +61,12 @@ export const getGenerateComponentMap =
|
||||
const ElementButton = element.Button
|
||||
const ElementComponent = element.Element
|
||||
|
||||
if (ElementButton)
|
||||
if (ElementButton) {
|
||||
componentMap.set(
|
||||
`element.button.${element.name}`,
|
||||
createMappedComponent(ElementButton, undefined, undefined, 'slate-ElementButton'),
|
||||
)
|
||||
}
|
||||
componentMap.set(
|
||||
`element.component.${element.name}`,
|
||||
createMappedComponent(ElementComponent, undefined, undefined, 'slate-ElementComponent'),
|
||||
|
||||
Reference in New Issue
Block a user