chore: add stronger lint rules

This commit is contained in:
Adhiraj Singh
2022-08-18 10:37:40 +05:30
parent 8d6e00eab6
commit c5917364ba
10 changed files with 101 additions and 103 deletions

View File

@@ -170,7 +170,6 @@ export const encodeBinaryNode = (
}
const writeString = (str: string) => {
// console.log('before write of ', str, ' ', Buffer.from(buffer).toString('hex'))
const tokenIndex = TOKEN_MAP[str]
if(tokenIndex) {
if(typeof tokenIndex.dict === 'number') {
@@ -207,7 +206,7 @@ export const encodeBinaryNode = (
typeof attrs[k] !== 'undefined' && attrs[k] !== null
))
writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' && content !== null ? 1 : 0))
writeListStart(2 * validAttributes.length + 1 + (typeof content !== 'undefined' ? 1 : 0))
writeString(tag)
for(const key of validAttributes) {
@@ -225,11 +224,9 @@ export const encodeBinaryNode = (
} else if(Array.isArray(content)) {
writeListStart(content.length)
for(const item of content) {
if(item) {
encodeBinaryNode(item, opts, buffer)
}
encodeBinaryNode(item, opts, buffer)
}
} else if(typeof content === 'undefined' || content === null) {
} else if(typeof content === 'undefined') {
// do nothing
} else {
throw new Error(`invalid children for header "${tag}": ${content} (${typeof content})`)