Skip to content

Commit f588549

Browse files
iqbalhasandevgithub-actions[bot]
authored andcommitted
style: fix code formatting [skip ci]
1 parent 019c5ba commit f588549

File tree

8 files changed

+74
-36
lines changed

8 files changed

+74
-36
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,27 @@ All notable changes to `@devwizard/laravel-localizer-react` will be documented i
3434
- Automatic page props detection
3535

3636
### 📚 Documentation
37+
3738
- Comprehensive README with usage examples
3839
- API documentation with TypeScript interfaces
3940
- Migration guide from v1 to v2
4041

4142
### 🧪 Testing
43+
4244
- Jest configuration
4345
- Comprehensive test suite with 100% coverage
4446
- Testing Library for React components
4547
- ESM module support
4648

4749
### 🛠️ Development Tools
50+
4851
- ESLint configuration with TypeScript and React rules
4952
- Prettier for code formatting
5053
- tsup for building and bundling
5154
- GitHub Actions for CI/CD
5255

5356
### 📦 Package Configuration
57+
5458
- ESM-only distribution
5559
- Tree-shakeable exports
5660
- Proper package.json exports field

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ yarn add @devwizard/laravel-localizer-react
2323
```
2424

2525
**Backend (Composer):**
26+
2627
```bash
2728
composer require devwizardhq/laravel-localizer
2829
php artisan localizer:install --framework=react
@@ -143,18 +144,18 @@ function ConditionalMessage() {
143144

144145
Returns an object with the following properties and methods:
145146

146-
| Property | Type | Description |
147-
|----------|------|-------------|
148-
| `__` | `(key, replacements?, fallback?) => string` | Main translation function |
149-
| `trans` | `(key, replacements?, fallback?) => string` | Alias for `__` |
150-
| `lang` | `(key, replacements?, fallback?) => string` | Alias for `__` |
151-
| `has` | `(key) => boolean` | Check if translation key exists |
152-
| `choice` | `(key, count, replacements?) => string` | Pluralization support |
153-
| `locale` | `string` | Current locale code |
154-
| `dir` | `'ltr' \| 'rtl'` | Text direction |
155-
| `availableLocales` | `Record<string, LocaleInfo>` | Available locales with metadata |
156-
| `translations` | `Record<string, string>` | All translations for current locale |
157-
| `getLocales` | `() => string[]` | Get all available locale codes |
147+
| Property | Type | Description |
148+
| ------------------ | ------------------------------------------- | ----------------------------------- |
149+
| `__` | `(key, replacements?, fallback?) => string` | Main translation function |
150+
| `trans` | `(key, replacements?, fallback?) => string` | Alias for `__` |
151+
| `lang` | `(key, replacements?, fallback?) => string` | Alias for `__` |
152+
| `has` | `(key) => boolean` | Check if translation key exists |
153+
| `choice` | `(key, count, replacements?) => string` | Pluralization support |
154+
| `locale` | `string` | Current locale code |
155+
| `dir` | `'ltr' \| 'rtl'` | Text direction |
156+
| `availableLocales` | `Record<string, LocaleInfo>` | Available locales with metadata |
157+
| `translations` | `Record<string, string>` | All translations for current locale |
158+
| `getLocales` | `() => string[]` | Get all available locale codes |
158159

159160
## Vite Plugin Options
160161

@@ -203,8 +204,8 @@ The package is fully typed. Generated translation files include TypeScript defin
203204
```typescript
204205
// Generated by localizer:generate
205206
export const en = {
206-
"welcome": "Welcome",
207-
"validation.required": "This field is required",
207+
welcome: 'Welcome',
208+
'validation.required': 'This field is required',
208209
} as const;
209210

210211
export type TranslationKeys = keyof typeof en;

__tests__/useTranslation.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ describe('useTranslation', () => {
144144

145145
const { result } = renderHook(() => useTranslation());
146146

147-
expect(result.current.choice('user.items', 3, { name: 'Alice' })).toBe(
148-
'Alice has 3 items'
149-
);
147+
expect(result.current.choice('user.items', 3, { name: 'Alice' })).toBe('Alice has 3 items');
150148
});
151149
});
152150

__tests__/vite-plugin.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('laravelLocalizer Vite Plugin', () => {
4343

4444
it('should set up file watchers', () => {
4545
const plugin = laravelLocalizer();
46-
46+
4747
const mockWatcher = {
4848
on: jest.fn(),
4949
};

eslint.config.min.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,28 @@
1-
import js from"@eslint/js";import tseslint from"typescript-eslint";import reactPlugin from"eslint-plugin-react";import reactHooksPlugin from"eslint-plugin-react-hooks";export default tseslint.config(js.configs.recommended,...tseslint.configs.recommended,{files:["**/*.ts","**/*.tsx"],plugins:{react:reactPlugin,"react-hooks":reactHooksPlugin},rules:{"@typescript-eslint/no-explicit-any":"warn","@typescript-eslint/no-unused-vars":["error",{argsIgnorePattern:"^_",varsIgnorePattern:"^_"}],"react-hooks/rules-of-hooks":"error","react-hooks/exhaustive-deps":"warn"}},{files:["**/__tests__/**","*.config.*","*.cjs"],rules:{"@typescript-eslint/no-explicit-any":"off"}},{ignores:["dist/**","node_modules/**","coverage/**","*.cjs","*.min.js","eslint.config.js"]});
1+
import js from '@eslint/js';
2+
import tseslint from 'typescript-eslint';
3+
import reactPlugin from 'eslint-plugin-react';
4+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
5+
export default tseslint.config(
6+
js.configs.recommended,
7+
...tseslint.configs.recommended,
8+
{
9+
files: ['**/*.ts', '**/*.tsx'],
10+
plugins: { react: reactPlugin, 'react-hooks': reactHooksPlugin },
11+
rules: {
12+
'@typescript-eslint/no-explicit-any': 'warn',
13+
'@typescript-eslint/no-unused-vars': [
14+
'error',
15+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
16+
],
17+
'react-hooks/rules-of-hooks': 'error',
18+
'react-hooks/exhaustive-deps': 'warn',
19+
},
20+
},
21+
{
22+
files: ['**/__tests__/**', '*.config.*', '*.cjs'],
23+
rules: { '@typescript-eslint/no-explicit-any': 'off' },
24+
},
25+
{
26+
ignores: ['dist/**', 'node_modules/**', 'coverage/**', '*.cjs', '*.min.js', 'eslint.config.js'],
27+
}
28+
);

hooks/useTranslation.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,8 @@ export function useTranslation(): UseTranslationReturn {
156156
const { props } = usePage<PageProps>();
157157
const locale = props.locale?.current || 'en';
158158
const dir = props.locale?.dir || 'ltr';
159-
160-
const availableLocales = useMemo(
161-
() => props.locale?.available || {},
162-
[props.locale?.available]
163-
);
159+
160+
const availableLocales = useMemo(() => props.locale?.available || {}, [props.locale?.available]);
164161

165162
// Dynamically import translations from generated files
166163
// Note: Users need to set up path alias '@/lang' -> 'resources/js/lang'

jest.config.min.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
1-
module.exports={preset:"ts-jest",testEnvironment:"jsdom",roots:["<rootDir>"],testMatch:["**/__tests__/**/*.test.ts","**/__tests__/**/*.test.tsx"],moduleNameMapper:{"^@/(.*)$":"<rootDir>/$1"},setupFilesAfterEnv:["<rootDir>/__tests__/setup.ts"],collectCoverageFrom:["hooks/**/*.ts","vite-plugin.ts","index.ts","!**/*.d.ts","!**/__tests__/**","!**/node_modules/**","!**/dist/**"],coverageThreshold:{global:{branches:80,functions:80,lines:80,statements:80}},transform:{"^.+\\.tsx?$":["ts-jest",{tsconfig:{jsx:"react-jsx",esModuleInterop:!0}}]}};
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
4+
roots: ['<rootDir>'],
5+
testMatch: ['**/__tests__/**/*.test.ts', '**/__tests__/**/*.test.tsx'],
6+
moduleNameMapper: { '^@/(.*)$': '<rootDir>/$1' },
7+
setupFilesAfterEnv: ['<rootDir>/__tests__/setup.ts'],
8+
collectCoverageFrom: [
9+
'hooks/**/*.ts',
10+
'vite-plugin.ts',
11+
'index.ts',
12+
'!**/*.d.ts',
13+
'!**/__tests__/**',
14+
'!**/node_modules/**',
15+
'!**/dist/**',
16+
],
17+
coverageThreshold: { global: { branches: 80, functions: 80, lines: 80, statements: 80 } },
18+
transform: {
19+
'^.+\\.tsx?$': ['ts-jest', { tsconfig: { jsx: 'react-jsx', esModuleInterop: !0 } }],
20+
},
21+
};

tsconfig.json

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@
3737
"noUncheckedIndexedAccess": true,
3838
"skipLibCheck": true
3939
},
40-
"include": [
41-
"**/*.ts",
42-
"**/*.tsx"
43-
],
44-
"exclude": [
45-
"node_modules",
46-
"dist",
47-
"__tests__",
48-
"**/*.test.ts",
49-
"**/*.test.tsx"
50-
]
40+
"include": ["**/*.ts", "**/*.tsx"],
41+
"exclude": ["node_modules", "dist", "__tests__", "**/*.test.ts", "**/*.test.tsx"]
5142
}

0 commit comments

Comments
 (0)