From f8ab0772b9c29be6edacc138bd6d9fa22c093860 Mon Sep 17 00:00:00 2001 From: Aric Camarata Date: Sun, 31 May 2026 08:48:31 -0400 Subject: [PATCH] =?UTF-8?q?ci:=20fix=20lint=20job=20=E2=80=94=20add=20@typ?= =?UTF-8?q?escript-eslint=20parser/plugin=20devDeps,=20files=20pattern,=20?= =?UTF-8?q?typed=20linting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eslint.config.mjs imported @typescript-eslint/parser and @typescript-eslint/eslint-plugin directly but neither was a direct devDependency. pnpm strict hoisting made them unreachable on CI. Fix: add both as explicit ^8 devDependencies, add files pattern for *.ts to all config objects, and enable parserOptions.project for typed rules. Also run prettier to fix formatting. --- eslint.config.mjs | 8 ++++-- package.json | 4 ++- pnpm-lock.yaml | 6 +++++ src/index.ts | 62 +++++++++++++++++++++++------------------------ src/types.ts | 2 +- 5 files changed, 47 insertions(+), 35 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 442dce0..e7f721a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -5,10 +5,14 @@ import { typescript } from '@acamarata/eslint-config'; export default [ { + files: ['**/*.ts', '**/*.tsx'], plugins: { '@typescript-eslint': tsPlugin }, - languageOptions: { parser: tsParser }, + languageOptions: { + parser: tsParser, + parserOptions: { project: true, tsconfigRootDir: import.meta.dirname }, + }, }, - ...typescript, + ...typescript.map((cfg) => ({ ...cfg, files: ['**/*.ts', '**/*.tsx'] })), eslintConfigPrettier, { ignores: ['dist/', 'node_modules/', 'test.mjs', 'test-cjs.cjs'], diff --git a/package.json b/package.json index 27e8455..96730c9 100644 --- a/package.json +++ b/package.json @@ -60,11 +60,13 @@ }, "devDependencies": { "@acamarata/eslint-config": "^0.1.0", - "c8": "^10.1.3", "@acamarata/prettier-config": "^0.1.0", "@acamarata/tsconfig": "^0.1.0", "@eslint/js": "^10.0.1", "@types/node": "^25.3.5", + "@typescript-eslint/eslint-plugin": "^8.56.1", + "@typescript-eslint/parser": "^8.56.1", + "c8": "^10.1.3", "dayjs": "^1.11.0", "eslint": "^10.0.3", "eslint-config-prettier": "^10.1.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 91cfe90..581099b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,12 @@ importers: '@types/node': specifier: ^25.3.5 version: 25.3.5 + '@typescript-eslint/eslint-plugin': + specifier: ^8.56.1 + version: 8.56.1(@typescript-eslint/parser@8.56.1(eslint@10.0.3)(typescript@5.9.3))(eslint@10.0.3)(typescript@5.9.3) + '@typescript-eslint/parser': + specifier: ^8.56.1 + version: 8.56.1(eslint@10.0.3)(typescript@5.9.3) c8: specifier: ^10.1.3 version: 10.1.3 diff --git a/src/index.ts b/src/index.ts index 22c0ccd..d7b04ff 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ -import type { PluginFunc } from 'dayjs'; -import { toHijri, toGregorian, hmLong, hmMedium, hwLong, hwShort, hwNumeric } from 'hijri-core'; -import type { ConversionOptions, HijriDate } from './types'; +import type { PluginFunc } from "dayjs"; +import { toHijri, toGregorian, hmLong, hmMedium, hwLong, hwShort, hwNumeric } from "hijri-core"; +import type { ConversionOptions, HijriDate } from "./types"; // Augment Day.js to expose plugin methods on the instance type. -declare module 'dayjs' { +declare module "dayjs" { interface Dayjs { /** * Convert the Day.js date to a Hijri date. @@ -91,7 +91,7 @@ declare module 'dayjs' { // Using the function declaration form (same pattern as dayjs timezone plugin) // because dayjs does not export an IStatic interface for module augmentation. // import('dayjs').Dayjs is used explicitly to satisfy the tsup DTS emitter. -declare module 'dayjs' { +declare module "dayjs" { /** * Construct a Day.js instance from a Hijri date. * @@ -117,7 +117,7 @@ declare module 'dayjs' { hm: number, hd: number, opts?: ConversionOptions, - ): import('dayjs').Dayjs; + ): import("dayjs").Dayjs; } // Hijri-specific format tokens, ordered longest-first to prevent partial matches. @@ -138,7 +138,7 @@ const HIJRI_TOKEN_RE = /iYYYY|iYY|iMMMM|iMMM|iMM|iM|iDD|iD|iEEEE|iEEE|iE|ioooo|i * @returns The bracket-escaped string. */ function lit(value: string): string { - return '[' + value.split(']').join(']][') + ']'; + return "[" + value.split("]").join("]][") + "]"; } /** @@ -191,7 +191,7 @@ const plugin: PluginFunc = (_option, dayjsClass, dayjsFactory) => { opts?: ConversionOptions, ): string { const hijri = this.toHijri(opts); - if (!hijri) return ''; + if (!hijri) return ""; // Day.js .day() returns 0 (Sunday) ... 6 (Saturday), matching the index // layout of hwLong, hwShort, and hwNumeric from hijri-core. @@ -199,38 +199,38 @@ const plugin: PluginFunc = (_option, dayjsClass, dayjsFactory) => { const replaced = formatStr.replace(HIJRI_TOKEN_RE, (token) => { switch (token) { - case 'iYYYY': - return lit(String(hijri.hy).padStart(4, '0')); - case 'iYY': - return lit(String(hijri.hy % 100).padStart(2, '0')); - case 'iMMMM': + case "iYYYY": + return lit(String(hijri.hy).padStart(4, "0")); + case "iYY": + return lit(String(hijri.hy % 100).padStart(2, "0")); + case "iMMMM": // Non-null: hijri.hm is a valid Hijri month 1-12; hm-1 is always within hmLong bounds. // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return lit(hmLong[hijri.hm - 1]!); - case 'iMMM': + case "iMMM": // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return lit(hmMedium[hijri.hm - 1]!); - case 'iMM': - return lit(String(hijri.hm).padStart(2, '0')); - case 'iM': + case "iMM": + return lit(String(hijri.hm).padStart(2, "0")); + case "iM": return lit(String(hijri.hm)); - case 'iDD': - return lit(String(hijri.hd).padStart(2, '0')); - case 'iD': + case "iDD": + return lit(String(hijri.hd).padStart(2, "0")); + case "iD": return lit(String(hijri.hd)); - case 'iEEEE': + case "iEEEE": // Non-null: dow is always 0-6 (day of week), within hwLong bounds. // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return lit(hwLong[dow]!); - case 'iEEE': + case "iEEE": // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return lit(hwShort[dow]!); - case 'iE': + case "iE": // eslint-disable-next-line @typescript-eslint/no-non-null-assertion return lit(String(hwNumeric[dow]!)); - case 'ioooo': - case 'iooo': - return lit('AH'); + case "ioooo": + case "iooo": + return lit("AH"); default: return token; } @@ -266,8 +266,8 @@ const plugin: PluginFunc = (_option, dayjsClass, dayjsFactory) => { // dayjsFactory(Date) interprets the Date in local time; a UTC-midnight Date // in western timezones would resolve to the previous local day. const y = greg.getUTCFullYear(); - const mo = String(greg.getUTCMonth() + 1).padStart(2, '0'); - const dy = String(greg.getUTCDate()).padStart(2, '0'); + const mo = String(greg.getUTCMonth() + 1).padStart(2, "0"); + const dy = String(greg.getUTCDate()).padStart(2, "0"); return dayjsFactory(`${y}-${mo}-${dy}`); }; }; @@ -278,13 +278,13 @@ export default plugin; * Re-exported from hijri-core for consumers who import from dayjs-hijri-plus. * Avoids requiring hijri-core as a direct dependency just to use these types. */ -export type { HijriDate, ConversionOptions } from './types'; +export type { HijriDate, ConversionOptions } from "./types"; /** * Re-exported CalendarEngine interface from hijri-core. * Use this type to implement custom calendar engines for `registerCalendar`. */ -export type { CalendarEngine } from 'hijri-core'; +export type { CalendarEngine } from "hijri-core"; /** * Re-exported registry API from hijri-core. @@ -296,4 +296,4 @@ export type { CalendarEngine } from 'hijri-core'; * registerCalendar('my-cal', myEngine); * listCalendars(); // ['uaq', 'fcna', 'my-cal'] */ -export { registerCalendar, getCalendar, listCalendars } from 'hijri-core'; +export { registerCalendar, getCalendar, listCalendars } from "hijri-core"; diff --git a/src/types.ts b/src/types.ts index 66f12f7..1443187 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,2 +1,2 @@ -import type { HijriDate, ConversionOptions } from 'hijri-core'; +import type { HijriDate, ConversionOptions } from "hijri-core"; export type { HijriDate, ConversionOptions };