Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
; http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[*.{go,py,rb,php}]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
88 changes: 63 additions & 25 deletions .github/ISSUE_TEMPLATE/bugreport.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,77 @@
name: 'Сообщение о проблеме'
description: 'Issue для сообщения о проблеме или баге'
title: 'Проблема: '
labels: ['bug']
name: "Bug Report"
description: "Report a bug or unexpected behavior"
title: "Bug: "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Спасибо, что помогаете улучшить наш проект! Пожалуйста, заполните следующую информацию:
Thanks for reporting! Please fill in the details below.

- type: dropdown
id: linthtml-version
attributes:
label: LintHTML version
options:
- 0.10.x
- 0.9.x
- Other
validations:
required: true

- type: dropdown
id: node-version
attributes:
label: Node.js version
options:
- 24.x
- 22.x
- 20.x
- 18.x
- Other
validations:
required: true

- type: input
id: package-version
attributes:
label: Package version
placeholder: e.g., 2.0.0
validations:
required: true

- type: textarea
id: terminal-error
id: error-output
attributes:
label: Ошибка из терминала
description: Введите ошибку из терминала
label: Error output
description: Paste the linter output from terminal
placeholder: |
```bash
File: test/index.html
Config file: index.js
8:3 error The <section> element must contain a heading of any level. htmlacademy/section-has-heading
✖ 1 problem (1 error, 0 warning)
```
8:3 error The <section> element must contain...
validations:
required: true

- type: textarea
id: example
id: code-sample
attributes:
label: Часть кода на котором произошла ошибка
description: Скопируйте часть кода на который неправильно реагирует линтер
placeholder: |
```html
<section>
<h1>Title</h1>
</section>
```
label: Code sample
description: HTML code that triggers the issue
render: html
validations:
required: true

- type: textarea
id: expected-actual
attributes:
label: Expected vs Actual
description: What should happen vs what happens
validations:
required: true

- type: textarea
id: description
id: steps
attributes:
label: Описание проблемы
description: Пожалуйста, подробно опишите проблему или баг
label: Steps to reproduce
description: Only if not obvious from above
validations:
required: false
66 changes: 27 additions & 39 deletions .github/ISSUE_TEMPLATE/new-rule.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,44 @@
name: 'Новое правило'
description: 'Issue для предложения нового правила в линтер'
title: 'Правило: '
labels: ["enhancement"]
name: 'New Rule'
description: 'Propose a new lint rule'
title: 'Rule: '
labels: ['enhancement']
body:
- type: markdown
attributes:
value: |
Спасибо, что нашли временем поделиться новым правилом
Thanks for your rule proposal!

- type: textarea
id: description
attributes:
label: Краткое описание
description: Опишите коротко, что будет проверять правило своими словами
placeholder: Проверяет наличие заголовка любого уровня в `<section>`.
label: Rule description
description: What does this rule check?
placeholder: Checks that <section> elements contain a heading
validations:
required: true

- type: textarea
id: bad-example
id: invalid-examples
attributes:
label: Плохие примеры
description: Напишите примеры кода, на которые правило должно выдавать ошибку
placeholder: |
Без заголовка
```html
<section>
<section>
```
label: Invalid code examples
description: Code that should trigger errors
render: html
validations:
required: true

- type: textarea
id: good-example
id: valid-examples
attributes:
label: Хорошие примеры
description: Напишите примеры кода, на которые правило не должно реагировать
placeholder: |
C заголовком
```html
<section>
<h2></h2>
<section>
```

С любой вложенностью
```html
<section>
<div>
<h2></h2>
</div>
<section>
```
label: Valid code examples
description: Code that should pass
render: html
validations:
required: true

- type: textarea
id: free
id: context
attributes:
label: Поле со свободным описанием.
description: Добавьте сюда всё остальное, что хотели рассказать
label: Additional context
description: Links to specs, edge cases, etc.
validations:
required: false
24 changes: 0 additions & 24 deletions .github/workflows/eslint.yml

