Skip to content

Commit

Permalink
Replace ESLint and Prettier with Biome
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmaj committed Jun 5, 2024
1 parent 16afaf8 commit b715b67
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 1,461 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn lint-staged
yarn format --staged --no-errors-on-unmatched --write
3 changes: 0 additions & 3 deletions .lintstagedrc.json

This file was deleted.

3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

4 changes: 0 additions & 4 deletions .prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"recommendations": ["dbaeumer.vscode-eslint", "eamodio.gitlens", "esbenp.prettier-vscode"],
"recommendations": ["biomejs.biome", "eamodio.gitlens"],
"unwantedRecommendations": ["dbaeumer.jshint"]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.defaultFormatter": "biomejs.biome",
"editor.formatOnSave": true,
"search.exclude": {
"**/.yarn": true
Expand Down
43 changes: 43 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.0/schema.json",
"files": {
"ignore": [".tsimp", "coverage", "dist", ".pnp.cjs", ".pnp.loader.mjs"]
},
"formatter": {
"lineWidth": 100,
"indentStyle": "space"
},
"linter": {
"rules": {
"complexity": {
"noUselessSwitchCase": "off"
},
"suspicious": {
"noConsoleLog": "warn"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"overrides": [
{
"include": ["**/package.json"],
"formatter": {
"lineWidth": 1
}
},
{
"include": ["**/vite.config.ts"],
"linter": {
"rules": {
"suspicious": {
"noConsoleLog": "off"
}
}
}
}
]
}
7 changes: 1 addition & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@
"unit": "yarn workspaces foreach --all run unit"
},
"devDependencies": {
"husky": "^9.0.0",
"lint-staged": "^15.0.0",
"prettier": "^3.2.0"
},
"resolutions": {
"eslint-plugin-import": "npm:eslint-plugin-i@^2.28.0"
"husky": "^9.0.0"
},
"packageManager": "[email protected]"
}
2 changes: 0 additions & 2 deletions packages/react-calendar/.eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions packages/react-calendar/.eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/react-calendar/.prettierignore

This file was deleted.

8 changes: 3 additions & 5 deletions packages/react-calendar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"build-js-cjs-package": "echo '{\n \"type\": \"commonjs\"\n}' > dist/cjs/package.json",
"clean": "rimraf dist",
"copy-styles": "cpy 'src/**/*.css' dist",
"format": "prettier --check . --cache",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"format": "biome format",
"lint": "biome lint",
"prepack": "yarn clean && yarn build",
"test": "yarn lint && yarn tsc && yarn format && yarn unit",
"tsc": "tsc",
Expand All @@ -52,17 +52,15 @@
"warning": "^4.0.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^15.0.0",
"@types/node": "*",
"@types/react": "*",
"@types/warning": "^3.0.0",
"cpy-cli": "^5.0.0",
"eslint": "^8.56.0",
"eslint-config-wojtekmaj": "^1.0.0",
"happy-dom": "^12.6.0",
"nodemon": "^3.0.0",
"prettier": "^3.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-calendar/src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ function getValue(value: LooseValue | undefined, index: 0 | 1): Date | null {

const valueDate = toDate(rawValue);

if (isNaN(valueDate.getTime())) {
if (Number.isNaN(valueDate.getTime())) {
throw new Error(`Invalid date: ${value}`);
}

Expand Down
10 changes: 6 additions & 4 deletions packages/react-calendar/src/Flex.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ describe('Flex', () => {
const wrapper = container.firstElementChild as HTMLDivElement;
const children = Array.from(wrapper.children);

children.forEach((child) => expect(child).toHaveStyle('flex-basis: 33.333333333333336%'));
expect(children[0]).toHaveStyle('margin-left: 33.333333333333336%');
expect(children[0]).toHaveStyle('margin-inline-start: 33.333333333333336%');
expect(children[0]).toHaveStyle('margin-inline-end: 0');
for (const child of children) {
expect(child).toHaveStyle('flex-basis: 33.333333333333336%');
expect(child).toHaveStyle('flex-shrink: 0');
expect(child).toHaveStyle('flex-grow: 0');
expect(child).toHaveStyle('overflow: hidden');
}
});
});
2 changes: 1 addition & 1 deletion packages/react-calendar/src/Flex.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Children, cloneElement } from 'react';

type FlexProps = React.HTMLAttributes<HTMLDivElement> & {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// biome-ignore lint/suspicious/noExplicitAny: Too complex to type
children: React.ReactElement<any>[];
className?: string;
count: number;
Expand Down
2 changes: 0 additions & 2 deletions test/.eslintignore

This file was deleted.

3 changes: 0 additions & 3 deletions test/.eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion test/.prettierignore

This file was deleted.

7 changes: 5 additions & 2 deletions test/Test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ const tileContent = ({ date, view }: { date: Date; view: View }) => {
const nineteenNinetyFive = new Date(1995, now.getUTCMonth() + 1, 15, 12);
const fifteenthOfNextMonth = new Date(now.getUTCFullYear(), now.getUTCMonth() + 1, 15, 12);

/* eslint-disable no-console */

type ReturnValue = 'start' | 'end' | 'range';

export default function Test() {
Expand Down Expand Up @@ -98,6 +96,7 @@ export default function Test() {
activeStartDate: Date | null;
view: View;
}) => {
// biome-ignore lint/suspicious/noConsoleLog: This is a test page
console.log('Changed view to', nextView, nextActiveStartDate);
setActiveStartDate(nextActiveStartDate || undefined);
setView(nextView);
Expand Down Expand Up @@ -130,6 +129,7 @@ export default function Test() {
onActiveStartDateChange: onViewOrDateChange,
onChange: (value: Value) => setValue(value),
onClickWeekNumber: (weekNumber: number, date: Date) => {
// biome-ignore lint/suspicious/noConsoleLog: This is a test page
console.log('Clicked week number', weekNumber, date);
},
onDrillDown: ({
Expand All @@ -139,6 +139,7 @@ export default function Test() {
activeStartDate: Date | null;
view: View;
}) => {
// biome-ignore lint/suspicious/noConsoleLog: This is a test page
console.log('Drilled down to', nextView, nextActiveStartDate);
},
onDrillUp: ({
Expand All @@ -148,6 +149,7 @@ export default function Test() {
activeStartDate: Date | null;
view: View;
}) => {
// biome-ignore lint/suspicious/noConsoleLog: This is a test page
console.log('Drilled up to', nextView, nextActiveStartDate);
},
onViewChange: onViewOrDateChange,
Expand Down Expand Up @@ -213,6 +215,7 @@ export default function Test() {
onSubmit={(event) => {
event.preventDefault();
console.error('Calendar triggered submitting the form.');
// biome-ignore lint/suspicious/noConsoleLog: This is a test page
console.log(event);
}}
>
Expand Down
8 changes: 3 additions & 5 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"scripts": {
"build": "vite build",
"dev": "vite",
"format": "prettier --check . --cache",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"format": "biome format",
"lint": "biome lint",
"preview": "vite preview",
"test": "yarn lint && yarn tsc && yarn format",
"tsc": "tsc"
Expand All @@ -26,11 +26,9 @@
"react-dom": "^18.2.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@types/react": "*",
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.56.0",
"eslint-config-wojtekmaj": "^1.0.0",
"prettier": "^3.2.0",
"typescript": "^5.4.2",
"vite": "^5.0.0"
}
Expand Down
Loading

0 comments on commit b715b67

Please sign in to comment.