mirror of
https://github.com/acamarata/moment-hijri-plus.git
synced 2026-06-30 18:54:29 +00:00
chore: adopt shared config packages (tsconfig, eslint, prettier)
This commit is contained in:
parent
60f2ac366a
commit
50b6665035
6 changed files with 81 additions and 32 deletions
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "all",
|
|
||||||
"printWidth": 100,
|
|
||||||
"tabWidth": 2
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
import eslint from '@eslint/js';
|
import tsParser from '@typescript-eslint/parser';
|
||||||
import tseslint from 'typescript-eslint';
|
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
||||||
import eslintConfigPrettier from 'eslint-config-prettier';
|
import eslintConfigPrettier from 'eslint-config-prettier';
|
||||||
|
import { typescript } from '@acamarata/eslint-config';
|
||||||
|
|
||||||
export default tseslint.config(
|
export default [
|
||||||
eslint.configs.recommended,
|
{
|
||||||
...tseslint.configs.recommended,
|
plugins: { '@typescript-eslint': tsPlugin },
|
||||||
|
languageOptions: { parser: tsParser },
|
||||||
|
},
|
||||||
|
...typescript,
|
||||||
eslintConfigPrettier,
|
eslintConfigPrettier,
|
||||||
{
|
{
|
||||||
ignores: ['dist/', 'node_modules/', 'test.mjs', 'test-cjs.cjs'],
|
ignores: ['dist/', 'node_modules/', 'test.mjs', 'test-cjs.cjs'],
|
||||||
},
|
},
|
||||||
);
|
];
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,9 @@
|
||||||
"moment": "^2.0.0"
|
"moment": "^2.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@acamarata/eslint-config": "^0.1.0",
|
||||||
|
"@acamarata/prettier-config": "^0.1.0",
|
||||||
|
"@acamarata/tsconfig": "^0.1.0",
|
||||||
"@eslint/js": "^10.0.1",
|
"@eslint/js": "^10.0.1",
|
||||||
"@types/node": "^25.3.5",
|
"@types/node": "^25.3.5",
|
||||||
"eslint": "^10.0.3",
|
"eslint": "^10.0.3",
|
||||||
|
|
@ -82,5 +85,6 @@
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/acamarata/moment-hijri-plus/issues"
|
"url": "https://github.com/acamarata/moment-hijri-plus/issues"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module",
|
||||||
|
"prettier": "@acamarata/prettier-config"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,15 @@ importers:
|
||||||
|
|
||||||
.:
|
.:
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
'@acamarata/eslint-config':
|
||||||
|
specifier: ^0.1.0
|
||||||
|
version: 0.1.0(@typescript-eslint/eslint-plugin@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@8.56.1(eslint@10.0.3)(typescript@5.9.3))(eslint-config-prettier@10.1.8(eslint@10.0.3))(eslint@10.0.3)
|
||||||
|
'@acamarata/prettier-config':
|
||||||
|
specifier: ^0.1.0
|
||||||
|
version: 0.1.0(prettier@3.8.1)
|
||||||
|
'@acamarata/tsconfig':
|
||||||
|
specifier: ^0.1.0
|
||||||
|
version: 0.1.0
|
||||||
'@eslint/js':
|
'@eslint/js':
|
||||||
specifier: ^10.0.1
|
specifier: ^10.0.1
|
||||||
version: 10.0.1(eslint@10.0.3)
|
version: 10.0.1(eslint@10.0.3)
|
||||||
|
|
@ -41,6 +50,32 @@ importers:
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
|
'@acamarata/eslint-config@0.1.0':
|
||||||
|
resolution: {integrity: sha512-St2TObpHKXBLBy1GPrXWlHzXCujJ7jaor6BuWRdLMTOjM56LPBDJx+898R7yFyI8Wi52VWNZdSTPxzHuyRAq+A==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
peerDependencies:
|
||||||
|
'@typescript-eslint/eslint-plugin': '>=8.0.0'
|
||||||
|
'@typescript-eslint/parser': '>=8.0.0'
|
||||||
|
eslint: '>=9.0.0'
|
||||||
|
eslint-config-prettier: '>=9.0.0'
|
||||||
|
eslint-plugin-react: '>=7.0.0'
|
||||||
|
eslint-plugin-react-hooks: '>=5.0.0'
|
||||||
|
peerDependenciesMeta:
|
||||||
|
eslint-plugin-react:
|
||||||
|
optional: true
|
||||||
|
eslint-plugin-react-hooks:
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@acamarata/prettier-config@0.1.0':
|
||||||
|
resolution: {integrity: sha512-ImMnz/653ettR4gJVd1f7Pz61DQSeDmUtguLrnCl8RdYncqfghT+QGEO5Znml0KvgX3vk4c4roPAWYdXaZgcPA==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
peerDependencies:
|
||||||
|
prettier: '>=3.0.0'
|
||||||
|
|
||||||
|
'@acamarata/tsconfig@0.1.0':
|
||||||
|
resolution: {integrity: sha512-bgzyBak43mE+0HhduZX3cvaPjKcggtGGZZMjr35qtYWolsIWgZ9nx7OOswbVYoU35qoUv6rZ0mTK6GbZ8QTYjw==}
|
||||||
|
engines: {node: '>=20'}
|
||||||
|
|
||||||
'@esbuild/aix-ppc64@0.27.3':
|
'@esbuild/aix-ppc64@0.27.3':
|
||||||
resolution: {integrity: sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==}
|
resolution: {integrity: sha512-9fJMTNFTWZMh5qwrBItuziu834eOCUcEqymSH7pY+zoMVEZg3gcPuBNxH1EvfVYe9h0x/Ptw8KBzv7qxb7l8dg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
@ -918,6 +953,19 @@ packages:
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
|
'@acamarata/eslint-config@0.1.0(@typescript-eslint/eslint-plugin@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@8.56.1(eslint@10.0.3)(typescript@5.9.3))(eslint-config-prettier@10.1.8(eslint@10.0.3))(eslint@10.0.3)':
|
||||||
|
dependencies:
|
||||||
|
'@typescript-eslint/eslint-plugin': 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': 8.56.1(eslint@10.0.3)(typescript@5.9.3)
|
||||||
|
eslint: 10.0.3
|
||||||
|
eslint-config-prettier: 10.1.8(eslint@10.0.3)
|
||||||
|
|
||||||
|
'@acamarata/prettier-config@0.1.0(prettier@3.8.1)':
|
||||||
|
dependencies:
|
||||||
|
prettier: 3.8.1
|
||||||
|
|
||||||
|
'@acamarata/tsconfig@0.1.0': {}
|
||||||
|
|
||||||
'@esbuild/aix-ppc64@0.27.3':
|
'@esbuild/aix-ppc64@0.27.3':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
|
|
||||||
23
src/index.ts
23
src/index.ts
|
|
@ -100,9 +100,12 @@ function install(momentInstance: typeof moment): void {
|
||||||
case 'iYY':
|
case 'iYY':
|
||||||
return escapeLiteral(String(hijri.hy % 100).padStart(2, '0'));
|
return escapeLiteral(String(hijri.hy % 100).padStart(2, '0'));
|
||||||
case 'iMMMM':
|
case 'iMMMM':
|
||||||
return escapeLiteral(hmLong[hijri.hm - 1]);
|
// Non-null: hijri.hm is 1-12; hm-1 is always 0-11, within hmLong bounds.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
return escapeLiteral(hmLong[hijri.hm - 1]!);
|
||||||
case 'iMMM':
|
case 'iMMM':
|
||||||
return escapeLiteral(hmMedium[hijri.hm - 1]);
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
return escapeLiteral(hmMedium[hijri.hm - 1]!);
|
||||||
case 'iMM':
|
case 'iMM':
|
||||||
return escapeLiteral(String(hijri.hm).padStart(2, '0'));
|
return escapeLiteral(String(hijri.hm).padStart(2, '0'));
|
||||||
case 'iM':
|
case 'iM':
|
||||||
|
|
@ -112,11 +115,15 @@ function install(momentInstance: typeof moment): void {
|
||||||
case 'iD':
|
case 'iD':
|
||||||
return escapeLiteral(String(hijri.hd));
|
return escapeLiteral(String(hijri.hd));
|
||||||
case 'iEEEE':
|
case 'iEEEE':
|
||||||
return escapeLiteral(hwLong[dow]);
|
// Non-null: dow is always 0-6 (day of week), within hwLong bounds.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
return escapeLiteral(hwLong[dow]!);
|
||||||
case 'iEEE':
|
case 'iEEE':
|
||||||
return escapeLiteral(hwShort[dow]);
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
return escapeLiteral(hwShort[dow]!);
|
||||||
case 'iE':
|
case 'iE':
|
||||||
return escapeLiteral(String(hwNumeric[dow]));
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
return escapeLiteral(String(hwNumeric[dow]!));
|
||||||
// Era tokens: both iooo and ioooo map to the common abbreviation.
|
// Era tokens: both iooo and ioooo map to the common abbreviation.
|
||||||
case 'iooo':
|
case 'iooo':
|
||||||
case 'ioooo':
|
case 'ioooo':
|
||||||
|
|
@ -128,10 +135,10 @@ function install(momentInstance: typeof moment): void {
|
||||||
return this.format(residual);
|
return this.format(residual);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attach fromHijri as a property on the constructor. We use a type assertion
|
// Attach fromHijri as a property on the constructor. We use bracket notation and a type
|
||||||
// because MomentStatic augmentation produces a DTS visibility error with some
|
// assertion because MomentStatic augmentation produces a DTS visibility error with some
|
||||||
// TypeScript configurations; attaching at runtime is equivalent and safe.
|
// TypeScript configurations; attaching at runtime is equivalent and safe.
|
||||||
(momentInstance as unknown as Record<string, unknown>).fromHijri = function (
|
(momentInstance as unknown as Record<string, unknown>)['fromHijri'] = function (
|
||||||
hy: number,
|
hy: number,
|
||||||
hm: number,
|
hm: number,
|
||||||
hd: number,
|
hd: number,
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,10 @@
|
||||||
{
|
{
|
||||||
|
"extends": "@acamarata/tsconfig/tsconfig.library.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "ES2020",
|
|
||||||
"module": "ESNext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"strict": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"declaration": true,
|
|
||||||
"declarationMap": true,
|
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"noFallthroughCasesInSwitch": true,
|
"noFallthroughCasesInSwitch": true,
|
||||||
"sourceMap": true,
|
"esModuleInterop": true,
|
||||||
"outDir": "dist",
|
"allowSyntheticDefaultImports": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"types": ["node"]
|
"types": ["node"]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue