Code ownership rules
Team Collaboration Standards
Code style consistency is the foundation of team collaboration. Use tools like ESLint and Prettier to enforce code formatting, avoiding disputes caused by indentation, semicolons, and other stylistic issues. Configuration example:
// .eslintrc.js
module.exports = {
extends: ['airbnb', 'prettier'],
rules: {
'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }],
'no-console': 'off',
},
};
The Git workflow must be clearly defined. Recommended models include Git Flow or Trunk Based Development, with feature branches named in the feat/xxx
format. Code merges must undergo Code Review. Typical workflow:
git checkout -b feat/user-auth
git commit -m "Add JWT authentication module"
git push origin feat/user-auth
Daily stand-up meetings should be limited to 15 minutes. Use tools like Jira to track task status. Code reviews should provide specific feedback—avoid vague statements like "This needs optimization." Instead, say, "The function has more than 5 parameters; consider using an object parameter."
Code Ownership Rules
Module-level ownership follows the "developer-maintainer" principle. In Monorepo projects, specify owners via OWNERS
files:
# src/components/table/OWNERS
@fe-team-zhangsan
@fe-team-lisi
Shared code requires a committee system. For cross-team public components, changes must be approved by at least 3 core members. Version releases follow semantic versioning:
// package.json
{
"version": "2.1.0", // MAJOR.MINOR.PATCH
"private": true
}
Deprecated code must be properly labeled. Use @deprecated
and retain for at least two iteration cycles:
/**
* @deprecated Use the new useModal instead
* @remove-after 2024-06-30
*/
export function openDialog(config) {
// Legacy implementation
}
Documentation Standards
All new features must include documentation. For TypeScript, automatically generate type definition docs:
interface PaginationParams {
/** Current page number, starting from 1 */
current: number;
/** Number of records per page */
pageSize: number;
}
Complex algorithms require flowchart explanations. Embed Mermaid syntax in Markdown:
```mermaid
graph TD
A[Start] --> B{Condition Check}
B -->|Yes| C[Execute Action 1]
B -->|No| D[Execute Action 2]
```
API changes must be recorded in CHANGELOG.md. Follow this format:
## [2.1.0] - 2023-11-20
### Added
- Added virtual scroll table component
### Changed
- Adjusted paginator default styles
Quality Assurance Measures
Unit test coverage must exceed 90% for core modules. Jest configuration example:
// jest.config.js
module.exports = {
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
coverageThreshold: {
global: {
branches: 80,
functions: 85,
lines: 90,
statements: 90,
},
},
};
Write E2E tests using Cypress. Example test case:
describe('Login Flow', () => {
it('Redirects to dashboard after successful login', () => {
cy.visit('/login')
cy.get('#username').type('admin')
cy.get('#password').type('123456')
cy.get('form').submit()
cy.url().should('include', '/dashboard')
})
})
Integrate performance monitoring tools like Sentry to capture runtime errors:
import * as Sentry from '@sentry/react';
Sentry.init({
dsn: 'https://example@sentry.io/1',
release: process.env.REACT_APP_VERSION,
});
Emergency Handling
Production incidents are categorized by severity:
- P0: Respond within 30 minutes, full-team collaboration required
- P1: Respond within 2 hours, module owner leads resolution
- P2: Resolve by the next business day
Rollback operations must be logged:
-- Database rollback log
INSERT INTO rollback_log
(operator, version, reason, timestamp)
VALUES ('zhangsan', '2.1.0', 'Pagination component caused blank screen', NOW());
Hotfix branches should be named hotfix/date-issue-summary
and merged into all long-term branches.
本站部分内容来自互联网,一切版权均归源网站或源作者所有。
如果侵犯了你的权益请来信告知我们删除。邮箱:cc@cccx.cn