7.3 Code Quality Tools
Automated code quality tools catch issues before they reach code review and ensure consistent formatting across the team. These tools should integrate with developer editors and run automatically during the build process.
For PHP projects, we use PHP CodeSniffer as mentioned in the PHP section above. JavaScript projects use ESLint with configurations appropriate for the project’s requirements.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// .eslintrc.json for JavaScript projects
{
"extends": [
"eslint:recommended",
"@wordpress/eslint-plugin/recommended"
],
"env": {
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
"no-console": "warn",
"no-unused-vars": "error",
"prefer-const": "error"
}
}
Editor configuration files ensure consistent formatting across different editors and operating systems. Every project should include an .editorconfig file that defines indentation, line endings, and character encoding standards.
.editorconfig
root = true
[*] charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = space indent_size = 2
[*.{php,blade.php}] indent_style = tab indent_size = 4
[*.md] trim_trailing_whitespace = false