diff --git a/package-lock.json b/package-lock.json index 6fd6874..86e167a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6392,6 +6392,9 @@ "devDependencies": { "@types/node": "^22.0", "babel-loader": "^9.2.1", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "prettier": "^3.3.3", "typescript": "^5.5" } } diff --git a/packages/typescript/Quran/etc/eslint.config.mjs b/packages/typescript/Quran/etc/eslint.config.mjs new file mode 100644 index 0000000..d2c4004 --- /dev/null +++ b/packages/typescript/Quran/etc/eslint.config.mjs @@ -0,0 +1,12 @@ +import eslint from '@eslint/js'; +import tseslint from 'typescript-eslint'; +import prettier from 'eslint-plugin-prettier/recommended'; + +export default tseslint.config( + eslint.configs.recommended, + ...tseslint.configs.recommended, + prettier, + { + rules: {'@typescript-eslint/no-require-imports': 0}, + } +) diff --git a/packages/typescript/Quran/package.json b/packages/typescript/Quran/package.json index fb0cb10..dfd2816 100644 --- a/packages/typescript/Quran/package.json +++ b/packages/typescript/Quran/package.json @@ -8,7 +8,8 @@ ], "scripts": { "build": "npx webpack --config etc/webpack.config.js", - "prepare": "npm run build" + "prepare": "npm run build", + "format": "npx eslint --config etc/eslint.config.mjs --fix src/index.ts" }, "repository": { "type": "git", @@ -19,6 +20,9 @@ "devDependencies": { "@types/node": "^22.0", "babel-loader": "^9.2.1", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "prettier": "^3.3.3", "typescript": "^5.5" } } diff --git a/packages/typescript/Quran/src/index.ts b/packages/typescript/Quran/src/index.ts index ccd07b2..7003384 100644 --- a/packages/typescript/Quran/src/index.ts +++ b/packages/typescript/Quran/src/index.ts @@ -4,15 +4,15 @@ type TAyat = Ayah[]; type TLocale = { - readonly name: string, - readonly displayName: string, - readonly direction: "rtl" | "ltr" + readonly name: string; + readonly displayName: string; + readonly direction: "rtl" | "ltr"; }; type TQuran = { readonly locale: TLocale; readonly surahs: Surah[]; -} +}; type TSurah = { readonly id: number; @@ -26,7 +26,7 @@ type TSurah = { type TAyah = { readonly id: number; readonly body: string; -} +}; /** * Classes @@ -40,20 +40,22 @@ class Quran { */ static get locales(): Record { return { - "en": {"name": "en", "displayName": "English", "direction": "ltr"}, - "ar": {"name": "ar", "displayName": "العربية", "direction": "rtl"}, - "fa": {"name": "fa", "displayName": "فارسی", "direction": "rtl"} - } + en: { name: "en", displayName: "English", direction: "ltr" }, + ar: { name: "ar", displayName: "العربية", direction: "rtl" }, + fa: { name: "fa", displayName: "فارسی", direction: "rtl" }, + }; } /** * @returns {Record} The available surahs */ static get surahs(): Record { - const result: Record = {} + const result: Record = {}; const surahs: Record = require("@json/surahs"); for (const locale in surahs) { - result[locale] = surahs[locale].map((surah: TSurah) => new Surah({...surah, locale})); + result[locale] = surahs[locale].map( + (surah: TSurah) => new Surah({ ...surah, locale }), + ); } return result; } @@ -73,7 +75,7 @@ class Surah { readonly locale: string; readonly translatedBy: string | null; - constructor(self: TSurah & {locale: string}) { + constructor(self: TSurah & { locale: string }) { this.id = self.id; this.name = self.name; this.urlName = self.urlName; @@ -85,8 +87,8 @@ class Surah { } get ayat(): Ayah[] { - const ayat = require(`@json/${this.locale}/${this.id}.json`) - return ayat.map(([id, body]) => new Ayah({id,body})); + const ayat = require(`@json/${this.locale}/${this.id}.json`); + return ayat.map(([id, body]) => new Ayah({ id, body })); } } @@ -105,8 +107,4 @@ class Ayah { /** * Exports */ -export { - Quran, Surah, Ayah, - TQuran, TSurah, TAyah, - TAyat, TLocale -}; +export { Quran, Surah, Ayah, TQuran, TSurah, TAyah, TAyat, TLocale };