This repository provides a basic Angular 18 project setup with preconfigured ESLint rules. It serves as a starting point for Angular applications, demonstrating how ESLint can enforce code quality and best practices. The repository includes examples that illustrate common ESLint errors and warnings.
To get started with this project, follow these steps:
- Clone the repository:
git clone <repository_url>
cd ng-lint-starter-kit
- Install dependencies:
npm install
- Start the development server:
npm start
This command builds the application and serves it locally. Open your browser and navigate to http://localhost:4200/ to see the application in action.
The ESLint setup in this project includes rules from eslint:recommended
, @typescript-eslint/recommended
, @angular-eslint/recommended
, and @angular-eslint/template/accessibility
. These configurations ensure that the code adheres to best practices and maintains consistency throughout the project.
Accessibility is an important aspect of web development. This project includes specific ESLint rules (@angular-eslint/template/accessibility
) that help enforce accessibility standards in Angular templates. These rules ensure that elements like images, form controls, ARIA roles, and other HTML attributes are used correctly to enhance accessibility for users with disabilities.
This component demonstrates how to write Angular components that comply with ESLint rules and accessibility guidelines. Here's what this component does:
- Includes proper alt text for images.
- Uses label elements with associated controls.
- Uses appropriate ARIA attributes (role, aria-labelledby, etc.).
- Avoids unnecessary features like autofocus and distracting elements (
<marquee>
). - Implements a
trackBy
function inngFor
loops for better performance.
This component intentionally violates ESLint rules to demonstrate common mistakes and bad practices in Angular development. It includes examples of unused variables, missing return types, deprecated API usage, unnecessary bindings, and unsafe JavaScript functions like eval
.
Feel free to use this repository as a template for your Angular projects. By leveraging ESLint and adhering to accessibility guidelines, you can improve code quality, maintainability, and user experience in your applications.
Contributions are welcome! If you find issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.