How we evolve code: Notion’s “ratcheting” system using custom ESLint rules

Ankit Sardesai, Jake Teton-Landis
7 min readbeginner
--
View Original

Overview

The article discusses Notion's innovative 'ratcheting' system, which utilizes custom ESLint rules to gradually modernize their codebase while maintaining developer velocity. This approach minimizes technical debt and enhances code quality by systematically enforcing lint rules over time.

What You'll Learn

1

How to implement a gradual code modernization strategy using ESLint

2

Why using a ratcheting system can improve code quality without sacrificing developer speed

3

When to apply custom lint rules to enforce coding standards effectively

Prerequisites & Requirements

  • Basic understanding of ESLint and linting concepts
  • Familiarity with continuous integration tools(optional)

Key Questions Answered

How does Notion's ratcheting system work to enforce coding standards?
Notion's ratcheting system works by gradually decreasing the allowed error counts for lint rules over time. It tracks existing errors, automatically enforces rules through pre-commit hooks, and monitors progress using tools like Datadog and Notion, ensuring a steady decline in lint errors.
Why does Notion only allow ESLint rules to report errors instead of warnings?
Notion restricts ESLint rules to report errors to avoid confusion among developers. Warnings are often ignored, leading to a buildup of issues. By treating all lint rules as errors, the team ensures that every reported issue is actionable and must be addressed before merging code.
What format does Notion use for the ratchet file to avoid merge conflicts?
Notion switched to a tab-separated value (TSV) format for the ratchet file to minimize merge conflicts. This format allows each line to represent a single file and lint-rule combination, making it easier for multiple developers to work on fixing lint errors simultaneously without conflicts.
How does Notion track the progress of code modernization efforts?
Notion tracks progress by feeding data from the ratchet file into Datadog and Notion itself. This integration allows the team to visualize how quickly they are eliminating outdated patterns and where to focus their modernization efforts.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Implementing a ratcheting system can significantly reduce technical debt in your codebase.
By gradually enforcing lint rules, you can modernize your code without overwhelming your team, ensuring that improvements are sustainable and manageable.
2
Switching to a TSV format for tracking lint errors can streamline collaboration among developers.
This format minimizes merge conflicts and allows for smoother workflows, especially in larger teams where multiple developers may be addressing issues simultaneously.
3
Using Datadog for monitoring lint errors provides valuable insights into code quality trends.
This visibility helps teams identify areas needing attention and measure the impact of their modernization efforts effectively.

Common Pitfalls

1
Failing to properly manage merge conflicts in the ratchet file can slow down development.
Using a JSON format for the ratchet file can lead to frequent conflicts when multiple developers work on fixing lint errors simultaneously. Switching to a TSV format mitigates this issue.

Related Concepts

Code Quality Management
Linting Practices
Continuous Integration Strategies