Skip to content

Consolidate Prettier config and improve consistency#15191

Merged
FelixMalfait merged 4 commits intomainfrom
feat/enforce-trailing-newlines
Oct 18, 2025
Merged

Consolidate Prettier config and improve consistency#15191
FelixMalfait merged 4 commits intomainfrom
feat/enforce-trailing-newlines

Conversation

@FelixMalfait
Copy link
Copy Markdown
Member

@FelixMalfait FelixMalfait commented Oct 18, 2025

Summary

Clean up and consolidate formatting configuration across the monorepo.

Changes

1. Remove Redundant Configs

  • ❌ Delete packages/twenty-server/.prettierrc (had invalid brakeBeforeElse typo)
  • ❌ Delete packages/twenty-zapier/.prettierrc
  • ✅ Use root .prettierrc only (Prettier searches up directory tree automatically)

2. Improve Root Prettier Config

  • Change endOfLine: 'auto''lf' for consistent Unix line endings across all OSes

3. Enhance VSCode Settings

  • files.eol: 'auto''\\n' (consistent with Prettier)
  • Add files.insertFinalNewline: true (explicit editor behavior)
  • Add files.trimTrailingWhitespace: true (cleaner files)

4. Add .gitattributes

  • Enforce LF line endings at Git level
  • Prevents core.autocrlf from converting based on contributor's OS
  • Mark patch files as binary (they have mixed line endings by design)
  • Explicitly define binary file types

5. Fix Line Endings

  • Convert 3 selectable-list state files from CRLF → LF
  • These were the only source files with Windows line endings

Why These Changes Matter

Before:

  • 3 different Prettier configs (inconsistent, one had typo)
  • Mixed CRLF/LF depending on contributor's OS
  • No Git-level enforcement

After:

  • Single source of truth for formatting
  • All files use LF (Unix standard)
  • Git enforces line endings regardless of OS
  • Prettier warning about invalid option removed

Result

  • ✅ Single .prettierrc config
  • ✅ Consistent LF line endings enforced by Git
  • ✅ Better VSCode defaults
  • ✅ No more CRLF files sneaking in from Windows contributors

- Add 'eol-last': ['error', 'always'] to ESLint configs
- Change Prettier endOfLine from 'auto' to 'lf'
- Run lint --fix to apply consistent-type-imports fixes

This ensures all code files end with a newline character,
following POSIX standards and preventing .env concatenation issues.
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR implements ESLint enforcement of trailing newlines across the codebase by adding the 'eol-last': ['error', 'always'] rule to both base and React ESLint configurations. The changes ensure all text files end with a newline character, following POSIX standards. The PR also updates Prettier's endOfLine setting from 'auto' to 'lf' for consistent Unix-style line endings. Most modifications are automatic fixes that convert regular TypeScript imports to type-only imports (e.g., RuleContexttype RuleContext) and add missing trailing newlines to files. This systematic approach improves tooling compatibility, prevents shell concatenation issues, and ensures cleaner git diffs across the entire codebase.

Important Files Changed

