Skip to content

Formatting & Linting

Scripts for Formatting and Linting

Bufferthemes includes several npm scripts to help maintain code quality:

  • npm run format: This script is used to format your code using Prettier, ensuring that your code adheres to a consistent style and is easy to read.

  • npm run format:check: This script checks your code to verify that it is formatted correctly according to Prettier’s rules. It helps you identify any formatting issues that need to be addressed.

  • npm run lint: This script runs ESLint, which analyzes your code for potential errors and enforces coding standards in the src directory. It helps maintain code quality by identifying problematic patterns.

  • npm run lint:fix: This script automatically fixes any linting errors found in the src directory. It streamlines the process of correcting issues that ESLint identifies.

  • npm run fix: This script combines the functionality of both lint:fix and format, ensuring that your code is both linted for errors and formatted correctly. It provides a comprehensive solution for maintaining code quality.

GitHub Actions

The theme also includes GitHub Actions that verify that your code is formatted correctly and passes linting rules. The linting rules are based on eslint-plugin-astro and eslint-plugin-jsx-a11y. You can refer to their documentation to customize the rules.

  • eslint-plugin-astro: This plugin provides linting for Astro components. It helps find problems and apply a consistent code style. Check the User Guide for more information.

  • eslint-plugin-jsx-a11y: This plugin is a static AST checker for accessibility rules on JSX elements. It helps ensure that your Astro sites are accessible. Refer to the documentation for setup and usage instructions.

To disable the GitHub Actions, you can simply delete the files in the .github/workflows directory.