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

Adding prettier #36

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .github/workflows/lint-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
run: npm ci
- run: npm run tsc
- run: npm run lint
- run: npm run prettier

unit-tests:
runs-on: ubuntu-latest
Expand Down
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Add files here to ignore them from prettier formatting

/coverage
/mkdocs

.next
node_modules
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"importOrder": [
"^react",
"^react-native",
"^[a-zA-Z]",
"^@?\\w",
"^@/?\\w",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"tabWidth": 4
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"prettier": "prettier -c \"{**/*,*}.{ts,tsx,json,js,md}\"",
"prettier-fix": "prettier --write \"{**/*,*}.{ts,tsx,json,js,md}\"",
"prepare": "husky"
},
"dependencies": {
Expand Down
65 changes: 32 additions & 33 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import React, { useEffect, useState } from "react";
import NoSSR from "react-no-ssr";
import { QueryClient, QueryClientProvider } from "react-query";
import { ReactQueryDevtools } from "react-query/devtools";
import { QueryClientConfig } from "react-query/types/core/types";

import { SessionProvider } from "next-auth/react";
import { NextAdapter } from "next-query-params";
import App, { AppContext, AppInitialProps, AppProps } from "next/app";
import Head from "next/head";
import { useRouter } from "next/router";
import { QueryParamProvider } from "use-query-params";

import type { EuiSideNavItemType } from "@elastic/eui";
import { EuiProvider, EuiThemeColorMode } from "@elastic/eui";
import "@elastic/eui/dist/eui_theme_light.min.css";

import React, { useEffect, useState } from 'react';
import NoSSR from 'react-no-ssr';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';
import { QueryClientConfig } from 'react-query/types/core/types';

import { SessionProvider } from 'next-auth/react';
import { NextAdapter } from 'next-query-params';
import App, { AppContext, AppInitialProps, AppProps } from 'next/app';
import Head from 'next/head';
import { useRouter } from 'next/router';
import { QueryParamProvider } from 'use-query-params';

import type { EuiSideNavItemType } from '@elastic/eui';
import { EuiProvider, EuiThemeColorMode } from '@elastic/eui';
import '@elastic/eui/dist/eui_theme_light.min.css';
import {
ColorModes,
ConfirmationDialogContextWrapper,
Expand All @@ -27,13 +26,13 @@ import {
WfoPageTemplate,
WfoToastsList,
defaultOrchestratorTheme,
} from "@orchestrator-ui/orchestrator-ui-components";
} from '@orchestrator-ui/orchestrator-ui-components';

import { getAppLogo } from "@/components/AppLogo/AppLogo";
import { getInitialOrchestratorConfig } from "@/configuration";
import { TranslationsProvider } from "@/translations/translationsProvider";
import { getAppLogo } from '@/components/AppLogo/AppLogo';
import { getInitialOrchestratorConfig } from '@/configuration';
import { TranslationsProvider } from '@/translations/translationsProvider';

import "../font/inter.css";
import '../font/inter.css';

type AppOwnProps = { orchestratorConfig: OrchestratorConfig };

Expand All @@ -55,17 +54,17 @@ function CustomApp({
const [queryClient] = useState(() => new QueryClient(queryClientConfig));

const [themeMode, setThemeMode] = useState<EuiThemeColorMode>(
ColorModes.LIGHT
ColorModes.LIGHT,
);

const handleThemeSwitch = (newThemeMode: EuiThemeColorMode) => {
setThemeMode(newThemeMode);
localStorage.setItem("themeMode", newThemeMode);
localStorage.setItem('themeMode', newThemeMode);
};

useEffect(() => {
// Initialize theme mode from localStorage or set it to 'light' if not present
const storedTheme = localStorage.getItem("themeMode");
const storedTheme = localStorage.getItem('themeMode');
if (
!storedTheme ||
(storedTheme !== ColorModes.LIGHT &&
Expand All @@ -76,19 +75,19 @@ function CustomApp({
}, []);

const addMenuItems = (
defaultMenuItems: EuiSideNavItemType<object>[]
defaultMenuItems: EuiSideNavItemType<object>[],
): EuiSideNavItemType<object>[] => [
...defaultMenuItems,
{
name: "Example form",
id: "10",
isSelected: router.pathname === "/example-form",
href: "/example-form",
name: 'Example form',
id: '10',
isSelected: router.pathname === '/example-form',
href: '/example-form',
renderItem: () => (
<WfoMenuItemLink
path={"/example-form"}
path={'/example-form'}
translationString="Example form"
isSelected={router.pathname === "/example-form"}
isSelected={router.pathname === '/example-form'}
/>
),
},
Expand Down Expand Up @@ -168,7 +167,7 @@ function CustomApp({
}

CustomApp.getInitialProps = async (
context: AppContext
context: AppContext,
): Promise<AppOwnProps & AppInitialProps> => {
const ctx = await App.getInitialProps(context);

Expand Down
Loading