Skip to content

Commit

Permalink
ci: 👷 Add type checks to PR checks
Browse files Browse the repository at this point in the history
A simple way to type checking all our projects
  • Loading branch information
mimarz committed Dec 12, 2024
1 parent d0df6c1 commit a73bf41
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ on:
- 'biome.jsonc'
jobs:
checks:
name: Lint
name: Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/gh-setup
- name: Lint code
- name: Types
run: yarn types
- name: Biome CI
run: yarn biome ci .
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
pull-requests: write

jobs:
checks:
test:
name: Build & test
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 4 additions & 0 deletions apps/_components/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.css' {
const styles: { [className: string]: string };
export default styles;
}
1 change: 1 addition & 0 deletions apps/_components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@navikt/aksel-icons": "^6.14.0",
"@types/react-syntax-highlighter": "^15.5.13",
"clsx": "^2.1.1",
"next": "^14.2.5",
"prettier": "^3.3.3",
"react-syntax-highlighter": "^15.5.0"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/_components/src/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const Header = ({
onClick={() => setOpen(false)}
prefetch={false}
className={cl(
pathname.includes(item.href) && classes.active,
pathname?.includes(item.href) && classes.active,
classes.link,
'ds-focus',
)}
Expand Down
19 changes: 16 additions & 3 deletions apps/_components/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"rootDir": "./src",
"compilerOptions": {
"outDir": "./tsc-build",
"declarationDir": "./dist/types",
Expand All @@ -9,8 +10,20 @@
"noEmit": false,
"incremental": true,
"moduleResolution": "Bundler",
"types": ["@digdir/designsystemet-theme/colors.d.ts"]
"types": [
"@digdir/designsystemet-theme/colors.d.ts",
"./declarations.d.ts",
"./next-env.d.ts"
],
},
"include": ["./src", "./stories", "declarations.d.ts"],
"rootDir": "./src"
"include": [
"./src",
"./stories",
"declarations.d.ts"
],
"plugins": [
{
"name": "next"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cl from 'clsx/lite';
import { useRef } from 'react';
import type { TransformedToken } from 'style-dictionary';

import type { ColorNumber } from '../../../../../packages/cli/src/colors/types';
import type { ColorNumber } from '@digdir/designsystemet/color';

import classes from './TokenColor.module.css';
interface TokenColorProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/layouts/MenuPageLayout/MenuPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const MenuPageLayout = ({ content, data, banner }: PageLayoutProps) => {
)}
<Container className={classes.page}>
<div className={classes.left}>
<SidebarMenu routerPath={pathname} />
<SidebarMenu routerPath={pathname ?? ''} />
</div>
<main id='main' className={classes.right}>
{data && (
Expand Down
38 changes: 28 additions & 10 deletions apps/storefront/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@components": ["components"],
"@layouts": ["layouts"],
"@blog": ["app/bloggen/_components"]
"@components": [
"components"
],
"@layouts": [
"layouts"
],
"@blog": [
"app/bloggen/_components"
]
},
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -19,16 +30,23 @@
"jsx": "preserve",
"incremental": true,
"forceConsistentCasingInFileNames": true,
"types": ["@digdir/designsystemet-theme/colors.d.ts"],
"types": [
"@digdir/designsystemet-theme/colors.d.ts",
],
"plugins": [
{
"name": "typescript-plugin-css-modules"
},
{
"name": "next"
}
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.css",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
3 changes: 2 additions & 1 deletion apps/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"types": "tsc --noEmit"
},
"dependencies": {
"@digdir/designsystemet": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"build:storybook": "yarn workspace @designsystemet/storybook build",
"build:storefront": "yarn workspace storefront build",
"start:storefront": "yarn workspace storefront start",
"types": "yarn workspaces foreach -Ap --topological-dev --no-private run types",
"types": "yarn workspaces foreach -Ap --topological-dev run types",
"types:react": "yarn workspace @digdir/designsystemet-react types",
"types:storefront": "yarn workspace storefront types",
"version-packages": "changeset version",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"build:tokens:debug": "yarn clean:theme && tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand",
"build": "tsup && yarn build:types",
"build:types": "tsc --emitDeclarationOnly --declaration",
"types": "tsc --noEmit",
"test:tokens-create": "yarn designsystemet tokens create -m dominant:#007682 secondary:#ff0000 -n #003333 -s support1:#12404f support2:#0054a6 support3:#942977 -o ./test-tokens-create",
"test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build",
"test:tokens-create-and-build": "rimraf test-tokens-create && rimraf test-tokens-build && yarn test:tokens-create && yarn test:tokens-build",
Expand Down
12 changes: 12 additions & 0 deletions packages/cli/src/colors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,15 @@ export const convertToHex = (color?: string): CssColor => {
}
return chroma(color).hex() as CssColor;
};

export const rgbToHex = (rgb: { r: number; g: number; b: number }) => {
return (
'#' +
[rgb.r, rgb.g, rgb.b]
.map((x) => {
const hex = Math.round(x * 255).toString(16);
return hex.length === 1 ? '0' + hex : hex;
})
.join('')
);
};
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build": "yarn run clean && tsc -b tsconfig.lib.json --emitDeclarationOnly false && rollup -c --bundleConfigAsCjs",
"clean": "rimraf dist && rimraf tsc-build && rimraf --glob \"*.tsbuildinfo\"",
"copy-css-to-build": "copyfiles -u 1 ./src/**/*.css ./tsc-build/",
"types": "tsc -b"
"types": "tsc --noEmit"
},
"peerDependencies": {
"react": ">=18.3.1",
Expand Down
1 change: 1 addition & 0 deletions plugins/figma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "npm run build:plugin && npm run build:ui",
"build:ui": "vite build -c ./vite.config.ui.ts",
"build:plugin": "vite build -c ./vite.config.plugin.ts",
"types": "tsc --noEmit",
"types:src": "tsc",
"types:node": "tsc -P tsconfig.node.json"
},
Expand Down
3 changes: 1 addition & 2 deletions plugins/figma/src/ui/pages/Theme/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ import {
import { useEffect, useId, useState } from 'react';
import { Link as RouterLink, useParams } from 'react-router-dom';

import type { CssColor } from '@adobe/leonardo-contrast-colors';
import { getDummyTheme } from '@common/dummyTheme';
import { colorCliOptions } from '@digdir/designsystemet';
import { generateThemeForColor } from '@digdir/designsystemet/color';
import { type CssColor, generateThemeForColor } from '@digdir/designsystemet/color';
import { type ColorTheme, useThemeStore } from '../../../common/store';
import { themeToFigmaFormat } from '../../../common/utils';
import classes from './Theme.module.css';
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3231,6 +3231,7 @@ __metadata:
"@navikt/aksel-icons": "npm:^6.14.0"
"@types/react-syntax-highlighter": "npm:^15.5.13"
clsx: "npm:^2.1.1"
next: "npm:^14.2.5"
prettier: "npm:^3.3.3"
react-syntax-highlighter: "npm:^15.5.0"
typescript: "npm:^5.5.4"
Expand Down

0 comments on commit a73bf41

Please sign in to comment.