Skip to content

[FEAT] - Add Linting and Formatting to Build Pipeline #14

@dylanlangston

Description

@dylanlangston

Is your feature request related to a problem? Please describe.

Currently, the AvaloniaXKCD repository lacks an automated process for code linting and formatting. This can lead to inconsistent coding styles, reduced code quality, and potential bugs that are not caught early in the development process. A consistent and clean codebase is easier to read, maintain, and contribute to.

Describe the solution you'd like

To improve code quality and maintain a consistent style across the project, we propose integrating linting and formatting tools into the build pipeline for both the C# and TypeScript code.

For C#:

  • CSharpier: An opinionated code formatter for C#, inspired by Prettier. Its "format on save" feature and minimal configuration can help enforce a uniform style with little overhead.
  • dotnet format: The official .NET code formatter that can apply style preferences from an .editorconfig file. It also includes capabilities for code style analysis.

Recommendation: Use CSharpier for consistent, opinionated formatting and supplement with dotnet format for its analytical and linting capabilities.

For TypeScript/JavaScript:

  • ESLint: A pluggable linting utility for JavaScript and TypeScript that identifies problematic patterns in the code. It helps enforce best practices and catch bugs.
  • Prettier: An opinionated code formatter that focuses solely on code style and formatting.

Recommendation: Use both Prettier for formatting and ESLint for code quality and bug detection, as this is a common and recommended practice. They can be configured to work together to prevent conflicts.

Describe alternatives you've considered

  • Manual Formatting. buthis is the current process and is not scalable or consistent, especially as more contributors get involved.
  • Using only dotnet format for C, but while dotnet format is a capable tool, CSharpier's opinionated nature can simplify setup and prevent debates over style rules.
  • Using only ESLint for TypeScript. ESLint can be configured for formatting, but Prettier is generally faster and more specialized for that task.

Additional context

Acceptance Criteria:

  • CSharpier is integrated into the build process for all C# files.
  • ESLint and Prettier are set up for the TypeScript/JavaScript files.
  • The release pipeline will fail if linting or formatting checks do not pass.
  • A make target is provided to allow developers to run formatting and linting locally.
  • Consider using a pre-commit hook to automatically format code before it is committed.
  • Documentation is updated to include instructions for the new linting and formatting setup.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestgood first issueGood for newcomersjavascriptPull requests that update javascript code

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions