Code Quality
We don't want bad or broken code to enter master
. Therefore, we deployed some tools in each
repository to check whether your committed code meets certain standard.
We use the following tools to enforce code quality checks:
- TypeScript for web/backend projects
- ESLint for web projects
- SwiftLint for iOS projects
- Android Linter (and optionally ktlint) for Android projects
flutter analyze
for Flutter projects
#
TypeScripttip
If your project is having endless bugs due to type errors, you should consider migrating to TypeScript as long as possible.
note
All new DTI web projects should start with TypeScript
Run tsc
to find all type errors. You must fix all type errors before you code can be accepted.
You can configure TypeScript in tsconfig.json
. To enable strict type checking, you should add
"strict": true
to your compilerOptions
in the json:
#
ESLintESLint should already be setup in your web repository.
You should run npm run lint
or yarn lint
to find all the linter errors, and fix them before
you commit or push.
You can configure the rules in .eslintrc
/.eslintrc.json
/.eslintrc.js
at the root of your
repository.
Your rules should start with this:
- React with TypeScript
- React with JavaScript
- Vue with TypeScript
- Backend with TypeScript
Examples rules:
- Carriage's configuration
- CoursePlan's configuration
- CUReview's configuration
- Flux's configuration
- Nova's configuration
- Research Connect's configuration
- Samwise's configuration
#
SwiftLintSwiftlint should already be setup in your iOS repository.
You can run
to find all the linter errors.
You should run
before you commit and push your changes.
You can configure the rules in .swiftlint.yml
at the root of your repository.
This is a reference rule you should start with:
Disable rules that are too disruptive for your subteam.
Examples rules:
#
Android LintingRun
- Windows
- Mac & Linux
to find all the linter errors. You should fix them before you commit or push.
If you are using Kotlin to develop Android apps, consider using ktlint and its gradle plugin.
flutter analyze
#
You do not need to configure anything once you installed Flutter.
Simply run
to find all the linter errors. You should fix them before you commit or push.