Replace prettier by stylistic to lint JavaScript (#3303)

In the latest versions of ESLint, more and more formatting rules were
removed or declared deprecated. These rules have been integrated into
the new Stylistic package (https://eslint.style/guide/why) and expanded.

Stylistic acts as a better formatter  for JavaScript as Prettier.

With this PR there are many changes that make the code more uniform, but
it may be difficult to review due to the large amount. Even if I have no
worries about the changes, perhaps this would be something for the
release after next.

Let me know what you think.
This commit is contained in:
Kristjan ESPERANTO 2023-12-25 08:17:11 +01:00 committed by GitHub
parent 4e7b68a69d
commit 0b70274a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
64 changed files with 954 additions and 942 deletions

View file

@ -9,7 +9,7 @@ const startUp = new Date();
* @param {Request} req - the request
* @param {Response} res - the result
*/
function getConfig(req, res) {
function getConfig (req, res) {
res.send(config);
}
@ -18,7 +18,7 @@ function getConfig(req, res) {
* @param {Request} req - the request
* @param {Response} res - the result
*/
function getStartup(req, res) {
function getStartup (req, res) {
res.send(startUp);
}
@ -31,7 +31,7 @@ function getStartup(req, res) {
* @param {Request} req - the request
* @param {Response} res - the result
*/
async function cors(req, res) {
async function cors (req, res) {
try {
const urlRegEx = "url=(.+?)$";
let url;
@ -68,7 +68,7 @@ async function cors(req, res) {
* @param {string} url - The url containing the headers and values to send.
* @returns {object} An object specifying name and value of the headers.
*/
function getHeadersToSend(url) {
function getHeadersToSend (url) {
const headersToSend = { "User-Agent": `Mozilla/5.0 MagicMirror/${global.version}` };
const headersToSendMatch = new RegExp("sendheaders=(.+?)(&|$)", "g").exec(url);
if (headersToSendMatch) {
@ -89,7 +89,7 @@ function getHeadersToSend(url) {
* @param {string} url - The url containing the expected headers from the response.
* @returns {string[]} headers - The name of the expected headers.
*/
function geExpectedRecievedHeaders(url) {
function geExpectedRecievedHeaders (url) {
const expectedRecievedHeaders = ["Content-Type"];
const expectedRecievedHeadersMatch = new RegExp("expectedheaders=(.+?)(&|$)", "g").exec(url);
if (expectedRecievedHeadersMatch) {
@ -106,7 +106,7 @@ function geExpectedRecievedHeaders(url) {
* @param {Request} req - the request
* @param {Response} res - the result
*/
function getHtml(req, res) {
function getHtml (req, res) {
let html = fs.readFileSync(path.resolve(`${global.root_path}/index.html`), { encoding: "utf8" });
html = html.replace("#VERSION#", global.version);
@ -124,7 +124,7 @@ function getHtml(req, res) {
* @param {Request} req - the request
* @param {Response} res - the result
*/
function getVersion(req, res) {
function getVersion (req, res) {
res.send(global.version);
}