Skip to content

Commit fa6cf2e

Browse files
authored
style: improve eslint config (#172)
1 parent d161bcd commit fa6cf2e

24 files changed

+56
-37
lines changed

.eslintrc.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@
4242
"semi": ["off"],
4343
"@typescript-eslint/semi": ["warn", "always"],
4444
"@typescript-eslint/no-inferrable-types": ["off"],
45+
"@typescript-eslint/member-ordering": ["warn", {
46+
"default": ["field", "constructor", "method", "signature"],
47+
"typeLiterals": []
48+
}],
49+
"@typescript-eslint/parameter-properties": ["warn", {
50+
"allow": []
51+
}],
52+
"@typescript-eslint/explicit-member-accessibility": ["warn"],
53+
"@typescript-eslint/member-delimiter-style": ["warn", {
54+
"multiline": {
55+
"delimiter": "comma",
56+
"requireLast": false
57+
},
58+
"singleline": {
59+
"delimiter": "comma",
60+
"requireLast": false
61+
},
62+
"multilineDetection": "brackets"
63+
}],
4564
"jsdoc/require-param": ["off"],
4665
"jsdoc/check-param-names": ["warn", {
4766
"checkDestructured": false

src/bindings/AddonTypes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ export type BindingModule = {
1717
batchSize?: number,
1818
logitsAll?: boolean,
1919
embedding?: boolean,
20-
threads?: number,
21-
}): AddonContext,
20+
threads?: number
21+
}): AddonContext
2222
},
2323
AddonGrammar: {
2424
new (grammarPath: string, params?: {
25-
printGrammar?: boolean,
25+
printGrammar?: boolean
2626
}): AddonGrammar
2727
},
2828
AddonGrammarEvaluationState: {
@@ -60,7 +60,7 @@ export type AddonModel = {
6060

6161
export type AddonContext = {
6262
dispose(): void,
63-
getContextSize(): number
63+
getContextSize(): number,
6464
initBatch(size: number): void, // size must be less or equal to batchSize
6565
addToBatch(
6666
sequenceId: number,

src/bindings/Llama.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class Llama {
3939
private constructor({
4040
bindings, metal, cuda, vulkan, logLevel, logger, buildType, cmakeOptions, llamaCppRelease
4141
}: {
42-
bindings: BindingModule
42+
bindings: BindingModule,
4343
metal: boolean,
4444
cuda: boolean,
4545
vulkan: boolean,
@@ -209,11 +209,11 @@ export class Llama {
209209
public static async _create({
210210
bindings, buildType, buildMetadata, logLevel, logger
211211
}: {
212-
bindings: BindingModule
212+
bindings: BindingModule,
213213
buildType: "localBuild" | "prebuilt",
214214
buildMetadata: BuildMetadataFile,
215215
logLevel: LlamaLogLevel,
216-
logger: (level: LlamaLogLevel, message: string) => void,
216+
logger: (level: LlamaLogLevel, message: string) => void
217217
}) {
218218
return new Llama({
219219
bindings,

src/evaluator/LlamaChat/LlamaChat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,8 @@ async function compressHistoryToFitContextSize({
866866
}: {
867867
history: ChatHistoryItem[],
868868
contextShiftSize: number,
869-
contextShiftStrategy: LLamaChatContextShiftOptions["strategy"]
870-
contextShiftLastEvaluationMetadata: LLamaChatContextShiftOptions["lastEvaluationMetadata"]
869+
contextShiftStrategy: LLamaChatContextShiftOptions["strategy"],
870+
contextShiftLastEvaluationMetadata: LLamaChatContextShiftOptions["lastEvaluationMetadata"],
871871
contextSize: number,
872872
tokenizer: Tokenizer,
873873
chatWrapper: ChatWrapper,

src/evaluator/LlamaEmbeddingContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type LlamaEmbeddingContextOptions = {
1818
* number of threads to use to evaluate tokens.
1919
* set to 0 to use the maximum threads supported by the current machine hardware
2020
*/
21-
threads?: number,
21+
threads?: number
2222
};
2323

2424
export class LlamaEmbeddingContext {

src/evaluator/LlamaGrammar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export type LlamaGrammarOptions = {
1414
grammar: string,
1515

1616
/** print the grammar to stdout */
17-
printGrammar?: boolean
17+
printGrammar?: boolean,
1818

1919
/** Consider any of these as EOS for the generated text. Only supported by `LlamaChat` and `LlamaChatSession` */
2020
stopGenerationTriggers?: readonly (StopGenerationTrigger | LlamaText)[],

src/evaluator/LlamaGrammarEvaluationState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {LlamaGrammar} from "./LlamaGrammar.js";
44

55

66
export type LlamaGrammarEvaluationStateOptions = {
7-
grammar: LlamaGrammar,
7+
grammar: LlamaGrammar
88
};
99

1010
/**

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import {GbnfJsonSchema, GbnfJsonSchemaToType} from "./utils/gbnfJson/types.js";
22
import {BuiltinSpecialTokenValue} from "./utils/LlamaText.js";
33

44
export type Token = number & {
5-
__token: never;
5+
__token: never
66
};
77

88
export type Tokenizer = {
9-
tokenize(text: string, specialTokens?: boolean): Token[];
10-
tokenize(text: BuiltinSpecialTokenValue, specialTokens: "builtin"): Token[];
9+
tokenize(text: string, specialTokens?: boolean): Token[],
10+
tokenize(text: BuiltinSpecialTokenValue, specialTokens: "builtin"): Token[]
1111
}["tokenize"];
1212

1313

src/utils/findCharacterRemovalCountToFitChatHistoryInContext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function findCharacterRemovalCountToFitChatHistoryInContext({
1313
}: {
1414
compressChatHistory(options: {
1515
chatHistory: readonly ChatHistoryItem[], charactersToRemove: number
16-
}): ChatHistoryItem[] | Promise<ChatHistoryItem[]>
16+
}): ChatHistoryItem[] | Promise<ChatHistoryItem[]>,
1717
chatHistory: ChatHistoryItem[],
1818
tokensCountToFit: number,
1919
tokenizer: Tokenizer,

src/utils/gbnfJson/GbnfTerminal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export abstract class GbnfTerminal {
1414
return ruleName;
1515
}
1616

17-
abstract getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
17+
public abstract getGrammar(grammarGenerator: GbnfGrammarGenerator): string;
1818

1919
public resolve(grammarGenerator: GbnfGrammarGenerator): string {
2020
const ruleName = this.getRuleName(grammarGenerator);

0 commit comments

Comments
 (0)