Skip to content

Commit

Permalink
chore: add eslint config and prettier (#1025)
Browse files Browse the repository at this point in the history
  • Loading branch information
gary-van-woerkens authored Aug 4, 2023
1 parent e4db769 commit 8abe6b3
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 45 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"],
"react/no-children-prop": "off"
}
}
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": false,
"tabWidth": 2,
"useTabs": false,
"printWidth": 80,
"singleQuote": false,
"trailingComma": "es5"
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"typescript": "5.1.6"
},
"devDependencies": {
"eslint-plugin-prettier": "5.0.0",
"prettier": "3.0.1",
"sass": "1.64.2"
}
}
18 changes: 9 additions & 9 deletions src/app/StartDsfr.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"use client";
"use client"

import { startReactDsfr } from "@codegouvfr/react-dsfr/next-appdir";
import { defaultColorScheme } from "./defaultColorScheme";
import Link from "next/link";
import { startReactDsfr } from "@codegouvfr/react-dsfr/next-appdir"
import { defaultColorScheme } from "./defaultColorScheme"
import Link from "next/link"

declare module "@codegouvfr/react-dsfr/next-appdir" {
interface RegisterLink {
Link: typeof Link;
interface RegisterLink {
Link: typeof Link
}
}

startReactDsfr({ defaultColorScheme, Link });
startReactDsfr({ defaultColorScheme, Link })

export function StartDsfr(){
export function StartDsfr() {
//Yes, leave null here.
return null;
return null
}
25 changes: 15 additions & 10 deletions src/app/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Footer as DSFRFooter, type FooterProps } from "@codegouvfr/react-dsfr/Footer";
import {
Footer as DSFRFooter,
type FooterProps,
} from "@codegouvfr/react-dsfr/Footer"

import { items as navigationItems } from "./Navigation";
import { items as navigationItems } from "./Navigation"

const otherLinks: FooterProps.LinkList.Column = {
categoryName: "Autres",
links: navigationItems.filter((item) => !item.menuLinks) as FooterProps.LinkList.Links,
};
links: navigationItems.filter(
(item) => !item.menuLinks
) as FooterProps.LinkList.Links,
}

const navigationToFooterLinkList: FooterProps.LinkList.List = [
...navigationItems
Expand All @@ -14,14 +19,14 @@ const navigationToFooterLinkList: FooterProps.LinkList.List = [
const listColumn: FooterProps.LinkList.Column = {
categoryName: item.text as string,
links: item.menuLinks?.map((menuLink) => {
const link = menuLink as FooterProps.LinkList.Link;
return link;
const link = menuLink as FooterProps.LinkList.Link
return link
}) as FooterProps.LinkList.Links,
};
return listColumn;
}
return listColumn
}),
otherLinks,
] as unknown as FooterProps.LinkList.List;
] as unknown as FooterProps.LinkList.List

export default function Footer() {
return (
Expand Down Expand Up @@ -59,5 +64,5 @@ export default function Footer() {
}}
linkList={navigationToFooterLinkList}
/>
);
)
}
9 changes: 5 additions & 4 deletions src/app/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Navigation from "./Navigation";
import { Header as DSFRHeader } from "@codegouvfr/react-dsfr/Header";
import Navigation from "./Navigation"
import { Header as DSFRHeader } from "@codegouvfr/react-dsfr/Header"

export default function Header() {
return (
Expand All @@ -13,7 +13,8 @@ export default function Header() {
}
homeLinkProps={{
href: "/",
title: "Accueil - Nom de l'entité (ministère, secrétariat d'état, gouvernement)",
title:
"Accueil - Nom de l'entité (ministère, secrétariat d'état, gouvernement)",
}}
id="fr-header-header-with-quick-access-items-nav-items-and-search-engine"
navigation={<Navigation />}
Expand All @@ -29,5 +30,5 @@ export default function Header() {
serviceTagline="Un incubateur betagouv 🥸"
serviceTitle="La Fabrique des Ministères Sociaux"
/>
);
)
}
7 changes: 5 additions & 2 deletions src/app/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { MainNavigation, type MainNavigationProps } from "@codegouvfr/react-dsfr/MainNavigation";
import {
MainNavigation,
type MainNavigationProps,
} from "@codegouvfr/react-dsfr/MainNavigation"

export const items: MainNavigationProps.Item[] = [
{
Expand Down Expand Up @@ -74,7 +77,7 @@ export const items: MainNavigationProps.Item[] = [
},
text: "Recrutement",
},
];
]

export default function Navigation() {
return <MainNavigation items={items} />
Expand Down
4 changes: 2 additions & 2 deletions src/app/defaultColorScheme.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { DefaultColorScheme } from "@codegouvfr/react-dsfr/next-appdir";
import type { DefaultColorScheme } from "@codegouvfr/react-dsfr/next-appdir"

export const defaultColorScheme: DefaultColorScheme = "system";
export const defaultColorScheme: DefaultColorScheme = "system"
32 changes: 18 additions & 14 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import "./globals.css";
import type { Metadata } from "next";
import "./globals.css"
import type { Metadata } from "next"

import { defaultColorScheme } from "./defaultColorScheme";
import { DsfrHead } from "@codegouvfr/react-dsfr/next-appdir/DsfrHead";
import { DsfrProvider } from "@codegouvfr/react-dsfr/next-appdir/DsfrProvider";
import { getHtmlAttributes } from "@codegouvfr/react-dsfr/next-appdir/getHtmlAttributes";
import { StartDsfr } from "./StartDsfr";
import { defaultColorScheme } from "./defaultColorScheme"
import { DsfrHead } from "@codegouvfr/react-dsfr/next-appdir/DsfrHead"
import { DsfrProvider } from "@codegouvfr/react-dsfr/next-appdir/DsfrProvider"
import { getHtmlAttributes } from "@codegouvfr/react-dsfr/next-appdir/getHtmlAttributes"
import { StartDsfr } from "./StartDsfr"

import Link from "next/link";
import Header from "./components/Header";
import Footer from "./components/Footer";
import Link from "next/link"
import Header from "./components/Header"
import Footer from "./components/Footer"

export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
};
}

export default function RootLayout({ children }: { children: React.ReactNode }) {
const lang = "fr";
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
const lang = "fr"
return (
<html {...getHtmlAttributes({ defaultColorScheme, lang })}>
<head>
Expand Down Expand Up @@ -46,5 +50,5 @@ export default function RootLayout({ children }: { children: React.ReactNode })
</DsfrProvider>
</body>
</html>
);
)
}
9 changes: 6 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { fr } from "@codegouvfr/react-dsfr";
import { fr } from "@codegouvfr/react-dsfr"

export default function Home() {
return (
<main id="contenu" className="flex min-h-screen flex-col items-center justify-between p-24">
<main
id="contenu"
className="flex min-h-screen flex-col items-center justify-between p-24"
>
<section className={fr.cx("fr-h1")}>
<h1>Santé, Solidarité, Travail: nos startups à votre service</h1>
</section>
</main>
);
)
}
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,14 @@ eslint-plugin-jsx-a11y@^6.5.1:
object.fromentries "^2.0.6"
semver "^6.3.0"

eslint-plugin-prettier@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz#6887780ed95f7708340ec79acfdf60c35b9be57a"
integrity sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w==
dependencies:
prettier-linter-helpers "^1.0.0"
synckit "^0.8.5"

eslint-plugin-react-hooks@5.0.0-canary-7118f5dd7-20230705:
version "5.0.0-canary-7118f5dd7-20230705"
resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-5.0.0-canary-7118f5dd7-20230705.tgz#4d55c50e186f1a2b0636433d2b0b2f592ddbccfd"
Expand Down Expand Up @@ -1053,6 +1061,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-diff@^1.1.2:
version "1.3.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0"
integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==

fast-glob@^3.2.12, fast-glob@^3.2.9, fast-glob@^3.3.0:
version "3.3.1"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4"
Expand Down Expand Up @@ -2042,6 +2055,18 @@ prelude-ls@^1.2.1:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396"
integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==

prettier-linter-helpers@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b"
integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==
dependencies:
fast-diff "^1.1.2"

prettier@3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.1.tgz#65271fc9320ce4913c57747a70ce635b30beaa40"
integrity sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ==

prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
Expand Down

0 comments on commit 8abe6b3

Please sign in to comment.