Skip to content
This repository was archived by the owner on May 12, 2025. It is now read-only.

Commit c010a65

Browse files
authored
fix: Remove warnings on installation (#229)
BREAKING CHANGE: Install `eslint-config-airbnb` (or `eslint-config-airbnb-base`) and `@typescript-eslint/parser` as dependencies. Follow the updated README.md file.
1 parent f065373 commit c010a65

File tree

7 files changed

+41
-52
lines changed

7 files changed

+41
-52
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
extends: ['./base.js', 'prettier'],
2+
extends: ['eslint-config-airbnb-base', './base.js', 'prettier'],
33
parserOptions: {
44
project: './tsconfig.json',
55
},

README.md

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,41 @@
22

33
[![Version](https://img.shields.io/npm/v/eslint-config-airbnb-typescript.svg?style=flat-square)](https://www.npmjs.com/package/eslint-config-airbnb-typescript?activeTab=versions) [![Downloads](https://img.shields.io/npm/dt/eslint-config-airbnb-typescript.svg?style=flat-square)](https://www.npmjs.com/package/eslint-config-airbnb-typescript) [![Last commit](https://img.shields.io/github/last-commit/iamturns/eslint-config-airbnb-typescript.svg?style=flat-square)](https://github.com/iamturns/eslint-config-airbnb-typescript/graphs/commit-activity) [![Build](https://img.shields.io/circleci/project/github/iamturns/eslint-config-airbnb-typescript/master.svg?style=flat-square)](https://circleci.com/gh/iamturns/eslint-config-airbnb-typescript) [![License](https://img.shields.io/github/license/iamturns/eslint-config-airbnb-typescript.svg?style=flat-square)](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/CONTRIBUTING.md) [![Code of conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](https://github.com/iamturns/eslint-config-airbnb-typescript/blob/master/CODE_OF_CONDUCT.md)
44

5-
Airbnb's ESLint config with TypeScript support
5+
Enhances Airbnb's ESLint config with TypeScript support
66

77
## Setup
88

9-
### 1) Install
9+
### 1) Setup regular Airbnb config
1010

11-
```
12-
npm install eslint-config-airbnb-typescript --save-dev
13-
```
14-
15-
### 2) Install ESLint plugins
11+
Make sure you have the regular Airbnb config setup. See [eslint-config-airbnb](https://www.npmjs.com/package/eslint-config-airbnb), or [eslint-config-airbnb-base](https://www.npmjs.com/package/eslint-config-airbnb-base) if you're not using React.
1612

17-
ESLint plugins used by this config must also be installed within your project. This is a limitation within ESLint (see [RFC](https://github.com/eslint/rfcs/tree/master/designs/2019-config-simplification) and [progress](https://github.com/eslint/eslint/issues/13481)).
13+
### 2) Install this config (and peer dependencies)
1814

1915
```bash
20-
npm install eslint-plugin-import@^2.22.0 \
21-
eslint-plugin-jsx-a11y@^6.3.1 \
22-
eslint-plugin-react@^7.20.3 \
23-
eslint-plugin-react-hooks@^4.0.8 \
24-
@typescript-eslint/eslint-plugin@^4.4.1 \
25-
--save-dev
26-
```
27-
28-
If you don't need React support:
29-
30-
```bash
31-
npm install eslint-plugin-import@^2.22.0 \
32-
@typescript-eslint/eslint-plugin@^4.4.1 \
16+
npm install eslint-config-airbnb-typescript \
17+
@typescript-eslint/eslint-plugin \
18+
@typescript-eslint/parser \
3319
--save-dev
3420
```
3521

3622
### 3) Configure ESLint
3723

38-
Add `"extends": "airbnb-typescript"` to your ESLint config file.
24+
Within your ESLint config file:
3925

40-
If you don't need React support, add `"extends": "airbnb-typescript/base"` instead.
26+
```diff
27+
extends: [
28+
'airbnb',
29+
+ 'airbnb-typescript'
30+
]
31+
```
4132

42-
An example `.eslintrc.js`:
33+
If you don't need React support:
4334

44-
```js
45-
module.exports = {
46-
extends: ['airbnb-typescript'],
47-
};
35+
```diff
36+
extends: [
37+
'airbnb-base',
38+
+ 'airbnb-typescript/base'
39+
]
4840
```
4941

5042
### 4) Configure the ESLint TypeScript parser
@@ -56,12 +48,12 @@ In your ESLint config, set [parserOptions.project](https://github.com/typescript
5648
For example:
5749

5850
```diff
59-
module.exports = {
60-
extends: ['airbnb-typescript'],
61-
+ parserOptions: {
62-
+ project: './tsconfig.json',
51+
{
52+
extends: ['airbnb', 'airbnb-typescript'],
53+
+ parserOptions: {
54+
+ project: './tsconfig.json'
6355
+ }
64-
};
56+
}
6557
```
6658

6759
### 5) Run ESLint
@@ -78,10 +70,6 @@ You can also get results in realtime inside most IDEs via a plugin.
7870

7971
## FAQ
8072

81-
### Does this work with JavaScript files too?
82-
83-
Yep! This config is a drop-in replacement for `eslint-config-airbnb`, decorating it with TypeScript support.
84-
8573
### I get this error when running ESLint: "The file must be included in at least one of the projects provided"
8674

8775
This means you are attempting to lint a file that `tsconfig.json` doesn't include.
@@ -104,17 +92,20 @@ parserOptions: {
10492
}
10593
```
10694

107-
### I get peer dependency warnings for ESLint React plugins, but I'm using `airbnb-typescript/base`
95+
### Why do I need the peer dependencies?
96+
97+
`@typescript-eslint/eslint-plugin` is a peer dependency because of a limitation within ESLint. See [issue](https://github.com/eslint/eslint/issues/3458), [RFC](https://github.com/eslint/rfcs/tree/master/designs/2019-config-simplification), and [progress](https://github.com/eslint/eslint/issues/13481).
10898

109-
This is a known problem. Some suggestions exist in this [GitHub issue](https://github.com/iamturns/eslint-config-airbnb-typescript/issues/6).
99+
`@typescript-eslint/parser` is a peer dependency because the version number must match `@typescript-eslint/eslint-plugin`.
110100

111101
### I wish this config would support [...]
112102

113-
The goal of `eslint-config-airbnb-typescript` is to simply decorate `eslint-config-airbnb` with TypeScript support. It's not a single config to cater for all TypeScript linting requirements. For additional functionality, alter your ESLint config file. For example:
103+
This config simply enhances the Airbnb with TypeScript support. It's not a single config to cater for all TypeScript linting requirements. For additional functionality, alter your ESLint config file. For example:
114104

115105
```js
116106
module.exports = {
117107
extends: [
108+
'airbnb',
118109
'airbnb-typescript',
119110
'airbnb/hooks',
120111
'plugin:@typescript-eslint/recommended',

base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
extends: ['eslint-config-airbnb-base', './lib/shared.js'].map(require.resolve),
2+
extends: ['./lib/shared.js'].map(require.resolve),
33
};

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file adds some React specific settings. Not using React? Use base.js instead.
22
module.exports = {
3-
extends: ['eslint-config-airbnb', './lib/shared'].map(require.resolve),
3+
extends: ['./lib/shared'].map(require.resolve),
44
settings: {
55
// Append 'ts' extensions to Airbnb 'import/resolver' setting
66
'import/resolver': {

lib/shared.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
12
const { rules: baseBestPracticesRules } = require('eslint-config-airbnb-base/rules/best-practices');
23
const { rules: baseErrorsRules } = require('eslint-config-airbnb-base/rules/errors');
34
const { rules: baseES6Rules } = require('eslint-config-airbnb-base/rules/es6');
45
const { rules: baseImportsRules } = require('eslint-config-airbnb-base/rules/imports');
56
const { rules: baseStyleRules } = require('eslint-config-airbnb-base/rules/style');
67
const { rules: baseVariablesRules } = require('eslint-config-airbnb-base/rules/variables');
8+
/* eslint-enable import/no-extraneous-dependencies */
79

810
module.exports = {
911
plugins: ['@typescript-eslint'],

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
"lint": "eslint ./",
2222
"validate": "npm run lint"
2323
},
24-
"dependencies": {
25-
"@typescript-eslint/parser": "^4.4.1",
26-
"eslint-config-airbnb": "^18.2.0",
27-
"eslint-config-airbnb-base": "^14.2.0"
24+
"peerDependencies": {
25+
"@typescript-eslint/eslint-plugin": "^4.4.1",
26+
"@typescript-eslint/parser": "^4.4.1"
2827
},
2928
"devDependencies": {
3029
"@typescript-eslint/eslint-plugin": "4.14.2",
3130
"doctoc": "2.0.1",
3231
"eslint": "7.32.0",
32+
"eslint-config-airbnb-base": "^14.2.1",
3333
"eslint-config-prettier": "8.3.0",
3434
"eslint-plugin-import": "2.24.1",
3535
"husky": "4.3.8",

renovate.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
"extends": ["config:base"],
33
"packageRules": [
44
{
5-
"packageNames": [
6-
"@typescript-eslint/parser",
7-
"eslint-config-airbnb",
8-
"eslint-config-airbnb-base"
9-
],
5+
"packageNames": ["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"],
106
"rangeStrategy": "replace"
117
}
128
]

0 commit comments

Comments
 (0)