This file was deleted.

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
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/node_modules
yarn.lock
node_modules/
.DS_Store
Thumbs.db
.idea
.idea/
*.sublime*
*.lock
.publish
.vscode/
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.0.0 — ???

### Breaking Changes
- Renames `htmlacademy/img-svg-req-dimensions` → `htmlacademy/replaced-elements-req-dimensions`. Now also checks `<video>` and `<iframe>` for `width` and `height` attributes.

### Changed
- `htmlacademy/a-target-rel`: Now requires only `rel="noopener"` (removed `noreferrer` requirement).
- `htmlacademy/req-webp-in-picture`: Now accepts `image/avif` as alternative to `image/webp`.

## 1.0.21
Fixes `req-webp-in-picture` to not check `<picture>` if all `<source>` have attribute `type="image/svg+xml"`.

Expand Down Expand Up @@ -101,7 +110,7 @@ Added a new rule [htmlacademy/req-stylesheet-link](rules/req-stylesheet-link/REA
```html
<head>
<link rel="stylesheet" href="styles/style.css">
</head>
</head>
```

## 1.0.13
Expand All @@ -124,7 +133,7 @@ will not require a name attribute for `<input`> with `type="submit"`
## 1.0.12
Fix `htmlacademy/attr-req-value` rule

### Exceptions
### Exceptions
A single `<option>` in `<select>` may have an empty value for the `value` attribute if it is selected by default.

The following pattern is **not** considered a problem:
Expand Down
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) 2023 .html academy
Copyright (c) 2023-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
77 changes: 70 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,73 @@
# linthtml-rules-htmlacademy
Кастомные правила для linthtml от HTML Academy
# LintHTML Rules for HTML Academy CODEGUIDE

