From ed6685580e16dd8f6b7f214957e1ee215002ae0e Mon Sep 17 00:00:00 2001 From: Kenneth Aasan Date: Wed, 24 Apr 2024 09:45:04 +0200 Subject: [PATCH] refactor: upgrade prettier and format code accordingly (#997) --- .eslintrc.json | 6 +- .gitpod.yml | 2 +- .prettierignore | 1 + library/e2e/plugins/index.js | 2 +- library/loaders/remove-hashbag-loader.js | 2 +- library/src/components/Bindings.tsx | 2 +- library/src/components/Schema.tsx | 102 +++++++++--------- library/src/components/Tags.tsx | 2 +- .../containers/Messages/MessageExample.tsx | 2 +- library/src/containers/Messages/Messages.tsx | 6 +- .../src/containers/Operations/Operation.tsx | 28 +++-- .../src/containers/Operations/Operations.tsx | 6 +- library/src/containers/Schemas/Schemas.tsx | 8 +- library/src/containers/Servers/Security.tsx | 7 +- library/src/containers/Servers/Servers.tsx | 6 +- library/src/containers/Sidebar/Sidebar.tsx | 55 ++++------ library/src/contexts/useSpec.ts | 5 +- library/src/helpers/message.ts | 33 +++--- library/src/helpers/schema.ts | 32 +++--- library/src/helpers/sidebar.ts | 8 +- library/src/helpers/specification.ts | 6 +- library/tailwind.config.js | 4 +- library/webpack.config.js | 4 +- package-lock.json | 98 +++++++++++++++-- package.json | 6 +- playground/components/FetchSchema.tsx | 4 +- playground/components/Tab.tsx | 2 +- playground/components/Tabs.tsx | 2 +- playground/components/styled.ts | 14 ++- web-component/src/AsyncApiWebComponent.tsx | 4 +- 30 files changed, 265 insertions(+), 194 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index dabc669f2..4cd2f8290 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -20,8 +20,8 @@ "@typescript-eslint", "@typescript-eslint/tslint", "sonarjs", - "jest" - // "prettier" uncomment when prettier is upgraded to the newest version + "jest", + "prettier" ], "settings": { "next": { @@ -39,7 +39,7 @@ }, "root": true, "rules": { - // "prettier/prettier": "error" uncomment when prettier is upgraded to the newest version + "prettier/prettier": "error", "jest/expect-expect": [ "error", { diff --git a/.gitpod.yml b/.gitpod.yml index 738349d00..f7d3bc69f 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -6,4 +6,4 @@ tasks: # List the ports to expose. Learn more https://www.gitpod.io/docs/config-ports/ ports: - port: 3000 - onOpen: open-preview \ No newline at end of file + onOpen: open-preview diff --git a/.prettierignore b/.prettierignore index 14e3dce0c..988b27454 100644 --- a/.prettierignore +++ b/.prettierignore @@ -21,3 +21,4 @@ lerna-debug.log* /.github playground/.next/ +playground/out/ diff --git a/library/e2e/plugins/index.js b/library/e2e/plugins/index.js index 72005749b..5ab0413d2 100644 --- a/library/e2e/plugins/index.js +++ b/library/e2e/plugins/index.js @@ -23,6 +23,6 @@ const webpackOptions = { }, }; -module.exports = on => { +module.exports = (on) => { on('file:preprocessor', wp({ webpackOptions })); }; diff --git a/library/loaders/remove-hashbag-loader.js b/library/loaders/remove-hashbag-loader.js index 43960049f..75df48679 100644 --- a/library/loaders/remove-hashbag-loader.js +++ b/library/loaders/remove-hashbag-loader.js @@ -1,6 +1,6 @@ /** * Make sure code does not contain properties such as `#property` */ -module.exports = function(source) { +module.exports = function (source) { return source.replace(/^#! .*\n/, ''); }; diff --git a/library/src/components/Bindings.tsx b/library/src/components/Bindings.tsx index 7b77e7c88..f40deb37f 100644 --- a/library/src/components/Bindings.tsx +++ b/library/src/components/Bindings.tsx @@ -17,7 +17,7 @@ export const Bindings: React.FunctionComponent = ({ return null; } - const renderedBindings = bindings.all().map(binding => { + const renderedBindings = bindings.all().map((binding) => { const bindingValue = binding.value(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const schema = SchemaHelpers.jsonToSchema(bindingValue); diff --git a/library/src/components/Schema.tsx b/library/src/components/Schema.tsx index 328d6cd27..2f632085c 100644 --- a/library/src/components/Schema.tsx +++ b/library/src/components/Schema.tsx @@ -98,14 +98,14 @@ export const Schema: React.FunctionComponent = ({ {isExpandable && !isCircular && !isArray ? ( <> setExpanded(prev => !prev)} + onClick={() => setExpanded((prev) => !prev)} expanded={expanded} > {renderedSchemaName}