diff --git a/.husky/pre-commit b/.husky/pre-commit index 4cac0e3..f332859 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -yarn ts:check && yarn lint-staged && yarn build:scripts +yarn lint-staged && yarn build:scripts diff --git a/.lintstagedrc.json b/.lintstagedrc.json deleted file mode 100644 index ae6a6c4..0000000 --- a/.lintstagedrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "*.{json, md, yml, js, ts, tsx, scss}": ["prettier --write"] -} diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 0000000..8e0a414 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,8 @@ +module.exports = { + "*.{json, md, yml, scss}": ["prettier --write"], + "*.{js, ts, tsx}": [ + "eslint", + "prettier --write", + "react-scripts test --watchAll=false --findRelatedTests", + ], +}; diff --git a/package.json b/package.json index 1768bcc..60c56fa 100644 --- a/package.json +++ b/package.json @@ -21,40 +21,41 @@ "build:scripts": "tsc --project tsconfig.scripts.json", "test": "react-scripts test", "ts:check": "tsc --noEmit", - "lint": "yarn ts:check" + "lint": "yarn ts:check && eslint src/**/*.tsx" }, "dependencies": { - "@types/fs-extra": "^9.0.11", + "@types/fs-extra": "^9.0.13", "@types/marked": "^2.0.3", "@types/node": "^12.0.0", - "@types/react": "^17.0.0", - "@types/react-dom": "^17.0.0", - "@types/react-router-dom": "^5.1.7", - "@types/walk": "^2.3.0", + "@types/react": "^17.0.24", + "@types/react-dom": "^17.0.9", + "@types/react-router-dom": "^5.3.0", + "@types/walk": "^2.3.1", "classnames": "^2.3.1", "front-matter": "^4.0.2", "fs-extra": "^10.0.0", - "highlight.js": "^11.0.0", + "highlight.js": "^11.2.0", "marked": "^2.0.7", "moment": "^2.29.1", - "query-string": "^7.0.0", + "query-string": "^7.0.1", "react": "^17.0.2", "react-dom": "^17.0.2", "react-icons": "^4.2.0", - "react-router-dom": "^5.2.0", + "react-router-dom": "^5.3.0", "react-scripts": "4.0.3", - "sass": "^1.34.0", - "typescript": "^4.1.2", - "walk": "^2.3.14" + "sass": "^1.42.1", + "typescript": "4.3.5", + "walk": "^2.3.15" }, "devDependencies": { + "@testing-library/dom": "^8.6.0", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", "@types/jest": "^26.0.15", "husky": "^6.0.0", - "lint-staged": "^11.0.0", - "prettier": "^2.3.0" + "lint-staged": "^11.1.2", + "prettier": "^2.4.1" }, "eslintConfig": { "extends": [ diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..f053ebf --- /dev/null +++ b/prettier.config.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/src/components/Item/Item.test.tsx b/src/components/Item/Item.test.tsx new file mode 100644 index 0000000..4086e34 --- /dev/null +++ b/src/components/Item/Item.test.tsx @@ -0,0 +1,13 @@ +import { render, screen } from "@testing-library/react"; +import { MemoryRouter } from "react-router-dom"; + +import { item as testItem } from "./testData"; +import Item from "./Item"; + +describe("Item", () => { + it("Should render the item", () => { + render(, { wrapper: MemoryRouter }); + + expect(screen.queryByText(testItem.title)).not.toBeInTheDocument(); + }); +}); diff --git a/src/components/Item/Item.tsx b/src/components/Item/Item.tsx index 225d66b..0669a32 100644 --- a/src/components/Item/Item.tsx +++ b/src/components/Item/Item.tsx @@ -9,7 +9,7 @@ type Props = { item: mItem; noLeadingBorder?: boolean; active?: boolean; - style: React.CSSProperties; + style?: React.CSSProperties; greyedOut?: boolean; }; @@ -20,24 +20,24 @@ const Item: React.FC = ({ style = {}, greyedOut = false, }) => ( - -
- {item.title} - -
- {item.info &&
{item.info}
} - + // + //
+ // {item.title} + // + //
+ // {item.info &&
{item.info}
} + // ); export default Item; diff --git a/src/components/Item/testData.tsx b/src/components/Item/testData.tsx new file mode 100644 index 0000000..0cd0bd5 --- /dev/null +++ b/src/components/Item/testData.tsx @@ -0,0 +1,23 @@ +import { Item } from "../../model"; + +export const item: Item = { + flag: "default", + featured: false, + revisions: [ + { + name: "yarn", + release: "2018-03-01", + title: "Yarn", + ring: "trial", + quadrant: "tools", + fileName: "C:\\projects\\techradar\\radar\\2018-03-01\\yarn.md", + body: "

Yarn is a dependency management tool for frontend (node) projects similar to npm. It also uses the npm registry and \ninfrastructure. According to Yarn, the benefits are that Yarn is much faster, automatically writes a .lock file and \nbuilds up a local cache to be even faster when installing packages again.

\n

At AOE, we started using Yarn in different projects to evaluate if we can switch to Yarn for all projects.

\n", + }, + ], + name: "yarn", + title: "Yarn", + ring: "trial", + quadrant: "tools", + body: "

Yarn is a dependency management tool for frontend (node) projects similar to npm. It also uses the npm registry and \ninfrastructure. According to Yarn, the benefits are that Yarn is much faster, automatically writes a .lock file and \nbuilds up a local cache to be even faster when installing packages again.

\n

At AOE, we started using Yarn in different projects to evaluate if we can switch to Yarn for all projects.

\n", + info: "", +}; diff --git a/src/components/ItemList/ItemList.tsx b/src/components/ItemList/ItemList.tsx index 1c3b653..2e8e8e4 100644 --- a/src/components/ItemList/ItemList.tsx +++ b/src/components/ItemList/ItemList.tsx @@ -33,14 +33,14 @@ const ItemList: React.FC = ({
{featuredItems.map((item, i) => ( - + // ))} {nonFeaturedItems.map((item, i) => ( =3.0.0 <4.0.0" @@ -10987,10 +11054,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^4.1.2: - version "4.3.3" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.3.tgz#5401db69bd3203daf1851a1a74d199cb3112c11a" - integrity sha512-rUvLW0WtF7PF2b9yenwWUi9Da9euvDRhmH7BLyBG4DCFfOJ850LGNknmRpp8Z8kXNUPObdZQEfKOiHtXuQHHKA== +typescript@4.3.5: + version "4.3.5" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" + integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== unbox-primitive@^1.0.1: version "1.0.1" @@ -11254,10 +11321,10 @@ w3c-xmlserializer@^2.0.0: dependencies: xml-name-validator "^3.0.0" -walk@^2.3.14: - version "2.3.14" - resolved "https://registry.yarnpkg.com/walk/-/walk-2.3.14.tgz#60ec8631cfd23276ae1e7363ce11d626452e1ef3" - integrity sha512-5skcWAUmySj6hkBdH6B6+3ddMjVQYH5Qy9QGbPmN8kVmLteXk+yVXg+yfk1nbX30EYakahLrr8iPcCxJQSCBeg== +walk@^2.3.15: + version "2.3.15" + resolved "https://registry.yarnpkg.com/walk/-/walk-2.3.15.tgz#1b4611e959d656426bc521e2da5db3acecae2424" + integrity sha512-4eRTBZljBfIISK1Vnt69Gvr2w/wc3U6Vtrw7qiN5iqYJPH7LElcYh/iU4XWhdCy2dZqv1ToMyYlybDylfG/5Vg== dependencies: foreachasync "^3.0.0"