Skip to content
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

test: extend cypress examples linting to javascript styles #1385

Merged

Conversation

MikeMcC399
Copy link
Collaborator

Situation

  • ESLint is already used to lint JavaScript files (see eslint.config.mjs for configuration).

  • JavaScript source files that are part of the core action are already formatted using Prettier.

  • JavaScript source files in the examples directory are not yet linted for formatting.

  • ESLint offers a consolidated plugin @stylistic/eslint-plugin for Stylistic Formatting.

Change

  • Add linting using @stylistic/eslint-plugin using its recommended rules for the examples directory. Additionally use the following rules for alignment with .prettierrc.json. In the case of the comma-dangle rule, this is aligned instead with the settings in @cypress/eslint-plugin-dev since scaffolded Cypress config files are generated with dangling commas.

    '@stylistic/indent': ['error', 2],
    '@stylistic/comma-dangle': ['error', 'always-multiline'],
    '@stylistic/quotes': ['error', 'single'],
    '@stylistic/semi': ['error', 'never'],
  • Use npx eslint --fix on examples to move to consistent JavaScript formatting.

  • Add JavaScript related files in the examples directory to .prettierignore to avoid a management conflict between ESLint and Prettier. ESLint is responsible for formatting examples, not Prettier.

Verify

npm ci
npm run lint

and confirm that no linting errors are reported.

npx prettier --check examples/**/*.js

and confirm that:

  • no *.js JavaScript files in the examples directory are being touched by Prettier
  • no changes are being proposed by Prettier

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 self-assigned this Mar 5, 2025
@MikeMcC399 MikeMcC399 marked this pull request as ready for review March 5, 2025 17:28
Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

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

Looks good 👍🏻

@jennifer-shehane jennifer-shehane merged commit 5a231d3 into cypress-io:master Mar 5, 2025
76 checks passed
@MikeMcC399 MikeMcC399 deleted the add/eslint-examples-style branch March 5, 2025 17:56
Copy link

github-actions bot commented Mar 7, 2025

🎉 This PR is included in version 6.7.15 🎉

The release is available on:

Your semantic-release bot 📦🚀

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