mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-29 14:02:19 +00:00
* ran prettier * Refactor ESLint configuration to use ES module syntax and enhance TypeScript support - Converted CommonJS `require` statements to ES module `import` syntax for better compatibility with modern JavaScript. - Added new paths to ignore in ESLint configuration to exclude additional directories. - Updated TypeScript file patterns to be more specific, improving linting accuracy. - Adjusted React hooks rules to allow certain patterns, enhancing flexibility in component design. These changes improve the maintainability and clarity of the ESLint configuration, aligning it with current best practices. * Refactor ESLint configuration to use ES module syntax and enhance TypeScript support - Converted CommonJS `require` statements to ES module `import` syntax for better compatibility with modern JavaScript. - Added new paths to ignore in ESLint configuration to exclude additional directories. - Updated TypeScript file patterns to be more specific, improving linting accuracy. - Introduced new React hooks rules and adjusted existing rules for better adherence to best practices. - Made minor adjustments to import statements across various files for consistency and clarity. These changes improve the overall linting setup and ensure better code quality across the project. * Refactor import statements across multiple files for consistency - Updated import statements to use TypeScript's `type` syntax for type imports, enhancing clarity and consistency across the codebase. - Consolidated imports from the same module into single statements, improving readability and maintainability. These changes streamline the code structure and align with best practices for TypeScript imports. * Refactor import statements in memory manager for improved clarity - Updated import statements to consolidate type imports and enhance readability. - Removed redundant imports, streamlining the code structure in the memory manager file. These changes align with best practices for TypeScript imports and improve maintainability. * Add Husky for pre-commit and pre-push hooks - Introduced Husky to manage Git hooks, enhancing the development workflow. - Added pre-commit and pre-push scripts to enforce code formatting and linting checks before commits and pushes. - Updated package.json to include Husky as a dependency and added a prepare script for setup. These changes improve code quality and ensure adherence to formatting and linting standards during the development process. * Refactor import statements for improved clarity and consistency - Updated import statements across multiple files to consolidate type imports and enhance readability. - Adjusted the order of imports for better organization and alignment with best practices in TypeScript. These changes streamline the code structure and improve maintainability throughout the project. * ran formatter * Refactor import statements and improve code formatting across multiple files - Consolidated and reordered import statements for better clarity and consistency in `SkillsGrid.tsx`, `SkillProvider.tsx`, and `index.ts`. - Enhanced readability by adjusting formatting and removing redundant lines. - These changes align with best practices for TypeScript imports and improve overall maintainability of the codebase. * Refactor and optimize code in multiple components - Removed redundant properties from the `STATUS_DISPLAY` object in `SkillsGrid.tsx` to streamline status handling. - Consolidated import statements in `SettingsModal.tsx` for improved organization. - Simplified state management and error handling in `BillingPanel.tsx`, enhancing performance and readability. - Added `REHYDRATE` import to `index.ts` for better state persistence management. These changes improve code clarity, maintainability, and align with best practices in TypeScript development. * Consolidate import statements in SettingsModal.tsx for improved organization * Add Prettier and ESLint checks to typecheck workflow - Integrated a Prettier formatting check to ensure code style consistency. - Added an ESLint step to enforce code quality and catch potential issues. - These enhancements improve the development workflow by automating formatting and linting checks during the typecheck process. * Add activeSkillDescription state to ConnectionsPanel and ConnectStep - Introduced activeSkillDescription state in both ConnectionsPanel and ConnectStep components to store and manage skill descriptions. - Updated the SkillSetupModal to accept skillDescription as a prop, enhancing the modal's functionality and data handling. These changes improve the user experience by providing more detailed information about skills during the connection setup process. * Enhance pre-push hook to include TypeScript compile check - Added a TypeScript compile check to the pre-push script, ensuring that code compiles successfully before pushing. - Updated error handling to include compile errors alongside formatting and linting issues, providing clearer feedback to developers. These changes improve the reliability of the codebase by preventing non-compiling code from being pushed. * Update GitHub workflows for pull request handling and publishing logic - Modified the package-and-publish workflow to support pull request events, ensuring proper handling of branches. - Adjusted the SHOULD_PUBLISH environment variable to differentiate between pull requests and main branch events. - Updated the pr-protection workflow to focus solely on the main branch, removing references to the master branch. These changes enhance the CI/CD process by refining branch handling and improving clarity in workflow conditions.
224 lines
6.7 KiB
JavaScript
224 lines
6.7 KiB
JavaScript
// ESLint flat config for ESLint 9+
|
|
// This config is compatible with Prettier and won't conflict with formatting rules
|
|
|
|
import js from '@eslint/js';
|
|
import tseslint from '@typescript-eslint/eslint-plugin';
|
|
import tsparser from '@typescript-eslint/parser';
|
|
import reactPlugin from 'eslint-plugin-react';
|
|
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
import importPlugin from 'eslint-plugin-import';
|
|
import prettierConfig from 'eslint-config-prettier';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname } from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
export default [
|
|
// Base recommended rules
|
|
js.configs.recommended,
|
|
|
|
// Ignore patterns
|
|
{
|
|
ignores: [
|
|
'node_modules/**',
|
|
'dist/**',
|
|
'coverage/**',
|
|
'src-tauri/**',
|
|
'skills/**',
|
|
'references/**',
|
|
'deploy/**',
|
|
'scripts/**',
|
|
'*.config.js',
|
|
'*.config.ts',
|
|
'vitest.config.ts',
|
|
'tsconfig.tsbuildinfo',
|
|
],
|
|
},
|
|
|
|
// Browser environment globals
|
|
{
|
|
files: ['**/*.js', '**/*.ts', '**/*.jsx', '**/*.tsx'],
|
|
languageOptions: {
|
|
globals: {
|
|
// Browser globals
|
|
window: 'readonly',
|
|
document: 'readonly',
|
|
navigator: 'readonly',
|
|
console: 'readonly',
|
|
setTimeout: 'readonly',
|
|
setInterval: 'readonly',
|
|
clearTimeout: 'readonly',
|
|
clearInterval: 'readonly',
|
|
fetch: 'readonly',
|
|
AbortSignal: 'readonly',
|
|
self: 'readonly',
|
|
crypto: 'readonly',
|
|
atob: 'readonly',
|
|
btoa: 'readonly',
|
|
// React globals
|
|
React: 'readonly',
|
|
// Node.js globals (for Vite/node polyfills)
|
|
require: 'readonly',
|
|
process: 'readonly',
|
|
Buffer: 'readonly',
|
|
global: 'readonly',
|
|
__dirname: 'readonly',
|
|
__filename: 'readonly',
|
|
module: 'readonly',
|
|
exports: 'readonly',
|
|
},
|
|
},
|
|
},
|
|
|
|
// TypeScript files configuration
|
|
{
|
|
files: ['src/**/*.ts', 'src/**/*.tsx'],
|
|
languageOptions: {
|
|
parser: tsparser,
|
|
parserOptions: {
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
project: './tsconfig.json',
|
|
tsconfigRootDir: __dirname,
|
|
},
|
|
},
|
|
plugins: {
|
|
'@typescript-eslint': tseslint,
|
|
import: importPlugin,
|
|
},
|
|
rules: {
|
|
// Disable base no-unused-vars in favor of TypeScript version
|
|
'no-unused-vars': 'off',
|
|
// TypeScript recommended rules (disable base JS rules that TypeScript handles)
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_|^[A-Z_]+$', // Ignore _prefixed vars and ALL_CAPS (enum members)
|
|
caughtErrorsIgnorePattern: '^_',
|
|
ignoreRestSiblings: true,
|
|
},
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
|
|
// Import/export rules
|
|
// Note: import/order is disabled to let Prettier handle import sorting
|
|
// ESLint still checks for other import issues
|
|
'import/order': 'off', // Prettier plugin handles import sorting
|
|
'import/no-unresolved': 'off', // TypeScript handles this
|
|
'import/no-cycle': 'warn',
|
|
'import/no-duplicates': 'error', // Prevent duplicate imports
|
|
|
|
// General JavaScript/TypeScript rules
|
|
'no-console': 'off', // Allow console in frontend code
|
|
'no-debugger': 'error',
|
|
'no-duplicate-imports': 'error',
|
|
'no-unused-expressions': 'off', // Covered by @typescript-eslint version
|
|
'@typescript-eslint/no-unused-expressions': 'error',
|
|
|
|
// Code quality
|
|
'prefer-const': 'error',
|
|
'no-var': 'error',
|
|
'object-shorthand': 'error',
|
|
'prefer-arrow-callback': 'error',
|
|
|
|
// Style: Enforce single-line statements on same line without braces when possible
|
|
curly: ['error', 'multi', 'consistent'], // Allow single-line without braces, require braces only for multi-statement blocks
|
|
'nonblock-statement-body-position': ['error', 'beside'], // Enforce single-line statements on same line (prevents braces on single-line)
|
|
},
|
|
},
|
|
|
|
// React files configuration
|
|
{
|
|
files: ['src/**/*.jsx', 'src/**/*.tsx'],
|
|
languageOptions: {
|
|
parser: tsparser,
|
|
parserOptions: {
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module',
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
project: './tsconfig.json',
|
|
tsconfigRootDir: __dirname,
|
|
},
|
|
},
|
|
plugins: {
|
|
react: reactPlugin,
|
|
'react-hooks': reactHooksPlugin,
|
|
},
|
|
settings: {
|
|
react: {
|
|
version: 'detect',
|
|
},
|
|
},
|
|
rules: {
|
|
...reactPlugin.configs.recommended.rules,
|
|
...reactHooksPlugin.configs.recommended.rules,
|
|
'react/react-in-jsx-scope': 'off', // Not needed in React 17+
|
|
'react/prop-types': 'off', // TypeScript handles prop validation
|
|
'react/display-name': 'off', // Not needed with TypeScript
|
|
'react/no-unescaped-entities': 'off', // Prettier handles this
|
|
'react-hooks/rules-of-hooks': 'error',
|
|
'react-hooks/exhaustive-deps': 'warn',
|
|
'react-hooks/set-state-in-effect': 'warn', // Allow initialization in effects
|
|
'react-hooks/refs': 'off', // Allow ref access in context providers
|
|
},
|
|
},
|
|
|
|
// Vitest test files and test setup files (must come after TypeScript config to override rules)
|
|
{
|
|
files: [
|
|
'**/*.test.ts',
|
|
'**/*.test.tsx',
|
|
'**/*.spec.ts',
|
|
'**/*.spec.tsx',
|
|
'**/__tests__/**/*.ts',
|
|
'**/__tests__/**/*.tsx',
|
|
],
|
|
languageOptions: {
|
|
globals: {
|
|
// Vitest globals
|
|
describe: 'readonly',
|
|
it: 'readonly',
|
|
test: 'readonly',
|
|
expect: 'readonly',
|
|
beforeEach: 'readonly',
|
|
afterEach: 'readonly',
|
|
beforeAll: 'readonly',
|
|
afterAll: 'readonly',
|
|
vi: 'readonly',
|
|
vitest: 'readonly',
|
|
},
|
|
},
|
|
rules: {
|
|
'@typescript-eslint/no-explicit-any': 'off', // Allow any in tests
|
|
'@typescript-eslint/no-non-null-assertion': 'off', // Allow non-null assertions in tests
|
|
'no-undef': 'off', // Vitest provides globals
|
|
},
|
|
},
|
|
|
|
// JavaScript files configuration
|
|
{
|
|
files: ['**/*.js', '**/*.jsx'],
|
|
languageOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
|
rules: {
|
|
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
|
|
'no-console': 'off',
|
|
'no-debugger': 'error',
|
|
'prefer-const': 'error',
|
|
'no-var': 'error',
|
|
},
|
|
},
|
|
|
|
// Disable all Prettier-conflicting rules (must be last)
|
|
prettierConfig,
|
|
];
|