Skip to content

feat: integrate prettier and enforce code formatting#192

Open
Rahul-R79 wants to merge 9 commits intoaccordproject:mainfrom
Rahul-R79:feat/add-prettier
Open

feat: integrate prettier and enforce code formatting#192
Rahul-R79 wants to merge 9 commits intoaccordproject:mainfrom
Rahul-R79:feat/add-prettier

Conversation

@Rahul-R79
Copy link
Copy Markdown

Closes #191

This PR integrates Prettier into the project to handle code formatting, separating stylistic concerns from code quality checks (ESLint). It also adds a mandatory formatting check in the CI pipeline.

Changes

  • Added Dependencies: prettier and eslint-config-prettier.
  • Added Configuration: Created .prettierrc with modern defaults (2-space indentation, single quotes, no trailing whitespace).
  • Updated Scripts: Added npm run format (write) and npm run format:check (verify) to package.json.
  • Updated ESLint: Modified .eslintrc.yml to extend prettier, disabling conflicting formatting rules.
  • Updated CI: Added npm run format:check step to .github/workflows/build.yml to fail builds on formatting errors.
  • Reformatted Codebase: Applied Prettier formatting to all source files (~133 files changed).

Flags

  • Large Diff: This PR touches ~130 files due to whitespace/indentation changes (moving from 4 spaces to 2 spaces).
  • History Mitigation: After merging, we should add the commit hash to .git-blame-ignore-revs (in a follow-up PR) to preserve git blame usability.

Screenshots or Video

N/A (Formatting changes only)

Related Issues

Author Checklist

  • Ensure you provide a DCO sign-off for your commits using the --signoff option of git commit.
  • Vital features and changes captured in unit and/or integration tests
  • Commits messages follow AP format
  • Extend the documentation, if necessary
  • Merging to main from fork:feat/add-prettier

@Rahul-R79
Copy link
Copy Markdown
Author

Rahul-R79 commented Jan 14, 2026

As we discussed in today's call, I've implemented Prettier for consistent formatting and added a CI check to enforce it.

I’ve also run the tests, linting, and Prettier locally, and everything passed successfully with no issues.

Note: To keep git blame clean, I will open a follow-up PR to add this commit hash to .git-blame-ignore-revs after merging, effectively hiding this massive reformatting from history.

Please review when you get some time @mttrbrts @dselman !

Comment thread lib/codegen/fromcto/avro/avrovisitor.js Fixed
Comment thread lib/codegen/fromcto/graphql/graphqlvisitor.js Fixed
Comment thread lib/codegen/fromcto/xmlschema/xmlschemavisitor.js Fixed
Signed-off-by: Rahul-R79 <rahul.devworks@gmail.com>
@coveralls
Copy link
Copy Markdown

Coverage Status

coverage: 98.363%. remained the same
when pulling a11a36e on Rahul-R79:feat/add-prettier
into 461d268 on accordproject:main.

Rahul-R79 and others added 3 commits February 17, 2026 00:07
Signed-off-by: Rahul R <158848606+Rahul-R79@users.noreply.github.com>
Signed-off-by: Rahul-R79 <rahul.devworks@gmail.com>
Signed-off-by: Rahul-R79 <rahul.devworks@gmail.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Integrates Prettier-based formatting into the repo, aiming to separate formatting concerns from ESLint and (per PR description) enforce formatting in CI.

Changes:

  • Add Prettier + eslint-config-prettier, and introduce format / format:check npm scripts.
  • Add Prettier configuration and ignore rules.
  • Update ESLint config to extend prettier and remove formatting-related rules; add VS Code workspace settings to default to Prettier.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
package.json Adds Prettier scripts and devDependencies; reformats JSON.
package-lock.json Locks new Prettier and eslint-config-prettier dependencies.
.vscode/settings.json Configures VS Code to format on save with Prettier and run ESLint fixes.
.prettierrc Introduces Prettier configuration (tab width, quotes, etc.).
.prettierignore Excludes build/artifact directories from Prettier runs.
.eslintrc.yml Extends prettier and removes ESLint formatting rules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json Outdated
Comment thread package.json
Comment thread .prettierrc Outdated
Comment thread .eslintrc.yml Outdated
Copy link
Copy Markdown
Member

@mttrbrts mttrbrts left a comment

Choose a reason for hiding this comment

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

Let's keep the 4 space indenting to remain consistent with other projects in this org, e.g. https://github.com/accordproject/concerto/blob/main/.eslintrc.yml

…t tabWidth to 4

Signed-off-by: Rahul-R79 <rahul.devworks@gmail.com>
@Rahul-R79 Rahul-R79 requested a review from mttrbrts March 10, 2026 18:09
@mttrbrts
Copy link
Copy Markdown
Member

@copilot why is the build failing?

@mttrbrts
Copy link
Copy Markdown
Member

Build Failure Analysis

The build is failing because the PR introduces a preinstall script in package.json:

"preinstall": "npm run lint:lockfile && npm run lint:deps"

This causes a chicken-and-egg problem in CI:

  1. npm ci runs preinstall before installing dependencies
  2. preinstall tries to run lockfile-lint and syncpack
  3. These tools aren't installed yet → build fails

The Fix

The main branch already addressed this (commit 450ac33 - "chore(ci): move lockfile-lint from preinstall script") by removing the preinstall script entirely.

To fix this PR:

  1. Rebase on latest main:

    git fetch upstream main
    git rebase upstream/main
  2. During conflict resolution, ensure package.json does NOT include the preinstall script. The lint checks should remain in the lint script:

    "lint": "eslint . && npm run lint:lockfile && npm run lint:deps",
  3. Regenerate package-lock.json after resolving conflicts:

    rm -rf node_modules package-lock.json
    npm install
  4. Force push the rebased branch:

    git push --force-with-lease

The rest of the prettier integration looks good! Just need to resolve this conflict with main.

The preinstall script fails in CI because lockfile-lint and syncpack
are not available before npm install completes. Moving these checks
to the lint script ensures they run after dependencies are installed.

Signed-off-by: Matt Roberts <code@rbrts.uk>
@mttrbrts mttrbrts enabled auto-merge (squash) April 26, 2026 21:21
mttrbrts and others added 2 commits April 26, 2026 22:27
Add missing prettier and eslint-config-prettier to lockfile.

Signed-off-by: Matt Roberts <code@rbrts.uk>
Signed-off-by: Matt Roberts <7544022+mttrbrts@users.noreply.github.com>
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.

feat: Integrate Prettier for Code Formatting and CI Check

5 participants