Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes prettier async in code quality file #4026

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions code_quality.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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);
Expand All @@ -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++;
}
});
Expand Down
2 changes: 1 addition & 1 deletion container/src/LuigiCompoundContainer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<svelte:options
customElement={{
tag: null,
tag: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed because of reported 'svelte_options_invalid_tagname' error:
https://svelte.dev/docs/svelte/compiler-errors#svelte_options_invalid_tagname

shadow: 'none',
props: {
activeFeatureToggleList: { type: 'Array', reflect: false, attribute: 'active-feature-toggle-list' },
Expand Down
2 changes: 1 addition & 1 deletion container/src/LuigiContainer.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<svelte:options
customElement={{
tag: null,
tag: '',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed because of reported 'svelte_options_invalid_tagname' error:
https://svelte.dev/docs/svelte/compiler-errors#svelte_options_invalid_tagname

shadow: 'none',
props: {
activeFeatureToggleList: { type: 'Array', reflect: false, attribute: 'active-feature-toggle-list' },
Expand Down
27 changes: 0 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading