From 7e8de4ba72778a1a051ea9fc296f831bbc8e5ba8 Mon Sep 17 00:00:00 2001 From: Waldemar Mazurek Date: Thu, 14 Nov 2024 13:29:25 +0100 Subject: [PATCH] Makes prettier async in code quality file --- code_quality.js | 15 +++++++----- container/src/LuigiCompoundContainer.svelte | 2 +- container/src/LuigiContainer.svelte | 2 +- package-lock.json | 27 --------------------- package.json | 1 - 5 files changed, 11 insertions(+), 36 deletions(-) diff --git a/code_quality.js b/code_quality.js index 7f9f4fd990..2acf5a919a 100644 --- a/code_quality.js +++ b/code_quality.js @@ -1,5 +1,5 @@ const gitChangedFiles = require('git-changed-files'); -const prettier = require('@prettier/sync'); +const prettier = require('prettier'); const prettierConfig = require('./prettier_config.json'); const codeQualityConfig = require('./package.json').codeQuality || {}; const path = require('path'); @@ -107,15 +107,17 @@ const groupFilesByExtension = (files) => { * @param file: absolute class path * @param config: configuration that will be used to prettier the file. */ -const prettifyFile = (file, config) => { +const prettifyFile = async (file, config) => { try { const text = fs.readFileSync(file).toString(); - if (prettier.check(text, config) || config?.excludedFiles?.includes(file)) { + const check = await prettier.check(text, config); + if (check || config?.excludedFiles?.includes(file)) { return; } console.log('Running prettier on the file: ' + file); - fs.writeFileSync(file, prettier.format(text, config)); + const format = await prettier.format(text, config); + fs.writeFileSync(file, format); return true; } catch (error) { console.log('Error in running prettier the file ' + file + ': \n' + error); @@ -140,8 +142,9 @@ const prettifyFiles = (filesByExtension) => { ); return; } - files.forEach((file) => { - if (prettifyFile(file, config)) { + files.forEach(async (file) => { + const action = await prettifyFile(file, config); + if (action) { filesChanged++; } }); diff --git a/container/src/LuigiCompoundContainer.svelte b/container/src/LuigiCompoundContainer.svelte index 9a6fe53660..4b8ebc7950 100644 --- a/container/src/LuigiCompoundContainer.svelte +++ b/container/src/LuigiCompoundContainer.svelte @@ -1,6 +1,6 @@ = 10" } }, - "node_modules/make-synchronized": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/make-synchronized/-/make-synchronized-0.2.9.tgz", - "integrity": "sha512-4wczOs8SLuEdpEvp3vGo83wh8rjJ78UsIk7DIX5fxdfmfMJGog4bQzxfvOwq7Q3yCHLC4jp1urPHIxRS/A93gA==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/fisker/make-synchronized?sponsor=1" - } - }, "node_modules/matcher": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/matcher/-/matcher-1.1.1.tgz", diff --git a/package.json b/package.json index b191e4e18a..d23af499a6 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,6 @@ "full-code-quality-eslint-e2e-tests": "node code_quality.js -- mode=full_eslint sourcePaths=test/e2e-test-application/cypress/e2e/tests report=e2e-test_full_eslint_report.html" }, "devDependencies": { - "@prettier/sync": "^0.5.2", "@stylistic/eslint-plugin": "^2.10.1", "@typescript-eslint/eslint-plugin": "^8.13.0", "@typescript-eslint/parser": "^8.13.0",