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
10 changes: 0 additions & 10 deletions .github/auto_assign.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/ci.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: [master]
pull_request:
branches: [master]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- run: npm ci
- run: npm test
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
node_modules/
yarn.lock
build/
.DS_Store
Thumbs.db
.idea
.idea/
*.sublime*
*.log
*.psd
*.ai
*.pdf
css/*.css
.vscode/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
25 changes: 25 additions & 0 deletions changelog.md → CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Changelog

## 11.0.0

### Breaking Changes

- Requires ESLint >= 10 and Node.js >= 24
- Flat config format only (`eslint.config.js`), legacy `.eslintrc` not supported
- Removed ES5, ES5.5, ES6 configurations
- Replaced `eslint-plugin-react` with `@eslint-react/eslint-plugin`

### Changed

- All formatting rules migrated to `@stylistic/eslint-plugin`
- `func-call-spacing` set to `always` (matches codeguide: `foo ()`)
- React configs rewritten with `@eslint-react` + `@stylistic` JSX formatting
- `no-new-object` replaced with `no-object-constructor`

### Added

- `@eslint-react/eslint-plugin` for React linting
- JSX formatting rules via `@stylistic` (`jsx-closing-bracket-location`, `jsx-closing-tag-location`, `jsx-curly-newline`, `jsx-wrap-multilines`)

---

10.0.1 / 2023-09-19
==================

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) 2021 HTML Academy
Copyright (c) 2016-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
174 changes: 68 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,141 +1,103 @@
# eslint-config-htmlacademy
# ESLint Config for HTML Academy Codeguide

ESLint [shareable config](http://eslint.org/docs/developer-guide/shareable-configs.html) for the [HTML Academy](http://htmlacademy.ru) courses
[![npm version](https://img.shields.io/npm/v/eslint-config-htmlacademy.svg)](https://www.npmjs.com/package/eslint-config-htmlacademy)
[![CI](https://github.com/htmlacademy/eslint-config-htmlacademy/actions/workflows/ci.yml/badge.svg)](https://github.com/htmlacademy/eslint-config-htmlacademy/actions/workflows/ci.yml)
[![license](https://img.shields.io/npm/l/eslint-config-htmlacademy.svg)](https://github.com/htmlacademy/eslint-config-htmlacademy/blob/main/LICENSE)

[ESLint](https://eslint.org) shareable configuration for JavaScript validation according to [HTML Academy Codeguide](https://codeguide.academy).

Version 11 uses [flat config](https://eslint.org/docs/latest/use/configure/configuration-files) and is not compatible with `.eslintrc`.

## Requirements

- Node.js >= 24
- ESLint >= 10

## Installation

```bash
npm install --save-dev eslint-config-htmlacademy
npm install -D eslint eslint-config-htmlacademy
```

Package requires `eslint`. You must install it manually.
## Configurations

## Usage
| Name | Export | Description |
| --- | --- | --- |
| vanilla | `vanilla` | Browser JavaScript |
| node | `node` | Node.js + TypeScript |
| react | `react` | React |
| react-typescript | `reactTypescript` | React + TypeScript |

Once the `eslint-config-htmlacademy` package is installed, you can use it by specifying `htmlacademy` in the [`extends`](http://eslint.org/docs/user-guide/configuring#extending-configuration-files) section of your [ESLint configuration](http://eslint.org/docs/user-guide/configuring).
ES5 and ES6 configurations were removed in v11.

For validating **Vanilla JS** project use `vanilla` version:
## Usage

```json
{
"parserOptions": {
"ecmaVersion": 2023,
"sourceType": "module"
},
"env": {
"es2023": true,
"browser": true
},
"extends": "htmlacademy/vanilla",
"rules": {
// Additional rules...
}
}
```
Create `eslint.config.js` in your project root.

For validating **React** project use `react` version (`htmlacademy/react` includes `react/recommended`):
### Vanilla

```json
{
"parserOptions": {
"ecmaVersion": 2019,
"sourceType": "module"
},
"env": {
"es2017": true,
"browser": true
```js
// eslint.config.js
import {vanilla} from 'eslint-config-htmlacademy';

export default [
...vanilla,
{
// your overrides
},
"extends": "htmlacademy/react",
"rules": {
// Additional rules...
}
}
];
```

For validating **React** project with TypeScript use `react-typescript` version (`htmlacademy/react-typescript` includes `react/recommended`, `@typescript-eslint/recommended` and `@typescript-eslint/recommended-requiring-type-checking`).
### Node

Before using `eslint-config-htmlacademy` make sure you have TypeScript, `@typescript-eslint/parser`, `@typescript-eslint/eslint-plugin` installed:
For Node.js projects with TypeScript. Extends `vanilla` with `typescript-eslint`.

```bash
$ npm i --save-dev typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm install -D typescript
```

```json
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": [
"tsconfig.json" // path to your tsconfig file
]
},
"env": {
"es2017": true,
"browser": true
},
"extends": "htmlacademy/react-typescript",
"rules": {
// Additional rules...
}
}
```
```js
// eslint.config.js
import {node} from 'eslint-config-htmlacademy';

Caution! `htmlacademy/react` and `htmlacademy/react-typescript` doesn't include `react-hooks/rules-of-hooks` and `react-hooks/exhaustive-deps` because in our courses we use CRA (Create React App) which includes these plugins out of box. Install them yourself if necessary.

Caution! If you're wanting to use `toBeCalled` and similar matches in jest tests, you can use next option for `eslintConfig`:

```json
"eslintConfig": {
"overrides": [
{
"files": ["*test*"], // regExp to answer the question "How to find your tests?"
"rules": {
"@typescript-eslint/unbound-method": "off",
"jest/unbound-method": "error"
}
}
]
}
export default [
...node,
];
```

Why this is necessary, you can read on the [next page](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md).
### React

For validating **Node** project use `node` version (`htmlacademy/node` includes `htmlacademy/vanilla`, `plugin:@typescript-eslint/recommended` and `plugin:node/recommended`).
Extends `vanilla` with `@eslint-react/eslint-plugin`.

Before using `eslint-config-htmlacademy` make sure you have TypeScript and `@typescript-eslint/parser` installed:
```js
// eslint.config.js
import {react} from 'eslint-config-htmlacademy';

```bash
$ npm i --save-dev typescript @typescript-eslint/parser
export default [
...react,
];
```

Then install the plugin:
### React + TypeScript

Extends `react` with `typescript-eslint`.

```bash
$ npm i --save-dev @typescript-eslint/eslint-plugin
npm install -D typescript
```

```json
{
"env": {
"es2021": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2021,
"sourceType": "module"
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": "htmlacademy/node",
"rules": {
// Additional rules...
}
}
```js
// eslint.config.js
import {reactTypescript} from 'eslint-config-htmlacademy';

export default [
...reactTypescript,
];
```

Caution!
- `htmlacademy/node` aimed at using Typescript.
- `htmlacademy/node` recommends a use of the "engines" field of package.json, because our package includes `plugin:node/recomended`. The "engines" field is used by `node/no-unsupported-features/*` rules.
- `htmlacademy/node` uses ES6 modules and the rules are aimed precisely at this approach of connecting modules.
## Links

- [HTML Academy](https://htmlacademy.ru)
- [HTML Academy Codeguide](https://codeguide.academy)
- [Codeguide Repository](https://github.com/htmlacademy/codeguide)
- [ESLint Documentation](https://eslint.org/docs/latest/)
18 changes: 0 additions & 18 deletions es5.5.js

This file was deleted.

Loading