Changed Files
Filename Score Overview
eslint.config.mjs 5/5 Added 'eol-last': ['error', 'always'] rule to base ESLint configuration
eslint.config.react.mjs 5/5 Added 'eol-last': ['error', 'always'] rule to React ESLint configuration
.prettierrc 4/5 Changed endOfLine from 'auto' to 'lf' but file itself lacks trailing newline
tools/eslint-rules/rules/matching-state-variable.ts 4/5 Added type import and trailing newline, but has inconsistent error message data properties
tools/eslint-rules/rules/component-props-naming.ts 5/5 Converted RuleContext import to type-only import
tools/eslint-rules/rules/effect-components.ts 5/5 Converted TSESTree and RuleContext to type-only imports
tools/eslint-rules/rules/explicit-boolean-predicates-in-if.ts 5/5 Converted TSESTree import to type-only import
tools/eslint-rules/rules/graphql-resolvers-should-be-guarded.ts 5/5 Added missing trailing newline to ESLint rule file
tools/eslint-rules/rules/graphql-resolvers-should-be-guarded.spec.ts 5/5 Added missing trailing newline to test specification file
tools/eslint-rules/rules/max-consts-per-file.ts 5/5 Converted TSESTree import to type-only import
tools/eslint-rules/rules/no-navigate-prefer-link.ts 5/5 Converted TSESTree import to type-only import
tools/eslint-rules/rules/rest-api-methods-should-be-guarded.ts 5/5 Added missing trailing newline to ESLint rule file
tools/eslint-rules/rules/rest-api-methods-should-be-guarded.spec.ts 5/5 Added missing trailing newline to test specification file
tools/eslint-rules/rules/sort-css-properties-alphabetically.ts 5/5 Converted multiple types to type-only imports
tools/eslint-rules/utils/createRule.ts 5/5 Added missing trailing newline to utility file
tools/eslint-rules/utils/typedTokenHelpers.ts 5/5 Added missing trailing newline to utility file

Confidence score: 4/5

  • This PR is safe to merge with only one minor inconsistency needing attention
  • Score reflects clean implementation of POSIX standards with mostly automated fixes, but points deducted for .prettierrc not following its own rule and one inconsistent error message pattern
  • Pay close attention to .prettierrc (missing trailing newline) and tools/eslint-rules/rules/matching-state-variable.ts (inconsistent error message data properties)

Sequence Diagram

sequenceDiagram
    participant User
Loading

Additional Comments (1)

  1. tools/eslint-rules/rules/matching-state-variable.ts, line 94-97 (link)

    logic: Inconsistent data property names: uses actual/expected instead of actualName/expectedName like other error reports in this file

Context used:

  • Context from dashboard - Use 'type' instead of 'interface' for type definitions in the project. (source)

16 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

.prettierrc Outdated
"trailingComma": "all",
"endOfLine": "auto"
"endOfLine": "lf"
} No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: This file is missing a trailing newline, which contradicts the PR's goal of enforcing trailing newlines via ESLint. The ESLint rule 'eol-last': ['error', 'always'] should apply to this file.

Prompt To Fix With AI
This is a comment left during a code review.
Path: .prettierrc
Line: 5:5

Comment:
**logic:** This file is missing a trailing newline, which contradicts the PR's goal of enforcing trailing newlines via ESLint. The ESLint rule `'eol-last': ['error', 'always']` should apply to this file.

How can I resolve this? If you propose a fix, please make it concise.

- Remove redundant package-level .prettierrc files (twenty-server, twenty-zapier)
- Prettier automatically searches up directory tree, so root config is sufficient
- Fix twenty-server/.prettierrc typo: 'brakeBeforeElse' (invalid option)
- Change .prettierrc endOfLine from 'auto' to 'lf' for consistency
- Update .vscode/settings.json:
  - files.eol: 'auto' → '\n' (consistent with Prettier)
  - Add files.insertFinalNewline: true
  - Add files.trimTrailingWhitespace: true
- Fix 3 files with CRLF line endings in selectable-list states

Result: Single source of truth for Prettier config, consistent line endings.
@FelixMalfait FelixMalfait changed the title Enforce trailing newlines via ESLint Consolidate Prettier config and improve consistency Oct 18, 2025
- Enforce LF line endings for all text files
- Prevent Git autocrlf from converting line endings based on OS
- Mark patch files as binary to preserve mixed line endings
- Explicitly mark binary file types

This prevents CRLF files from entering the repo regardless of
contributor's Git config or operating system.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 18, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:27741

This environment will automatically shut down when the PR is closed or after 5 hours.

@FelixMalfait FelixMalfait merged commit 44aee86 into main Oct 18, 2025
57 checks passed
@FelixMalfait FelixMalfait deleted the feat/enforce-trailing-newlines branch October 18, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant