Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
- run: npm ci
- run: npm test
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
node_modules/
yarn.lock
.DS_Store
Thumbs.db
.idea
*.sublime*
.idea/
*.lock
.publish
*.sublime*
.vscode/
17 changes: 13 additions & 4 deletions .htmlhintrc
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
{
"doctype-first": true,
"doctype-html5": true,
"html-lang-require": true,
"head-script-disabled": true,
"style-disabled": false,
"title-require": true,
"meta-charset-require": true,
"meta-viewport-require": true,
"main-require": true,
"h1-require": true,

"attr-lowercase": ["viewBox", "preserveAspectRatio"],
"attr-lowercase": ["viewBox", "preserveAspectRatio"],
"attr-no-duplication": true,
"attr-no-unnecessary-whitespace": true,
"attr-unsafe-chars": true,
"attr-value-double-quotes": true,
"attr-value-not-empty": false,
"attr-sorted": false,
"alt-require": true,
"input-requires-label": false,
"input-requires-label": true,

"tags-check": false,
"tag-pair": true,
"tag-self-close": false,
"tagname-lowercase": true,
"empty-tag-not-self-closed": false,
"empty-tag-not-self-closed": true,
"src-not-empty": true,
"href-abs-or-rel": false,

Expand All @@ -30,5 +36,8 @@
"inline-style-disabled": false,

"space-tab-mixed-disabled": "space",
"spec-char-escape": true
"spec-char-escape": true,

"button-type-require": true,
"form-method-require": true
}
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

## 2.0.0

- Update HTMLHint to 1.8.0
- `html-lang-require`: `<html>` must have `lang` attribute
- `meta-charset-require`: `<meta charset>` required
- `meta-viewport-require`: `<meta viewport>` required
- `main-require`: `<main>` required on page
- `h1-require`: `<h1>` required on page
- `button-type-require`: `<button>` must have `type` attribute
- `form-method-require`: `<form>` must have `method` attribute
- `empty-tag-not-self-closed`: void tags must not be self-closing
- `input-requires-label`: each `<input>` must have associated `<label>`

## 1.0.0

- Initial release with basic ruleset
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 HTML Academy
Copyright (c) 2020-2026 HTML Academy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
121 changes: 111 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,123 @@
# htmlhint-config-htmlacademy
> The standart htmlhint config
# HTMLHint Config for HTML Academy CODEGUIDE

[![npm version](https://img.shields.io/npm/v/htmlhint-config-htmlacademy.svg)](https://www.npmjs.com/package/htmlhint-config-htmlacademy)
[![test](https://github.com/htmlacademy/htmlhint-config-htmlacademy/actions/workflows/test.yml/badge.svg)](https://github.com/htmlacademy/htmlhint-config-htmlacademy/actions/workflows/test.yml)
[![license](https://img.shields.io/npm/l/htmlhint-config-htmlacademy.svg)](https://github.com/htmlacademy/htmlhint-config-htmlacademy/blob/main/LICENSE)

[HTMLHint](https://htmlhint.com) configuration for HTML markup validation according to [HTML Academy codeguide](https://codeguide.academy).

## Usage

### Main method (copy config)

1. Copy `.htmlhintrc` to project root
2. Install HTMLHint:

## Instalation
```bash
npm install -D htmlhint
```

## Usage
1. Copy `.htmlhintrc` to your project root
3. Add script to `package.json`:

2. Create package script
```json
{
"scripts": {
"lint:html": "htmlhint src/**/*.html"
}
}
```

4. Customize rules in `.htmlhintrc` as needed

### Alternative method (via npm)

Install the package:

```bash
npm install -D htmlhint htmlhint-config-htmlacademy
```

**package.json**
Add script to `package.json`:

```json
{
"scripts": {
"test": "htmlhint path/to/html/files/*.html"
}
"scripts": {
"lint:html": "htmlhint -c ./node_modules/htmlhint-config-htmlacademy/.htmlhintrc src/**/*.html"
}
}
```

Benefit: automatic config updates via npm.

## Rules

### Document

| Rule | Value | Description |
|------|-------|-------------|
| `doctype-first` | `true` | DOCTYPE must be first |
| `doctype-html5` | `true` | HTML5 DOCTYPE required |
| `html-lang-require` | `true` | `lang` attribute required on `<html>` |
| `head-script-disabled` | `true` | No `<script>` in `<head>` |
| `style-disabled` | `false` | `<style>` tag allowed |
| `title-require` | `true` | `<title>` tag required |
| `meta-charset-require` | `true` | `<meta charset>` required |
| `meta-viewport-require` | `true` | `<meta viewport>` required |
| `main-require` | `true` | `<main>` tag required |
| `h1-require` | `true` | `<h1>` tag required |

### Attributes

| Rule | Value | Description |
|------|-------|-------------|
| `attr-lowercase` | `["viewBox", "preserveAspectRatio"]` | Lowercase attributes, except SVG |
| `attr-no-duplication` | `true` | No duplicate attributes |
| `attr-no-unnecessary-whitespace` | `true` | No unnecessary whitespace in attributes |
| `attr-unsafe-chars` | `true` | No unsafe characters |
| `attr-value-double-quotes` | `true` | Double quotes for values |
| `attr-value-not-empty` | `false` | Empty values allowed |
| `attr-sorted` | `false` | Attribute sorting disabled |
| `alt-require` | `true` | `alt` required for images |
| `input-requires-label` | `true` | `<label>` required for `<input>` |

### Tags

| Rule | Value | Description |
|------|-------|-------------|
| `tags-check` | `false` | Tag checking disabled |
| `tag-pair` | `true` | Paired tags must be closed |
| `tag-self-close` | `false` | Self-closing tags disabled |
| `tagname-lowercase` | `true` | Lowercase tags |
| `empty-tag-not-self-closed` | `true` | Void tags without `/` |
| `src-not-empty` | `true` | No empty `src` |
| `href-abs-or-rel` | `false` | Link type checking disabled |
| `button-type-require` | `true` | `type` required on `<button>` |
| `form-method-require` | `true` | `method` required on `<form>` |

### IDs and Classes

| Rule | Value | Description |
|------|-------|-------------|
| `id-class-ad-disabled` | `false` | Ad name checking disabled |
| `id-class-value` | `false` | Name format checking disabled |
| `id-unique` | `true` | IDs must be unique |

### Formatting

| Rule | Value | Description |
|------|-------|-------------|
| `inline-script-disabled` | `false` | Inline scripts allowed |
| `inline-style-disabled` | `false` | Inline styles allowed |
| `space-tab-mixed-disabled` | `"space"` | Spaces only for indentation |
| `spec-char-escape` | `true` | Special characters must be escaped |

## Requirements

- HTMLHint >=1.8.0

## Links

- [HTML Academy](https://htmlacademy.ru)
- [HTML Academy Codeguide](https://codeguide.academy)
- [Codeguide Repository](https://github.com/htmlacademy/codeguide)
- [HTMLHint Documentation](https://htmlhint.com/getting-started/)
Loading