Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@ For validating **React** project use `react` version (`htmlacademy/react` includ
}
```

For validating **React** project with TypeScript use `react-typescript` version (`htmlacademy/react-typescript` includes `react/recommended` and `@typescript-eslint/recommended`):
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`).

Before using `eslint-config-htmlacademy` make sure you have TypeScript, `@typescript-eslint/parser`, `@typescript-eslint/eslint-plugin` installed:

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

```json
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
"ecmaVersion": 2020,
"sourceType": "module",
"project": [
"tsconfig.json" // path to your tsconfig file
]
},
"env": {
"es2017": true,
Expand All @@ -73,6 +84,24 @@ For validating **React** project with TypeScript use `react-typescript` version

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"
}
}
]
}
```

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).

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

Before using `eslint-config-htmlacademy` make sure you have TypeScript and `@typescript-eslint/parser` installed:
Expand Down
10 changes: 6 additions & 4 deletions react-typescript.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
extends: [
'htmlacademy/react',
'plugin:@typescript-eslint/recommended'
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking'
],
rules: {
'react/jsx-uses-react': 'off',
Expand All @@ -10,9 +11,10 @@ module.exports = {
'@typescript-eslint/no-use-before-define': ['error'],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'@typescript-eslint/member-delimiter-style': ['error'],
'@typescript-eslint/no-useless-empty-export': 'warn'
'@typescript-eslint/no-useless-empty-export': 'warn',
'@typescript-eslint/no-floating-promises': 'off'
}
}