Skip to content

Commit

Permalink
fix linting issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Feb 19, 2024
1 parent 6163879 commit cbb0629
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 377 deletions.
6 changes: 3 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parserOptions": {
"sourceType": "module"
"project": "./tsconfig.json"
},
"rules": {
"no-unused-vars": "off",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
"builtin-modules": "3.3.0",
"esbuild": "0.14.47",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.4.3",
"jest-cli": "^29.4.3",
"jest-junit-reporter": "^1.1.0",
"obsidian": "^1.2.8",
"prettier": "^2.8.1",
"prettier": "^3.2.5",
"semantic-release": "^19.0.5",
"ts-jest": "^29.0.5",
"tslib": "2.4.0",
Expand Down
18 changes: 9 additions & 9 deletions src/__tests__/formatDate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function generateRandomISODateStrings(quantity: number): string[] {
Math.floor(Math.random() * 24),
Math.floor(Math.random() * 60),
Math.floor(Math.random() * 60),
Math.floor(Math.random() * 1000)
)
Math.floor(Math.random() * 1000),
),
)

// Randomly select a timezone from the available time zones
Expand All @@ -86,7 +86,7 @@ function generateRandomISODateStrings(quantity: number): string[] {
// Convert the generated date to the randomly selected timezone
// const dateTimeWithZone = DateTime.fromJSDate(date, { zone: randomTimeZone }).toUTC();
const jsDateTimeWithZone = new Date(
date.toLocaleString('en-US', { timeZone: randomTimeZone })
date.toLocaleString('en-US', { timeZone: randomTimeZone }),
)
const luxonDate = DateTime.fromJSDate(jsDateTimeWithZone)
randomISODateStrings.push(luxonDate.toISO() as string)
Expand All @@ -102,13 +102,13 @@ describe('formatDate on random dates', () => {
const result = formatDate(date, 'yyyy-MM-dd HH:mm:ss')
// test with regex to ensure the format is correct
expect(result).toMatch(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/)
}
},
)
})

function getCasesWithRandomDates(
testFormats: string[],
quantity = 10
quantity = 10,
): {
date: string
luxonFormat: string
Expand All @@ -117,7 +117,7 @@ function getCasesWithRandomDates(
generateRandomISODateStrings(quantity).map((date) => ({
date,
luxonFormat,
}))
})),
)
}

Expand All @@ -135,7 +135,7 @@ describe('round trip on random dates', () => {
const result = formatDate(testCase.date, testCase.luxonFormat)
const result2 = formatDate(result, testCase.luxonFormat)
expect(result2).toBe(result)
}
},
)

const atypicalFormats = [
Expand All @@ -148,9 +148,9 @@ describe('round trip on random dates', () => {
const formattedDate = formatDate(testCase.date, testCase.luxonFormat)
const parsedDate = DateTime.fromFormat(
formattedDate,
testCase.luxonFormat
testCase.luxonFormat,
)
expect(parsedDate.isValid).toBe(true)
}
},
)
})
14 changes: 7 additions & 7 deletions src/__tests__/path_validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('replaceIllegalChars() removes all expected characters', () => {
const input = `this${character}string`
const output = replaceIllegalChars(input)
expect(output).not.toContain(character)
}
},
)
})

Expand All @@ -41,7 +41,7 @@ describe('replaceIllegalChars() function replaces illegal characters with replac
const expectedOutput = `this${REPLACEMENT_CHAR}string`
const output = replaceIllegalChars(input)
expect(output).toEqual(expectedOutput)
}
},
)
})

Expand All @@ -51,7 +51,7 @@ describe('replaceIllegalChars() function does not modify string without illegal
(input) => {
const output = replaceIllegalChars(input)
expect(output).toEqual(input)
}
},
)
})

Expand All @@ -72,14 +72,14 @@ describe('replaceIllegalChars() function replaces all occurrences of illegal cha
const output = replaceIllegalChars(input)
expect(output).toEqual(expectedOutput)
expect(output.match(ILLEGAL_CHAR_REGEX)).toBeNull()
}
},
)
})

describe('file system behavior with non-alphanumeric characters not in the illegal character list', () => {
const nonAlphanumericCharactersWithoutIllegal: string[] = Array.from(
{ length: 127 - 32 },
(_, i) => String.fromCharCode(i + 32)
(_, i) => String.fromCharCode(i + 32),
)
.filter((char) => !/^[a-zA-Z0-9]+$/.test(char))
.map(replaceIllegalChars)
Expand All @@ -97,7 +97,7 @@ describe('file system behavior with non-alphanumeric characters not in the illeg
fs.unlinkSync(input)
// verify the file has been deleted
expect(fs.existsSync(input)).toBe(false)
}
},
)
})

Expand All @@ -110,6 +110,6 @@ describe('replaceIllegalChars() function removes all occurrences of invisible ch
const output = replaceIllegalChars(input)
expect(output).toEqual(expectedOutput)
expect(output.match(ILLEGAL_CHAR_REGEX)).toBeNull()
}
},
)
})
4 changes: 2 additions & 2 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const loadArticles = async (
updatedAt = '',
query = '',
includeContent = false,
format = 'html'
format = 'html',
): Promise<[Article[], boolean]> => {
const res = await requestUrl({
url: endpoint,
Expand Down Expand Up @@ -177,7 +177,7 @@ export const loadArticles = async (
export const deleteArticleById = async (
endpoint: string,
apiKey: string,
articleId: string
articleId: string,
) => {
const res = await requestUrl({
url: endpoint,
Expand Down
Loading

0 comments on commit cbb0629

Please sign in to comment.