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

[WIP] Fix biome linter errors #33

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: CI

on:
push:
branches: [ "**" ]
pull_request:
branches: [ "**" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm run ci-project
#- run: npm run build --if-present
- run: npm test
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
"editor.trimAutoWhitespace": false,
"files.eol": "\n",
"javascript.preferences.quoteStyle": "single",
"typescript.tsdk": "node_modules/typescript/lib", // Use the TypeScript SDK from the current project
}
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"scripts": {
"gen-package": "node package.json.js",
"install-project": "npm run gen-package && npm install --force",
"ci-project": "npm ci --force",
"node": "node --import=tsx",
"repl": "tsx",
"plop": "NODE_OPTIONS=\"--import tsx\" plop",
Expand All @@ -41,11 +42,11 @@
"build": "vite --config=./vite.config.ts --emptyOutDir build",
"storybook:serve": "storybook dev -p 6006",
"storybook:build": "storybook build --docs",
"check-types": "tsc --noEmit",
"check:types": "tsc --noEmit",
"lint:style": "stylelint 'src/**/*.scss'",
"lint:script": "biome",
"lint": "npm run list:style && npm run lint:script",
"test": "vitest run --root=.",
"lint:script": "biome lint",
"lint": "npm run lint:style && npm run lint:script",
"test": "npm run check:types && npm run lint:style",
"test-ui": "vitest --ui",
"coverage": "vitest run --coverage",
"start": "npm run storybook:serve",
Expand All @@ -61,6 +62,7 @@
"vite-plugin-lib-inject-css": "^2.1.1",
"vite-plugin-svg-icons": "^2.0.1",
"typescript": "^5.6.3",
"@types/node": "^22.9.0",
"stylelint": "^16.10.0",
"stylelint-config-standard-scss": "^13.1.0",
"@biomejs/biome": "^1.9.4",
Expand Down
12 changes: 8 additions & 4 deletions package.json.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const packageConfig = {
scripts: {
// Utilities
'gen-package': 'node package.json.js', // Update `package.json`
// Use --force currently since we're using React v19 rc. Once peer deps are updated remove this.
'install-project': 'npm run gen-package && npm install --force',
'ci-project': 'npm ci --force',

// CLI
'node': 'node --import=tsx',
Expand All @@ -59,14 +61,15 @@ const packageConfig = {
'storybook:build': 'storybook build --docs',

// Static analysis
'check-types': 'tsc --noEmit',
'check:types': 'tsc --noEmit',
'lint:style': `stylelint 'src/**/*.scss'`,
'lint:script': 'biome',
'lint': 'npm run list:style && npm run lint:script',
'lint:script': 'biome lint',
'lint': 'npm run lint:style && npm run lint:script',

// Test
// Note: use `vitest run --root=. src/...` to run a single test file
'test': 'vitest run --root=.', // Need to specify `--root=.` since the vite root is set to `./app`
//'test': 'vitest run --root=.', // Need to specify `--root=.` since the vite root is set to `./app`
'test': 'npm run check:types && npm run lint:style',
'test-ui': 'vitest --ui',
'coverage': 'vitest run --coverage',

Expand All @@ -93,6 +96,7 @@ const packageConfig = {

// Static analysis
'typescript': '^5.6.3',
'@types/node': '^22.9.0',
'stylelint': '^16.10.0',
'stylelint-config-standard-scss': '^13.1.0',
'@biomejs/biome': '^1.9.4',
Expand Down
4 changes: 2 additions & 2 deletions scripts/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const getServices = () => {

type ScriptArgs = {
values: {
help: boolean | undefined,
silent: boolean | undefined,
help?: undefined | boolean,
silent?: undefined | boolean,
},
positionals: Array<string>,
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/actions/Link/Link.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const Descenders: Story = {
export const Scroll: Story = {
render: (args) => (
<>
<a id="anchor"></a>
<a id="anchor" href="/" onClick={evt => { evt.preventDefault(); }}>Anchor</a>
<OverflowTester openDefault/>
<Link {...args} href="#anchor"/>
<OverflowTester openDefault/>
Expand Down
8 changes: 4 additions & 4 deletions src/components/containers/Alert/Alert.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ export default {

export const Standard: Story = {};

export const Info: Story = { args: { kind: 'info' } };
export const Warning: Story = { args: { kind: 'warning' } };
export const Error: Story = { args: { kind: 'error' } };
export const Success: Story = { args: { kind: 'success' } };
export const InfoAlert: Story = { args: { kind: 'info' } };
export const WarningAlert: Story = { args: { kind: 'warning' } };
export const ErrorAlert: Story = { args: { kind: 'error' } };
export const SuccessAlert: Story = { args: { kind: 'success' } };

/** Multiple alerts stacked. */
export const Stacked: Story = {
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/context/Form/Form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ type FormArgs = React.ComponentProps<typeof Form>;
type Story = StoryObj<FormArgs>;

const FormWithState = (props: React.ComponentProps<typeof Form>) => {
const action = async (previousState: unknown, formData: FormData) => {
const action = async (previousState: unknown, formData: FormData): Promise<null> => {
if (typeof props.action === 'function') {
return props.action?.(formData);
return props.action?.(formData) ?? null;
}
return null;
};
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/context/Form/FormOptics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export { cl as FormClassNames };

export type FormContext<T> = {
formId: string,
accessor: O.OpticFor<T>,
//accessor: O.OpticFor<T>,
};
export const FormContext = React.createContext<null | FormContext<unknown>>(null);
export const useFormContext = <T,>(): FormContext<T> => {
Expand All @@ -43,7 +43,7 @@ export const Form = (props: FormProps) => {
const [wrapperRef, setWrapperRef] = React.useState<null | React.ComponentRef<'div'>>(null);

// Memoize to keep a stable reference
const context: FormContext = React.useMemo(() => ({ formId }), [formId]);
const context: FormContext<unknown> = React.useMemo(() => ({ formId }), [formId]);

const renderForm = ({ children }: { children: React.ReactNode }) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/forms/context/SubmitButton/SubmitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ export const SubmitButton = (props: SubmitButtonProps) => {
const isDisabled = !isInteractive;
const isNonactive = propsButton.nonactive || isPending;

const handlePress = () => {
const handlePress = React.useCallback(() => {
if (typeof onPress !== 'function') { return; }

startPressTransition(async () => {
await Promise.race([onPress(), timeout(asyncTimeout)]);
});
};
}, [onPress, asyncTimeout]);

const handleClick = React.useCallback(async (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
// `onClick` should not be used in most cases, only if the consumer needs low level control over click events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export const SegmentedControl = (props: SegmentedControlProps) => {
[cl['bk-segmented-control--disabled']]: disabled,
}, propsRest.className)}
>
{formattedOptions.map((option, index) =>
{formattedOptions.map((option, index) =>
// biome-ignore lint/suspicious/noArrayIndexKey: no other unique identifier available
<li key={index} className={cl['bk-segmented-control__item']}>
<Button
role="tab"
Expand Down
2 changes: 1 addition & 1 deletion src/components/navigations/Stepper/Stepper.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

&.bk-stepper--vertical {
.bk-stepper__item {
&:not(:first-child):not(:first-child) {
&:not(:first-child) {
margin-top: bk.$spacing-9;

.bk-stepper__item__circle {
Expand Down
2 changes: 1 addition & 1 deletion src/components/navigations/Tabs/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type DefaultTabOption = {
className?: string,
};
const defaultTabOptions: DefaultTabOption[] = [1,2,3,4].map(index => {
return { index }
return { index };
});

type TabWithTriggerProps = React.PropsWithChildren<Partial<TabsArgs>> & {
Expand Down
1 change: 0 additions & 1 deletion src/components/overlays/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ const Modal = ({
};

return (
// biome-ignore lint/a11y/useKeyWithClickEvents: <explanation>
<dialog
ref={dialogRef}
className={cx(
Expand Down
3 changes: 1 addition & 2 deletions src/components/overlays/Toast/Toast.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

@layer baklava.components {
.bk-toast {
width: auto !important; // Override style for .Toastify__toast-container
padding: 0 !important; // Override style for .Toastify__toast-container
width: 400px !important; // Override style for .Toastify__toast-container

&:has(.bk-close--dark) {
.bk-toast__body {
margin-right: bk.$spacing-4 !important; // Override style for .Toastify__toast-body
Expand Down
6 changes: 3 additions & 3 deletions src/components/overlays/Toast/Toast.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Actions = () => {
);
};

export const Success: Story = {
export const SuccessToast: Story = {
args: {
options: {},
},
Expand All @@ -60,7 +60,7 @@ export const Success: Story = {
),
};

export const Info: Story = {
export const InfoToast: Story = {
args: {
options: {},
},
Expand All @@ -71,7 +71,7 @@ export const Info: Story = {
),
};

export const Error: Story = {
export const ErrorToast: Story = {
args: {
options: {},
},
Expand Down
2 changes: 2 additions & 0 deletions src/components/overlays/Toast/ToastyOverride.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
|* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
|* the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. */

/* stylelint-disable selector-class-pattern */

@use '../../../styling/defs.scss' as bk;

// Define styling to override react-toastify's styles, as overriding directly from Toast.module.scss is not possible.
Expand Down
18 changes: 9 additions & 9 deletions src/components/overlays/Tooltip/Tooltip.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
background: var(--c1);

&::before {
content: "";
content: '';
position: absolute;
z-index: -1;
inset: 0;
Expand Down Expand Up @@ -72,16 +72,16 @@
100% min(100%,var(--p) + var(--h)*tan(var(--a)/2)),
calc(100% + var(--h)) var(--p),
100% max(0% ,var(--p) - var(--h)*tan(var(--a)/2)));
border-image: conic-gradient(var(--c1) 0 0) fill 0/
max(0%,var(--p) - var(--h)*tan(var(--a)/2)) 0 max(0%,100% - var(--p) - var(--h)*tan(var(--a)/2)) var(--r)/0 var(--h) 0 0;
border-image: conic-gradient(var(--c1) 0 0) fill 0
/ max(0%,var(--p) - var(--h)*tan(var(--a)/2)) 0 max(0%,100% - var(--p) - var(--h)*tan(var(--a)/2)) var(--r)/0 var(--h) 0 0;

&::before {
clip-path: polygon(100% 0,0 0,0 100%,100% 100%,
calc(100% - var(--b)) min(100% - var(--b),var(--p) + var(--h)*tan(var(--a)/2) - var(--b)*tan(45deg - var(--a)/4)),
calc(100% + var(--h) - var(--b)/sin(var(--a)/2)) var(--p),
calc(100% - var(--b)) max( var(--b),var(--p) - var(--h)*tan(var(--a)/2) + var(--b)*tan(45deg - var(--a)/4)));
border-image: conic-gradient(var(--c2) 0 0) fill 0/
max(var(--b),var(--p) - var(--h)*tan(var(--a)/2)) 0 max(var(--b),100% - var(--p) - var(--h)*tan(var(--a)/2)) var(--r)/0 var(--h) 0 0;
border-image: conic-gradient(var(--c2) 0 0) fill 0
/ max(var(--b),var(--p) - var(--h)*tan(var(--a)/2)) 0 max(var(--b),100% - var(--p) - var(--h)*tan(var(--a)/2)) var(--r)/0 var(--h) 0 0;
}
}
@mixin bk-tooltip-arrow-bottom {
Expand All @@ -108,16 +108,16 @@
0 min(100%,var(--p) + var(--h)*tan(var(--a)/2)),
calc(-1*var(--h)) var(--p),
0 max(0% ,var(--p) - var(--h)*tan(var(--a)/2)));
border-image: conic-gradient(var(--c1) 0 0) fill 0/
max(0%,var(--p) - var(--h)*tan(var(--a)/2)) var(--r) max(0%,100% - var(--p) - var(--h)*tan(var(--a)/2)) 0/0 0 0 var(--h);
border-image: conic-gradient(var(--c1) 0 0) fill 0
/ max(0%,var(--p) - var(--h)*tan(var(--a)/2)) var(--r) max(0%,100% - var(--p) - var(--h)*tan(var(--a)/2)) 0/0 0 0 var(--h);

&::before {
clip-path: polygon(0 0,100% 0,100% 100%,0 100%,
var(--b) min(100% - var(--b),var(--p) + var(--h)*tan(var(--a)/2) - var(--b)*tan(45deg - var(--a)/4)),
calc(var(--b)/sin(var(--a)/2) - var(--h)) var(--p),
var(--b) max( var(--b),var(--p) - var(--h)*tan(var(--a)/2) + var(--b)*tan(45deg - var(--a)/4)));
border-image: conic-gradient(var(--c2) 0 0) fill 0/
max(var(--b),var(--p) - var(--h)*tan(var(--a)/2)) var(--r) max(var(--b),100% - var(--p) - var(--h)*tan(var(--a)/2)) 0/0 0 0 var(--h);
border-image: conic-gradient(var(--c2) 0 0) fill 0
/ max(var(--b),var(--p) - var(--h)*tan(var(--a)/2)) var(--r) max(var(--b),100% - var(--p) - var(--h)*tan(var(--a)/2)) 0/0 0 0 var(--h);
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/layouts/AppLayout/Sidebar/Sidebar.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@
transition: all 300ms ease-in-out;
transition-property: width, grid-template-columns;

&.-collapsed {
width: var(--bk-sizing-5);
}

.bk-app-layout-sidebar__action-collapse {
margin: var(--bk-sizing-2);
padding: var(--bk-sizing-1) var(--bk-sizing-2);
Expand Down
3 changes: 3 additions & 0 deletions src/util/storybook/OverflowTester.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type OverflowTesterProps = {
};
export const OverflowTester = ({ lines = 50, openDefault = false }: OverflowTesterProps) => {
const ref = React.useRef<HTMLDetailsElement>(null);

// biome-ignore lint/correctness/useExhaustiveDependencies: `openDefault` only applies on mount
React.useEffect(() => {
if (openDefault && ref.current) {
ref.current.open = true;
Expand All @@ -23,6 +25,7 @@ export const OverflowTester = ({ lines = 50, openDefault = false }: OverflowTest
<details ref={ref} className="util-overflow-tester">
<summary>Test overflow</summary>
{Array.from({ length: lines }).map((_, index) =>
// biome-ignore lint/suspicious/noArrayIndexKey: no other unique identifier available
<p key={index}>...</p>
)}
</details>
Expand Down
2 changes: 1 addition & 1 deletion stylelint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
'rules': {
// Override `stylelint-config-standard-scss` rules
'scss/load-partial-extension': 'always',
'scss/at-import-partial-extension': 'always',
//'scss/at-import-partial-extension': 'always',
'comment-empty-line-before': null,
'comment-whitespace-inside': null,
'scss/comment-no-empty': null,
Expand Down
Loading