Enable brace-style eslint rules
This commit is contained in:
parent
73bdcdfd0a
commit
5a8f484a03
9 changed files with 54 additions and 13 deletions
13
.eslintrc.js
13
.eslintrc.js
|
@ -15,6 +15,10 @@ const rules = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// No omitting braces, keep on the same line
|
||||||
|
'brace-style': ['error', '1tbs', { allowSingleLine: false }],
|
||||||
|
curly: ['error', 'all'],
|
||||||
|
|
||||||
// prevents us from accidentally checking in exclusive tests (`.only`):
|
// prevents us from accidentally checking in exclusive tests (`.only`):
|
||||||
'mocha/no-exclusive-tests': 'error',
|
'mocha/no-exclusive-tests': 'error',
|
||||||
|
|
||||||
|
@ -109,12 +113,19 @@ const rules = {
|
||||||
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
curly: 'error',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const typescriptRules = {
|
const typescriptRules = {
|
||||||
...rules,
|
...rules,
|
||||||
|
|
||||||
|
// Override brace style to enable typescript-specific syntax
|
||||||
|
'brace-style': 'off',
|
||||||
|
'@typescript-eslint/brace-style': [
|
||||||
|
'error',
|
||||||
|
'1tbs',
|
||||||
|
{ allowSingleLine: false },
|
||||||
|
],
|
||||||
|
|
||||||
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
|
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
|
||||||
|
|
||||||
'no-restricted-imports': 'off',
|
'no-restricted-imports': 'off',
|
||||||
|
|
|
@ -70,7 +70,9 @@ export const StickerButton = React.memo(
|
||||||
const setOpen = React.useCallback(
|
const setOpen = React.useCallback(
|
||||||
(value: boolean) => {
|
(value: boolean) => {
|
||||||
internalSetOpen(value);
|
internalSetOpen(value);
|
||||||
if (onOpenStateChanged) onOpenStateChanged(value);
|
if (onOpenStateChanged) {
|
||||||
|
onOpenStateChanged(value);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[internalSetOpen, onOpenStateChanged]
|
[internalSetOpen, onOpenStateChanged]
|
||||||
);
|
);
|
||||||
|
|
|
@ -119,7 +119,9 @@ export class EmojiCompletion {
|
||||||
|
|
||||||
const range = this.quill.getSelection();
|
const range = this.quill.getSelection();
|
||||||
|
|
||||||
if (!range) return PASS_THROUGH;
|
if (!range) {
|
||||||
|
return PASS_THROUGH;
|
||||||
|
}
|
||||||
|
|
||||||
const [blot, index] = this.quill.getLeaf(range.index);
|
const [blot, index] = this.quill.getLeaf(range.index);
|
||||||
const [leftTokenTextMatch, rightTokenTextMatch] = matchBlotTextPartitions(
|
const [leftTokenTextMatch, rightTokenTextMatch] = matchBlotTextPartitions(
|
||||||
|
@ -200,14 +202,18 @@ export class EmojiCompletion {
|
||||||
completeEmoji(): void {
|
completeEmoji(): void {
|
||||||
const range = this.quill.getSelection();
|
const range = this.quill.getSelection();
|
||||||
|
|
||||||
if (range === null) return;
|
if (range === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const emoji = this.results[this.index];
|
const emoji = this.results[this.index];
|
||||||
const [leafText] = this.getCurrentLeafTextPartitions();
|
const [leafText] = this.getCurrentLeafTextPartitions();
|
||||||
|
|
||||||
const tokenTextMatch = /:([-+0-9a-z_]*)(:?)$/.exec(leafText);
|
const tokenTextMatch = /:([-+0-9a-z_]*)(:?)$/.exec(leafText);
|
||||||
|
|
||||||
if (tokenTextMatch === null) return;
|
if (tokenTextMatch === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const [, tokenText] = tokenTextMatch;
|
const [, tokenText] = tokenTextMatch;
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,9 @@ export class MentionCompletion {
|
||||||
|
|
||||||
const range = this.quill.getSelection();
|
const range = this.quill.getSelection();
|
||||||
|
|
||||||
if (range === null) return;
|
if (range === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const member = this.results[resultIndex];
|
const member = this.results[resultIndex];
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,9 @@ type MentionInsert = {
|
||||||
|
|
||||||
const isMention = (insert?: unknown): insert is MentionInsert => {
|
const isMention = (insert?: unknown): insert is MentionInsert => {
|
||||||
if (insert) {
|
if (insert) {
|
||||||
if (Object.getOwnPropertyNames(insert).includes('mention')) return true;
|
if (Object.getOwnPropertyNames(insert).includes('mention')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,12 +30,15 @@ export type ModifiedGroupDetails = MessageWithAvatar<Proto.GroupDetails>;
|
||||||
|
|
||||||
export type ModifiedContactDetails = MessageWithAvatar<Proto.ContactDetails>;
|
export type ModifiedContactDetails = MessageWithAvatar<Proto.ContactDetails>;
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/brace-style -- Prettier conflicts with ESLint */
|
||||||
abstract class ParserBase<
|
abstract class ParserBase<
|
||||||
Message extends OptionalAvatar,
|
Message extends OptionalAvatar,
|
||||||
Decoder extends DecoderBase<Message>,
|
Decoder extends DecoderBase<Message>,
|
||||||
Result
|
Result
|
||||||
> implements Iterable<Result>
|
> implements Iterable<Result>
|
||||||
{
|
{
|
||||||
|
/* eslint-enable @typescript-eslint/brace-style */
|
||||||
|
|
||||||
protected readonly reader: protobuf.Reader;
|
protected readonly reader: protobuf.Reader;
|
||||||
|
|
||||||
constructor(bytes: Uint8Array, private readonly decoder: Decoder) {
|
constructor(bytes: Uint8Array, private readonly decoder: Decoder) {
|
||||||
|
|
|
@ -229,10 +229,13 @@ function getEnvelopeId(envelope: ProcessedEnvelope): string {
|
||||||
return `${prefix} ${timestamp} (${envelope.id})`;
|
return `${prefix} ${timestamp} (${envelope.id})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/brace-style -- Prettier conflicts with ESLint */
|
||||||
export default class MessageReceiver
|
export default class MessageReceiver
|
||||||
extends EventTarget
|
extends EventTarget
|
||||||
implements IRequestHandler
|
implements IRequestHandler
|
||||||
{
|
{
|
||||||
|
/* eslint-enable @typescript-eslint/brace-style */
|
||||||
|
|
||||||
private server: WebAPIType;
|
private server: WebAPIType;
|
||||||
|
|
||||||
private storage: Storage;
|
private storage: Storage;
|
||||||
|
|
|
@ -55,14 +55,18 @@ export class User {
|
||||||
|
|
||||||
public getNumber(): string | undefined {
|
public getNumber(): string | undefined {
|
||||||
const numberId = this.storage.get('number_id');
|
const numberId = this.storage.get('number_id');
|
||||||
if (numberId === undefined) return undefined;
|
if (numberId === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return Helpers.unencodeNumber(numberId)[0];
|
return Helpers.unencodeNumber(numberId)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getUuid(uuidKind = UUIDKind.ACI): UUID | undefined {
|
public getUuid(uuidKind = UUIDKind.ACI): UUID | undefined {
|
||||||
if (uuidKind === UUIDKind.PNI) {
|
if (uuidKind === UUIDKind.PNI) {
|
||||||
const pni = this.storage.get('pni');
|
const pni = this.storage.get('pni');
|
||||||
if (pni === undefined) return undefined;
|
if (pni === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return new UUID(pni);
|
return new UUID(pni);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +75,9 @@ export class User {
|
||||||
`Unsupported uuid kind: ${uuidKind}`
|
`Unsupported uuid kind: ${uuidKind}`
|
||||||
);
|
);
|
||||||
const uuid = this.storage.get('uuid_id');
|
const uuid = this.storage.get('uuid_id');
|
||||||
if (!uuid) return undefined;
|
if (!uuid) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return new UUID(Helpers.unencodeNumber(uuid.toLowerCase())[0]);
|
return new UUID(Helpers.unencodeNumber(uuid.toLowerCase())[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,13 +167,17 @@ export class User {
|
||||||
|
|
||||||
private _getDeviceIdFromUuid(): string | undefined {
|
private _getDeviceIdFromUuid(): string | undefined {
|
||||||
const uuid = this.storage.get('uuid_id');
|
const uuid = this.storage.get('uuid_id');
|
||||||
if (uuid === undefined) return undefined;
|
if (uuid === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return Helpers.unencodeNumber(uuid)[1];
|
return Helpers.unencodeNumber(uuid)[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getDeviceIdFromNumber(): string | undefined {
|
private _getDeviceIdFromNumber(): string | undefined {
|
||||||
const numberId = this.storage.get('number_id');
|
const numberId = this.storage.get('number_id');
|
||||||
if (numberId === undefined) return undefined;
|
if (numberId === undefined) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return Helpers.unencodeNumber(numberId)[1];
|
return Helpers.unencodeNumber(numberId)[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,9 @@ class CollectIterator<T, S> implements Iterator<S> {
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
const nextIteration = this.iterator.next();
|
const nextIteration = this.iterator.next();
|
||||||
if (nextIteration.done) return nextIteration;
|
if (nextIteration.done) {
|
||||||
|
return nextIteration;
|
||||||
|
}
|
||||||
const nextValue = this.fn(nextIteration.value);
|
const nextValue = this.fn(nextIteration.value);
|
||||||
if (nextValue !== undefined) {
|
if (nextValue !== undefined) {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue