Skip to content

Commit

Permalink
fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
davemarco committed Sep 6, 2024
1 parent ee9e3d8 commit 54a363f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
4 changes: 2 additions & 2 deletions new-log-viewer/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ const Layout = () => {
multiple={true}
name={"log-level"}
style={{display: "table-row", height: "2rcap"}}
value={selectedLogLevels.map(index => index.toString())}
value={selectedLogLevels.map((index) => index.toString())}
onChange={handleLogLevelSelectChange}
>
{LOG_LEVEL_NAMES_LIST.map((logLevelName,index) => (
{LOG_LEVEL_NAMES_LIST.map((logLevelName, index) => (
<option
key={logLevelName}
style={{display: "table-cell", width: "8rch", borderStyle: "solid"}}
Expand Down
6 changes: 4 additions & 2 deletions new-log-viewer/src/contexts/StateContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ const StateContextProvider = ({children}: StateContextProviderProps) => {
const {filePath, logEventNum} = useContext(UrlContext);

const [fileName, setFileName] = useState<string>(STATE_DEFAULT.fileName);
const [firstLogEventNumPerPage, setFirstLogEventNumPerPage] = useState<number[]>(STATE_DEFAULT.firstLogEventNumPerPage);
const [lastLogEventNumPerPage, setLastLogEventNumPerPage] = useState<number[]>(STATE_DEFAULT.lastLogEventNumPerPage);
const [firstLogEventNumPerPage, setFirstLogEventNumPerPage] =
useState<number[]>(STATE_DEFAULT.firstLogEventNumPerPage);
const [lastLogEventNumPerPage, setLastLogEventNumPerPage] =
useState<number[]>(STATE_DEFAULT.lastLogEventNumPerPage);
const [logData, setLogData] = useState<string>(STATE_DEFAULT.logData);
const [numEvents, setNumEvents] = useState<number>(STATE_DEFAULT.numEvents);
const [numFilteredEvents, setNumFilteredEvents] =
Expand Down
11 changes: 6 additions & 5 deletions new-log-viewer/src/services/LogFileManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {getBasenameFromUrlOrDefault} from "../utils/url";
import ClpIrDecoder from "./decoders/ClpIrDecoder";
import JsonlDecoder from "./decoders/JsonlDecoder";


/**
* Loads a file from a given source.
*
Expand Down Expand Up @@ -241,18 +242,18 @@ class LogFileManager {
this.#numFilteredEvents = filteredLogEventsIndices.length;

for (let i = 0; i < this.#numFilteredEvents; i += this.#pageSize) {
const firstLogEventOnPageIdx: number = filteredLogEventsIndices[i] as number
const firstLogEventOnPageIdx: number = filteredLogEventsIndices[i] as number;
this.#firstLogEventNumPerPage.push(1 + firstLogEventOnPageIdx);

//Need to minus one from page size to get correct index into filtered log events.
// Need to minus one from page size to get correct index into filtered log events.
let lastPageIdx: number = i + this.#pageSize - 1

Check failure on line 250 in new-log-viewer/src/services/LogFileManager.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/LogFileManager.ts#L249-L250

[@stylistic/js/semi] Missing semicolon.
//Guard to prevent indexing out of array on last page.
// Guard to prevent indexing out of array on last page.
if (lastPageIdx >= this.#numFilteredEvents) {
lastPageIdx = this.#numFilteredEvents - 1
lastPageIdx = this.#numFilteredEvents - 1;
}

const lastLogEventOnPageIdx: number = filteredLogEventsIndices[lastPageIdx] as number
const lastLogEventOnPageIdx: number = filteredLogEventsIndices[lastPageIdx] as number;
this.#lastLogEventNumPerPage.push(1 + lastLogEventOnPageIdx);
}
}
Expand Down
5 changes: 2 additions & 3 deletions new-log-viewer/src/services/decoders/ClpIrDecoder.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import clpFfiJsModuleInit, {ClpIrStreamReader} from "clp-ffi-js";

import {Nullable} from "../../typings/common";

import {
Decoder,
DecodeResultType,
LogEventCount,
} from "../../typings/decoders";
import {LogLevelFilter} from "../../typings/logs";

Check warning on line 8 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L1-L8

[simple-import-sort/imports] Run autofix to sort these imports!

Check failure on line 8 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L8

[import/newline-after-import] Expected 2 empty lines after import statement not followed by another import.

class ClpIrDecoder implements Decoder {
#streamReader: ClpIrStreamReader;
Expand Down Expand Up @@ -44,7 +43,7 @@ class ClpIrDecoder implements Decoder {
};
}

// eslint-disable-next-line class-methods-use-this
// eslint-disable-next-line class-methods-use-this no-unused-vars

Check failure on line 46 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L46

[class-methods-use-this no-unused-vars] Definition for rule 'class-methods-use-this no-unused-vars' was not found.
changeLogLevelFilter (logLevelFilter: LogLevelFilter): boolean {

Check failure on line 47 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L47

[class-methods-use-this] Expected 'this' to be used by class method 'changeLogLevelFilter'.

Check failure on line 47 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L47

[@typescript-eslint/no-unused-vars] 'logLevelFilter' is defined but never used.
// TODO: fix this after log level filtering is implemented in clp-ffi-js

Check failure on line 48 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L48

[@stylistic/js/indent] Expected indentation of 8 spaces but found 9.

Check warning on line 48 in new-log-viewer/src/services/decoders/ClpIrDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/ClpIrDecoder.ts#L48

[no-warning-comments] Unexpected 'todo' comment: 'TODO: fix this after log level filtering...'.
return true
Expand Down
35 changes: 18 additions & 17 deletions new-log-viewer/src/services/decoders/JsonlDecoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class JsonlDecoder implements Decoder {
}

this.#deserialize();
this.#filteredLogIndices = this.#createIndicesArray(this.#logEvents.length)
this.#filteredLogIndices = createIndicesArray(this.#logEvents.length);

Check failure on line 74 in new-log-viewer/src/services/decoders/JsonlDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/JsonlDecoder.ts#L74

[no-use-before-define] 'createIndicesArray' was used before it was defined.

const numInvalidEvents = Array.from(this.#invalidLogEventIdxToRawLine.keys())
.filter((eventIdx) => (beginIdx <= eventIdx && eventIdx < endIdx))
Expand All @@ -85,6 +85,7 @@ class JsonlDecoder implements Decoder {

changeLogLevelFilter (logLevelFilter: LogLevelFilter): boolean {
this.#filterLogs(logLevelFilter);

return true;
}

Expand Down Expand Up @@ -190,7 +191,7 @@ class JsonlDecoder implements Decoder {
this.#filteredLogIndices.length = 0;

if (!logLevelFilter) {
return
return;
}

this.#logEvents.forEach((logEvent, index) => {
Expand All @@ -200,21 +201,6 @@ class JsonlDecoder implements Decoder {
});
}

/**
* Creates an array containing indices as values. Method is used to set the default log level
* filter (i.e. all levels are selected, so the array should include all log indices).
*
* @param length The length of the array
* @return Array with indices as values (i.e [0, 1, 2, 3, ..., length - 1])
*/
#createIndicesArray (length: number): number[] {
const filteredLogIndices: number[] = Array.from(
{length: length},
(_, index) => index
);
return filteredLogIndices;
}

/**
* Parses the log level from the given log event.
*
Expand Down Expand Up @@ -260,4 +246,19 @@ class JsonlDecoder implements Decoder {
}
}

/**
* Creates an array containing indices as values. Method is used to set the default log level
* filter (i.e. all levels are selected, so the array should include all log indices).
*
* @param length The length of the array

Check warning on line 253 in new-log-viewer/src/services/decoders/JsonlDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/JsonlDecoder.ts#L253

[jsdoc/informative-docs] This tag description only repeats the name it describes.
* @return Array with indices as values (i.e [0, 1, 2, 3, ..., length - 1])
*/
function createIndicesArray (length: number): number[] {
const filteredLogIndices: number[] = Array.from(

Check failure on line 257 in new-log-viewer/src/services/decoders/JsonlDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/JsonlDecoder.ts#L257

[@stylistic/js/no-multi-spaces] Multiple spaces found before '='.
{length: length},
(_, index) => index
);
return filteredLogIndices;

Check warning on line 261 in new-log-viewer/src/services/decoders/JsonlDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/JsonlDecoder.ts#L261

[@stylistic/js/padding-line-between-statements] Expected blank line before this statement.
}

Check warning on line 262 in new-log-viewer/src/services/decoders/JsonlDecoder.ts

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

new-log-viewer/src/services/decoders/JsonlDecoder.ts#L256-L262

[func-style] Expected a function expression.

export default JsonlDecoder;
1 change: 1 addition & 0 deletions new-log-viewer/src/typings/decoders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
LogLevelFilter,
} from "./logs";


interface LogEventCount {
numValidEvents: number,
numInvalidEvents: number,
Expand Down

0 comments on commit 54a363f

Please sign in to comment.