Skip to content

Commit 22326f1

Browse files
committed
chore(lint): resolve Biome lint errors and apply auto-fix formatting
Suppress `useNullishCoalescing` on the intentional `||` fallback for empty string and `useNamingConvention` on the `__OPTIONAL_CATCH_ALL__*` keys which are part of the library's public API contract. Also includes `biome check --write` auto-fix for import ordering and formatting.
1 parent a5a639a commit 22326f1

5 files changed

Lines changed: 39 additions & 33 deletions

File tree

.vscode/tasks.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
// See https://go.microsoft.com/fwlink/?LinkId=733558
33
// for the documentation about the tasks.json format
44
"version": "2.0.0",
5-
"tasks": [{
6-
"label": "Project wide type checking with TypeScript",
7-
"type": "npm",
8-
"script": "type-check",
9-
"problemMatcher": ["$tsc"],
10-
"group": {
11-
"kind": "build",
12-
"isDefault": true
13-
},
14-
"presentation": {
15-
"clear": true,
16-
"reveal": "never"
5+
"tasks": [
6+
{
7+
"label": "Project wide type checking with TypeScript",
8+
"type": "npm",
9+
"script": "type-check",
10+
"problemMatcher": ["$tsc"],
11+
"group": {
12+
"kind": "build",
13+
"isDefault": true
14+
},
15+
"presentation": {
16+
"clear": true,
17+
"reveal": "never"
18+
}
1719
}
18-
}]
20+
]
1921
}

eslint.config.mjs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,28 @@
22
/* eslint-disable no-underscore-dangle */
33
/* eslint-disable import/no-anonymous-default-export */
44

5+
import { FlatCompat } from '@eslint/eslintrc';
56
// ESLint core and compatibility utilities
67
import js from '@eslint/js';
7-
import { FlatCompat } from '@eslint/eslintrc';
8-
// import { fixupPluginRules } from '@eslint/compat';
9-
import globals from 'globals';
10-
11-
// ESLint plugins for various technologies and best practices
12-
import react from 'eslint-plugin-react';
13-
import reactHooks from 'eslint-plugin-react-hooks';
14-
import jsxA11Y from 'eslint-plugin-jsx-a11y';
8+
// import nextPlugin from '@next/eslint-plugin-next';
9+
import pluginQuery from '@tanstack/eslint-plugin-query';
1510
import typescriptEslint from '@typescript-eslint/eslint-plugin';
16-
// import tseslint from 'typescript-eslint';
17-
import unusedImports from 'eslint-plugin-unused-imports';
18-
import tailwindcss from 'eslint-plugin-tailwindcss';
19-
import tsdoc from 'eslint-plugin-tsdoc';
11+
import vitest from '@vitest/eslint-plugin';
12+
import deprecation from 'eslint-plugin-deprecation';
2013
import _import from 'eslint-plugin-import';
14+
import jsxA11Y from 'eslint-plugin-jsx-a11y';
2115
import prettier from 'eslint-plugin-prettier';
2216
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
17+
// ESLint plugins for various technologies and best practices
18+
import react from 'eslint-plugin-react';
19+
import reactHooks from 'eslint-plugin-react-hooks';
20+
import tailwindcss from 'eslint-plugin-tailwindcss';
2321
import testingLibrary from 'eslint-plugin-testing-library';
24-
import vitest from '@vitest/eslint-plugin';
25-
import deprecation from 'eslint-plugin-deprecation';
26-
// import nextPlugin from '@next/eslint-plugin-next';
27-
import pluginQuery from '@tanstack/eslint-plugin-query';
22+
import tsdoc from 'eslint-plugin-tsdoc';
23+
// import tseslint from 'typescript-eslint';
24+
import unusedImports from 'eslint-plugin-unused-imports';
25+
// import { fixupPluginRules } from '@eslint/compat';
26+
import globals from 'globals';
2827

2928
const compat = new FlatCompat({
3029
baseDirectory: import.meta.dirname, // Added in: v21.2.0, v20.11.0 @ https://nodejs.org/api/esm.html#importmetadirname

src/__tests__/index.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { renderHook } from '@testing-library/react';
2-
import { usePathname, useParams } from 'next/navigation';
3-
import { describe, expect, vi, beforeEach } from 'vitest';
2+
import { useParams, usePathname } from 'next/navigation';
3+
import { beforeEach, describe, expect, vi } from 'vitest';
44

55
import usePlaceholderPath from '../index';
66

@@ -103,6 +103,7 @@ describe('usePlaceholderPath', () => {
103103
test('should handle optional catch-all segments with one value', () => {
104104
vi.mocked(usePathname).mockReturnValue('/shop/category');
105105
vi.mocked(useParams).mockReturnValue({
106+
// biome-ignore lint/style/useNamingConvention: library internal prefix (see getPlaceholder in src/index.ts) is part of the public API contract for optional catch-all routes
106107
__OPTIONAL_CATCH_ALL__slug: ['category'],
107108
});
108109

@@ -113,6 +114,7 @@ describe('usePlaceholderPath', () => {
113114
test('should handle optional catch-all segments with two values', () => {
114115
vi.mocked(usePathname).mockReturnValue('/shop/category/product');
115116
vi.mocked(useParams).mockReturnValue({
117+
// biome-ignore lint/style/useNamingConvention: library internal prefix (see getPlaceholder in src/index.ts) is part of the public API contract for optional catch-all routes
116118
__OPTIONAL_CATCH_ALL__slug: ['category', 'product'],
117119
});
118120

@@ -123,6 +125,7 @@ describe('usePlaceholderPath', () => {
123125
test('should handle optional catch-all segments with three values', () => {
124126
vi.mocked(usePathname).mockReturnValue('/shop/category/product/variant');
125127
vi.mocked(useParams).mockReturnValue({
128+
// biome-ignore lint/style/useNamingConvention: library internal prefix (see getPlaceholder in src/index.ts) is part of the public API contract for optional catch-all routes
126129
__OPTIONAL_CATCH_ALL__slug: ['category', 'product', 'variant'],
127130
});
128131

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { usePathname, useParams } from 'next/navigation';
1+
import { useParams, usePathname } from 'next/navigation';
22

33
interface UsePlaceholderPathOptions {
44
optionalCatchAllSegments?: string;
@@ -80,7 +80,8 @@ const usePlaceholderPath = (options: UsePlaceholderPathOptions = {}) => {
8080

8181
// Handle top-level optional catch-all segments
8282
if (isTopLevelOptionalCatchAll) {
83-
const catchAllSegment = optionalCatchAllSegments || 'slug'; // Use 'slug' as default if empty string
83+
// biome-ignore lint/nursery/useNullishCoalescing: intentional `||` to treat empty string as missing and fall back to 'slug'
84+
const catchAllSegment = optionalCatchAllSegments || 'slug';
8485
return `/${segments[0]}/[[...${catchAllSegment}]]`;
8586
}
8687

vitest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable import/no-extraneous-dependencies */
22
import '@testing-library/jest-dom/vitest';
3+
34
import { cleanup } from '@testing-library/react';
45
import { afterEach } from 'vitest';
56
import 'intersection-observer';

0 commit comments

Comments
 (0)