Enable brace-style eslint rules

This commit is contained in:
jamiebuilds-signal 2022-09-13 14:48:09 -07:00 committed by GitHub
parent 73bdcdfd0a
commit 5a8f484a03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 54 additions and 13 deletions

View file

@ -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`):
'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.',
},
],
curly: 'error',
};
const typescriptRules = {
...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' }],
'no-restricted-imports': 'off',

View file

@ -70,7 +70,9 @@ export const StickerButton = React.memo(
const setOpen = React.useCallback(
(value: boolean) => {
internalSetOpen(value);
if (onOpenStateChanged) onOpenStateChanged(value);
if (onOpenStateChanged) {
onOpenStateChanged(value);
}
},
[internalSetOpen, onOpenStateChanged]
);

View file

@ -119,7 +119,9 @@ export class EmojiCompletion {
const range = this.quill.getSelection();
if (!range) return PASS_THROUGH;
if (!range) {
return PASS_THROUGH;
}
const [blot, index] = this.quill.getLeaf(range.index);
const [leftTokenTextMatch, rightTokenTextMatch] = matchBlotTextPartitions(
@ -200,14 +202,18 @@ export class EmojiCompletion {
completeEmoji(): void {
const range = this.quill.getSelection();
if (range === null) return;
if (range === null) {
return;
}
const emoji = this.results[this.index];
const [leafText] = this.getCurrentLeafTextPartitions();
const tokenTextMatch = /:([-+0-9a-z_]*)(:?)$/.exec(leafText);
if (tokenTextMatch === null) return;
if (tokenTextMatch === null) {
return;
}
const [, tokenText] = tokenTextMatch;

View file

@ -151,7 +151,9 @@ export class MentionCompletion {
const range = this.quill.getSelection();
if (range === null) return;
if (range === null) {
return;
}
const member = this.results[resultIndex];

View file

@ -79,7 +79,9 @@ type MentionInsert = {
const isMention = (insert?: unknown): insert is MentionInsert => {
if (insert) {
if (Object.getOwnPropertyNames(insert).includes('mention')) return true;
if (Object.getOwnPropertyNames(insert).includes('mention')) {
return true;
}
}
return false;
};

View file

@ -30,12 +30,15 @@ export type ModifiedGroupDetails = MessageWithAvatar<Proto.GroupDetails>;
export type ModifiedContactDetails = MessageWithAvatar<Proto.ContactDetails>;
/* eslint-disable @typescript-eslint/brace-style -- Prettier conflicts with ESLint */
abstract class ParserBase<
Message extends OptionalAvatar,
Decoder extends DecoderBase<Message>,
Result
> implements Iterable<Result>
{
/* eslint-enable @typescript-eslint/brace-style */
protected readonly reader: protobuf.Reader;
constructor(bytes: Uint8Array, private readonly decoder: Decoder) {

View file

@ -229,10 +229,13 @@ function getEnvelopeId(envelope: ProcessedEnvelope): string {
return `${prefix} ${timestamp} (${envelope.id})`;
}
/* eslint-disable @typescript-eslint/brace-style -- Prettier conflicts with ESLint */
export default class MessageReceiver
extends EventTarget
implements IRequestHandler
{
/* eslint-enable @typescript-eslint/brace-style */
private server: WebAPIType;
private storage: Storage;

View file

@ -55,14 +55,18 @@ export class User {
public getNumber(): string | undefined {
const numberId = this.storage.get('number_id');
if (numberId === undefined) return undefined;
if (numberId === undefined) {
return undefined;
}
return Helpers.unencodeNumber(numberId)[0];
}
public getUuid(uuidKind = UUIDKind.ACI): UUID | undefined {
if (uuidKind === UUIDKind.PNI) {
const pni = this.storage.get('pni');
if (pni === undefined) return undefined;
if (pni === undefined) {
return undefined;
}
return new UUID(pni);
}
@ -71,7 +75,9 @@ export class User {
`Unsupported uuid kind: ${uuidKind}`
);
const uuid = this.storage.get('uuid_id');
if (!uuid) return undefined;
if (!uuid) {
return undefined;
}
return new UUID(Helpers.unencodeNumber(uuid.toLowerCase())[0]);
}
@ -161,13 +167,17 @@ export class User {
private _getDeviceIdFromUuid(): string | undefined {
const uuid = this.storage.get('uuid_id');
if (uuid === undefined) return undefined;
if (uuid === undefined) {
return undefined;
}
return Helpers.unencodeNumber(uuid)[1];
}
private _getDeviceIdFromNumber(): string | undefined {
const numberId = this.storage.get('number_id');
if (numberId === undefined) return undefined;
if (numberId === undefined) {
return undefined;
}
return Helpers.unencodeNumber(numberId)[1];
}
}

View file

@ -133,7 +133,9 @@ class CollectIterator<T, S> implements Iterator<S> {
// eslint-disable-next-line no-constant-condition
while (true) {
const nextIteration = this.iterator.next();
if (nextIteration.done) return nextIteration;
if (nextIteration.done) {
return nextIteration;
}
const nextValue = this.fn(nextIteration.value);
if (nextValue !== undefined) {
return {