## All rules
Познакомьтесь со всеми правилами в [едином списке всех правил](docs/list-of-rules.md).
[![npm version](https://img.shields.io/npm/v/linthtml-rules-htmlacademy.svg)](https://www.npmjs.com/package/linthtml-rules-htmlacademy)
[![test](https://github.com/htmlacademy/linthtml-rules-htmlacademy/actions/workflows/test.yml/badge.svg)](https://github.com/htmlacademy/linthtml-rules-htmlacademy/actions/workflows/test.yml)
[![license](https://img.shields.io/npm/l/linthtml-rules-htmlacademy.svg)](https://github.com/htmlacademy/linthtml-rules-htmlacademy/blob/main/LICENSE)

## Contributing
Ознакомьтесь с подробными [правилами по содействию](./docs/CONTRIBUTING.md). Мы принимаем любую помощь, начиная с исправления орфографии, заканчивая созданием новых правил для линтера.
Custom LintHTML rules by [HTML Academy](https://htmlacademy.ru) for validating HTML markup according to the [HTML Academy Codeguide](https://codeguide.academy).

https://linthtml.vercel.app/developer-guide/plugins
## Installation

```bash
npm install linthtml-rules-htmlacademy --save-dev
```

## Usage

Add the plugin to your `.linthtmlrc` configuration file:

```json
{
"plugins": ["linthtml-rules-htmlacademy"],
"rules": {
"htmlacademy/tag-name-lowercase": true,
"htmlacademy/img-svg-req-dimensions": true
}
}
```

## Rules

| Rule | Description |
| --- | --- |
| [htmlacademy/a-target-rel](rules/a-target-rel/) | Requires `rel="noopener noreferrer"` on `<a target="_blank">` |
| [htmlacademy/aria-label-misuse](rules/aria-label-misuse/) | Requires `aria-label` usage on specific elements only |
| [htmlacademy/attr-delimiter](rules/attr-delimiter/) | Disallows spaces around `=` in attributes |
| [htmlacademy/attr-req-value](rules/attr-req-value/) | Disallows empty attribute values except those in `ignore` list |
| [htmlacademy/attribute-allowed-values](rules/attribute-allowed-values/) | Validates attribute values against allowed values |
| [htmlacademy/ban-url-spaces](rules/ban-url-spaces/) | Disallows spaces in `href` and `src` URLs |
| [htmlacademy/charset-position](rules/charset-position/) | Requires `<meta charset="utf-8">` as first element in `<head>` |
| [htmlacademy/class-first](rules/class-first/) | Requires `class` to be the first attribute on any element |
| [htmlacademy/form-action-attribute](rules/form-action-attribute/) | Requires `action` attribute on `<form>` |
| [htmlacademy/head-meta-charset](rules/head-meta-charset/) | Requires `<meta charset="utf-8">` in `<head>` |
| [htmlacademy/id-no-dup](rules/id-no-dup/) | Disallows duplicate `id` values on page |
| [htmlacademy/img-svg-req-dimensions](rules/img-svg-req-dimensions/) | Requires `width` and `height` on `<img>` and `<svg>` |
| [htmlacademy/input-req-label](rules/input-req-label/) | Requires label for input fields, allows `aria-label` |
| [htmlacademy/link-req-content](rules/link-req-content/) | Requires text content in `<a>` elements |
| [htmlacademy/no-blocking-script](rules/no-blocking-script/) | Validates script placement in markup |
| [htmlacademy/no-class-in-container](rules/no-class-in-container/) | Validates `class` attribute on children inside specified container |
| [htmlacademy/no-double-br](rules/no-double-br/) | Disallows consecutive `<br>` elements |
| [htmlacademy/no-px-size](rules/no-px-size/) | Requires `width` and `height` to contain only numbers without units |
| [htmlacademy/req-charset-utf](rules/req-charset-utf/) | Requires `UTF-8` for `<meta charset="">` |
| [htmlacademy/req-head-styles](rules/req-head-styles/) | Disallows stylesheets outside `<head>` |
| [htmlacademy/req-mailto](rules/req-mailto/) | Requires `mailto:` for links with email text |
| [htmlacademy/req-meta-viewport](rules/req-meta-viewport/) | Requires `<meta name="viewport">` in `<head>` |
| [htmlacademy/req-preload-font](rules/req-preload-font/) | Requires font preload in `<head>` |
| [htmlacademy/req-single-styles](rules/req-single-styles/) | Allows only one `<link rel="stylesheet">` in `<head>` |
| [htmlacademy/req-source-width-height](rules/req-source-width-height/) | Requires `width` and `height` on `<source>` inside `<picture>` |
| [htmlacademy/req-stylesheet-link](rules/req-stylesheet-link/) | Requires `<link rel="stylesheet">` with non-empty `href` |
| [htmlacademy/req-tags-presence](rules/req-tags-presence/) | Requires specified tags on page |
| [htmlacademy/req-webp-in-picture](rules/req-webp-in-picture/) | Requires `webp` format in `<picture>` |
| [htmlacademy/section-has-heading](rules/section-has-heading/) | Requires heading element in `<section>` |
| [htmlacademy/space-between-comments](rules/space-between-comments/) | Validates spaces in comments `<!-- Comment -->` |
| [htmlacademy/tag-forbid-attr](rules/tag-forbid-attr/) | Disallows specified attributes on specified tags |
| [htmlacademy/tag-name-lowercase](rules/tag-name-lowercase/) | Requires lowercase tag names |
| [htmlacademy/tag-req-attr](rules/tag-req-attr/) | Requires specified attributes on specified tags |
| [htmlacademy/tag-self-close](rules/tag-self-close/) | Disallows self-closing void elements (`<br>` not `<br/>`) |

## Links

- [HTML Academy](https://htmlacademy.ru)
- [HTML Academy Codeguide](https://codeguide.academy)
- [Codeguide Repository](https://github.com/htmlacademy/codeguide)
- [LintHTML Plugins Documentation](https://linthtml.vercel.app/developer-guide/plugins)
Loading