mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-29 18:09:49 +02:00
Enforce 2-spaces indentation
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
"import/no-named-as-default": "error",
|
"import/no-named-as-default": "error",
|
||||||
"import/no-named-as-default-member": "error",
|
"import/no-named-as-default-member": "error",
|
||||||
"import/no-unresolved": "error",
|
"import/no-unresolved": "error",
|
||||||
|
"indent": ["error", 2],
|
||||||
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
|
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
|
||||||
"lines-around-comment": ["error", { "beforeBlockComment": true, "afterBlockComment": true }],
|
"lines-around-comment": ["error", { "beforeBlockComment": true, "afterBlockComment": true }],
|
||||||
"new-parens": "error",
|
"new-parens": "error",
|
||||||
|
@@ -21,14 +21,13 @@ function block(value) {
|
|||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'object': {
|
case 'object':
|
||||||
return Block.create(nodeProperties(value))
|
return Block.create(nodeProperties(value))
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid \`block\` argument! It must be a block, an object, or a string. You passed: "${value}".`)
|
throw new Error(`Invalid \`block\` argument! It must be a block, an object, or a string. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize an inline argument `value`.
|
* Normalize an inline argument `value`.
|
||||||
@@ -42,14 +41,13 @@ function inline(value) {
|
|||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'object': {
|
case 'object':
|
||||||
return Inline.create(nodeProperties(value))
|
return Inline.create(nodeProperties(value))
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid \`inline\` argument! It must be an inline, an object, or a string. You passed: "${value}".`)
|
throw new Error(`Invalid \`inline\` argument! It must be an inline, an object, or a string. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize a key argument `value`.
|
* Normalize a key argument `value`.
|
||||||
@@ -82,14 +80,13 @@ function mark(value) {
|
|||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'string':
|
case 'string':
|
||||||
case 'object': {
|
case 'object':
|
||||||
return Mark.create(markProperties(value))
|
return Mark.create(markProperties(value))
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid \`mark\` argument! It must be a mark, an object, or a string. You passed: "${value}".`)
|
throw new Error(`Invalid \`mark\` argument! It must be a mark, an object, or a string. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize a mark properties argument `value`.
|
* Normalize a mark properties argument `value`.
|
||||||
@@ -102,11 +99,11 @@ function markProperties(value = {}) {
|
|||||||
const ret = {}
|
const ret = {}
|
||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'string': {
|
case 'string':
|
||||||
ret.type = value
|
ret.type = value
|
||||||
break
|
break
|
||||||
}
|
|
||||||
case 'object': {
|
case 'object':
|
||||||
for (const k in value) {
|
for (const k in value) {
|
||||||
if (k == 'data') {
|
if (k == 'data') {
|
||||||
if (value[k] !== undefined) ret[k] = Data.create(value[k])
|
if (value[k] !== undefined) ret[k] = Data.create(value[k])
|
||||||
@@ -115,11 +112,10 @@ function markProperties(value = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid mark \`properties\` argument! It must be an object, a string or a mark. You passed: "${value}".`)
|
throw new Error(`Invalid mark \`properties\` argument! It must be an object, a string or a mark. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -135,11 +131,11 @@ function nodeProperties(value = {}) {
|
|||||||
const ret = {}
|
const ret = {}
|
||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'string': {
|
case 'string':
|
||||||
ret.type = value
|
ret.type = value
|
||||||
break
|
break
|
||||||
}
|
|
||||||
case 'object': {
|
case 'object':
|
||||||
if (value.isVoid !== undefined) ret.isVoid = !!value.isVoid
|
if (value.isVoid !== undefined) ret.isVoid = !!value.isVoid
|
||||||
for (const k in value) {
|
for (const k in value) {
|
||||||
if (k == 'data') {
|
if (k == 'data') {
|
||||||
@@ -149,11 +145,10 @@ function nodeProperties(value = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid node \`properties\` argument! It must be an object, a string or a node. You passed: "${value}".`)
|
throw new Error(`Invalid node \`properties\` argument! It must be an object, a string or a node. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -169,14 +164,13 @@ function selection(value) {
|
|||||||
if (value instanceof Selection) return value
|
if (value instanceof Selection) return value
|
||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'object': {
|
case 'object':
|
||||||
return Selection.create(value)
|
return Selection.create(value)
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid \`selection\` argument! It must be a selection or an object. You passed: "${value}".`)
|
throw new Error(`Invalid \`selection\` argument! It must be a selection or an object. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize a selection properties argument `value`.
|
* Normalize a selection properties argument `value`.
|
||||||
@@ -189,7 +183,7 @@ function selectionProperties(value = {}) {
|
|||||||
const ret = {}
|
const ret = {}
|
||||||
|
|
||||||
switch (typeOf(value)) {
|
switch (typeOf(value)) {
|
||||||
case 'object': {
|
case 'object':
|
||||||
if (value.anchorKey !== undefined) ret.anchorKey = value.anchorKey
|
if (value.anchorKey !== undefined) ret.anchorKey = value.anchorKey
|
||||||
if (value.anchorOffset !== undefined) ret.anchorOffset = value.anchorOffset
|
if (value.anchorOffset !== undefined) ret.anchorOffset = value.anchorOffset
|
||||||
if (value.focusKey !== undefined) ret.focusKey = value.focusKey
|
if (value.focusKey !== undefined) ret.focusKey = value.focusKey
|
||||||
@@ -198,11 +192,10 @@ function selectionProperties(value = {}) {
|
|||||||
if (value.isFocused !== undefined) ret.isFocused = !!value.isFocused
|
if (value.isFocused !== undefined) ret.isFocused = !!value.isFocused
|
||||||
if (value.marks !== undefined) ret.marks = value.marks
|
if (value.marks !== undefined) ret.marks = value.marks
|
||||||
break
|
break
|
||||||
}
|
|
||||||
default: {
|
default:
|
||||||
throw new Error(`Invalid selection \`properties\` argument! It must be an object or a selection. You passed: "${value}".`)
|
throw new Error(`Invalid selection \`properties\` argument! It must be an object or a selection. You passed: "${value}".`)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user