Summary of front end code review issues at the annual code rollover site

Mondo Technology Updated on 2024-03-05



Ali Mei guide.

* Review in the technical team of the engineer culture construction is very meaningful, it is the most effective way to form a unified team style, the author of his own team in a year of CR common small problems to do some combing, I hope to help you a little. I. Introduction.

The team has carried out offline weekly reviews for more than a year, as the main judges, I originally thought that it would take a lot of time and effort to give ** suggestions, and always thought that it would be of great help to the reviewees to improve the ** design problems, but in fact, the review found that most of the students were still in some basic ** quality problems, and the review to improve the design or find business bugs to achieve the goal rarely appeared, so I think the team should still have enough patience for CR. Explain the basic problems as a bug and accumulate them on the way to excellent engineering. At the same time, I can also deeply feel that each student's attitude towards ** is different, which has produced two differentiations, some people will improve very quickly, and some people will continue to repeat the problems that have been reviewed. I hope it can be of little help to everyone. Second, the rollover scene (common problems in CR).

2.1 **Normative class

2.1.1 Use manaRollover Index:Description:Mana represents a value that is not declared in ** and is used directly, which is widespread in our ** review questions.

bad case

const now = date.now();const lastvisittime = localstorage.getitem('last_visit_time');

if (lastvisittime &&parseint(lastvisittime, 10) >24 * 60 * 60 * 1000)

localstorage.setitem('last_visit_time', now.tostring())

good case
const last_visit_time_cache_key = 'last_visit_time';const day_in_ms = 24 * 60 * 60 * 1000;

const now = date.now();const lastvisittime = localstorage.getitem(last_visit_time_cache_key);

if (lastvisittime &&parseint(lastvisittime, 10) >day_in_ms)

localstorage.setitem(last_visit_time_cache_key, now.tostring())

2.1.2 Misuse of eslint-disableRollover Index:Description:eslint-disable is a directive used to disable specific rules in eslint, and some students will choose to use it to avoid problems when they encounter lint errors that are difficult to solve.

2.1.3 Using Ghost DependenciesRollover Index:Description:Ghost dependencies (also known as implicit dependencies or implicit dependencies) are packages that are not in a module of the project that are not in that moduleDependencies declared directly in the JSON file.

2.1.4 The no-else-return principle is not followedRollover Index:Description:no-else-return is a quality rule that emphasizes brevity and readability, and is used to indicate that there is no need to use an else block when an if block already contains a return statement. Because the return statement in the if block exits the current function as soon as the return statement in the if block is executed, else is redundant. ❌ you can skip the else block

function hello(condition: boolean) else
✅ yay, much easier to read
function hello(condition: boolean)

return '

Related Pages