Skip to content

ci: add prettier linting #264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged

Conversation

MikeMcC399
Copy link
Collaborator

Status

JavaScript files are linted for stylistic formatting using @stylistic/eslint-plugin.

Other types of files are not linted for formatting.

Assessment

Prettier is used in some other Cypress repos to provide consistent code formatting, in addition to @stylistic/eslint-plugin. It supports several file types including the following used in this repo:

JavaScript formatting is already the responsibility of @stylistic/eslint-plugin in this repo. Prettier has a different opinion about JavaScript and the two cannot be used together. Cypress itself does not use Prettier to format code - see CONTRIBUTING > Coding Style.

Change

  • Implement Prettier source file formatting with [email protected]
  • Target JSON and YAML initially
  • Defer linting Markdown until a follow-on PR
  • Exclude JavaScript and TypeScript from linting by Prettier
  • Add scripts to package.json
    "format": "prettier --write .",
    "format:check": "prettier --check .",
  • Add instructions to the CONTRIBUTING document to run format
  • Add format:check to circle.yml pipeline lint job and to .husky/pre-commit

Verification

On Ubuntu 24.04.2 LTS, Node.js 22.16.0 LTS

Execute

git clean -xfd
npm ci
npm run format:check

and confirm

All matched files use Prettier code style!

Execute

npm run format

and confirm that only the following file types are linted by Prettier at this time. Each should also be annotated with (unchanged):

  • *.yml
  • *.json

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 marked this pull request as ready for review June 3, 2025 07:45
@jennifer-shehane jennifer-shehane merged commit 8c9d1a0 into cypress-io:master Jun 4, 2025
10 checks passed
@MikeMcC399 MikeMcC399 deleted the ci/prettier branch June 4, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants