Update loaders

Plus configure prettier to run via eslint. That makes it easier
to hide certain blocks of code from the linter.
This commit is contained in:
0x1eef 2024-06-09 15:27:32 -03:00
parent 62ed9c93e8
commit 20fb969959
8 changed files with 165 additions and 44 deletions

View file

@ -1,5 +1,6 @@
module.exports = {
extends: ["standard-with-typescript", "standard-jsx", "prettier"],
"plugins": ["prettier"],
parserOptions: {
project: "./tsconfig.json",
},
@ -24,5 +25,16 @@ module.exports = {
"quotes": 0,
"object-curly-spacing": 2,
"n/no-callback-literal": 0,
"prettier/prettier": [
"error",
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"printWidth": 90,
"arrowParens": "avoid"
}
]
},
};

View file

@ -1,8 +0,0 @@
node_modules
# Ignore artifacts:
build
tmp
.idea
coverage
src/ar
src/en

View file

@ -1,8 +0,0 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"printWidth": 90,
"arrowParens": "avoid"
}

150
package-lock.json generated
View file

@ -20,7 +20,8 @@
"esbuild-loader": "^4.1.0",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.7.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.0.0",
"ts-standard": "^12.0.1",
"typescript": "^4.8.2",
"url": "^0.11.3",
@ -559,6 +560,18 @@
"node": ">= 8"
}
},
"node_modules/@pkgr/core": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
"integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==",
"dev": true,
"engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/unts"
}
},
"node_modules/@types/css-font-loading-module": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/@types/css-font-loading-module/-/css-font-loading-module-0.0.7.tgz",
@ -1999,6 +2012,36 @@
"eslint": ">=7.0.0"
}
},
"node_modules/eslint-plugin-prettier": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz",
"integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==",
"dev": true,
"dependencies": {
"prettier-linter-helpers": "^1.0.0",
"synckit": "^0.8.6"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/eslint-plugin-prettier"
},
"peerDependencies": {
"@types/eslint": ">=8.0.0",
"eslint": ">=8.0.0",
"eslint-config-prettier": "*",
"prettier": ">=3.0.0"
},
"peerDependenciesMeta": {
"@types/eslint": {
"optional": true
},
"eslint-config-prettier": {
"optional": true
}
}
},
"node_modules/eslint-plugin-promise": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz",
@ -2316,6 +2359,12 @@
"dev": true,
"license": "MIT"
},
"node_modules/fast-diff": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
"dev": true
},
"node_modules/fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
@ -3758,20 +3807,32 @@
}
},
"node_modules/prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.1.tgz",
"integrity": "sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=10.13.0"
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"dependencies": {
"fast-diff": "^1.1.2"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
@ -4400,6 +4461,28 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/synckit": {
"version": "0.8.8",
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz",
"integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==",
"dev": true,
"dependencies": {
"@pkgr/core": "^0.1.0",
"tslib": "^2.6.2"
},
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
"funding": {
"url": "https://opencollective.com/unts"
}
},
"node_modules/synckit/node_modules/tslib": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==",
"dev": true
},
"node_modules/tapable": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
@ -5191,6 +5274,12 @@
"fastq": "^1.6.0"
}
},
"@pkgr/core": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz",
"integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==",
"dev": true
},
"@types/css-font-loading-module": {
"version": "0.0.7",
"resolved": "https://registry.npmjs.org/@types/css-font-loading-module/-/css-font-loading-module-0.0.7.tgz",
@ -6292,6 +6381,16 @@
"semver": "^7.3.7"
}
},
"eslint-plugin-prettier": {
"version": "5.1.3",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz",
"integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0",
"synckit": "^0.8.6"
}
},
"eslint-plugin-promise": {
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-6.1.1.tgz",
@ -6457,6 +6556,12 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
"fast-diff": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz",
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
"dev": true
},
"fast-glob": {
"version": "3.2.12",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz",
@ -7489,11 +7594,20 @@
"dev": true
},
"prettier": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz",
"integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==",
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.1.tgz",
"integrity": "sha512-7CAwy5dRsxs8PHXT3twixW9/OEll8MLE0VRPCJyl7CkS6VHGPSlsVaWTiASPTyGyYRyApxlaWTzwUxVNrhcwDg==",
"dev": true
},
"prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"requires": {
"fast-diff": "^1.1.2"
}
},
"prop-types": {
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
@ -7923,6 +8037,24 @@
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
"dev": true
},
"synckit": {
"version": "0.8.8",
"resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz",
"integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==",
"dev": true,
"requires": {
"@pkgr/core": "^0.1.0",
"tslib": "^2.6.2"
},
"dependencies": {
"tslib": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.3.tgz",
"integrity": "sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==",
"dev": true
}
}
},
"tapable": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",

View file

@ -5,8 +5,7 @@
],
"scripts": {
"tsc": "tsc --noEmit",
"eslint": "npm exec eslint -- --fix src/js/",
"prettier": "npm exec prettier -- --write src/js/"
"eslint": "npm exec eslint -- --fix src/js/"
},
"dependencies": {
"classnames": "^2.3.2",
@ -20,7 +19,8 @@
"esbuild-loader": "^4.1.0",
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"prettier": "^2.7.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.0.0",
"ts-standard": "^12.0.1",
"typescript": "^4.8.2",
"url": "^0.11.3",

View file

@ -6,7 +6,6 @@ task :ci do
# format
sh "bundle exec rubocop"
sh "npm exec eslint -- src/js/"
sh "npm exec prettier -- --check src/js/"
##
# tsc

View file

@ -13,7 +13,7 @@ import type { TLocale } from "Quran";
/* Postman */
const loader: HTMLElement = doc.querySelector(".postman.loader")!;
const stylesheet: HTMLStyleElement = doc.querySelector(".css.postman")!;
const style: HTMLStyleElement = doc.querySelector(".css.postman")!;
const progressBar: HTMLProgressElement = loader.querySelector("progress")!;
const progressNumber: HTMLSpanElement = loader.querySelector(".percentage")!;
@ -29,8 +29,7 @@ import type { TLocale } from "Quran";
)
.fetch()
.then(pkg => {
stylesheet.remove();
loader.remove();
[loader, style].forEach(el => el.remove());
pkg.fonts.forEach(f => document.fonts.add(f));
pkg.css.forEach(s => document.head.appendChild(s));
pkg.scripts.forEach(s => document.body.removeChild(document.body.appendChild(s)));

View file

@ -14,7 +14,7 @@ import type { TLocale } from "Quran";
/* Postman */
const loader = doc.querySelector(".postman.loader")!;
const stylesheet = doc.querySelector(".css.postman")!;
const style = doc.querySelector(".css.postman")!;
const progressBar = loader.querySelector("progress")!;
const progressNumber: HTMLSpanElement = loader.querySelector(".percentage")!;
@ -23,15 +23,11 @@ import type { TLocale } from "Quran";
item.css(`/css/main/surah-stream.css?v=${rev}`),
item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"),
item.font("Mada Regular", "url(/fonts/mada-regular.ttf"),
item.json(`/json/${doc.lang}/${surahId}/info.json?v=${rev}`, {
className: "json surahinfo",
}),
item.json(`/json/${doc.lang}/${surahId}/surah.json?v=${rev}`, {
className: "json surah",
}),
item.json(`/json/durations/${surahId}.json?v=${rev}`, {
className: "json durations",
}),
/* eslint-disable */
item.json(`/json/${doc.lang}/${surahId}/info.json?v=${rev}`, { className: "json surahinfo" }),
item.json(`/json/${doc.lang}/${surahId}/surah.json?v=${rev}`, { className: "json surah" }),
item.json(`/json/durations/${surahId}.json?v=${rev}`, { className: "json durations" }),
/* eslint-enable */
item.progress((percent: number) => {
progressBar.value = percent;
progressNumber.innerText = formatNumber(locale, Number(percent.toFixed(0)));
@ -39,8 +35,7 @@ import type { TLocale } from "Quran";
)
.fetch()
.then(pkg => {
stylesheet.remove();
loader.remove();
[loader, style].forEach(el => el.remove());
pkg.fonts.forEach(f => document.fonts.add(f));
pkg.css.forEach(s => document.head.appendChild(s));
pkg.json.forEach(o => document.body.appendChild(o));