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

Commit 70e86f9

Browse files
authored
feat: Update dependencies, support ESLint v6 (#17)
BREAKING CHANGE: New and updated linting rules bubbled up from latest Airbnb version. New dependencies and dependency versions required within your app. Using `airbnb-typescript`? ``` npm install eslint-config-airbnb-typescript@latest \ eslint-plugin-import@^2.18.2 \ eslint-plugin-jsx-a11y@^6.2.3 \ eslint-plugin-react@^7.14.3 \ eslint-plugin-react-hooks@^1.7.0 \ @typescript-eslint/eslint-plugin@^2.3.0 \ --save-dev ``` Using `airbnb-typescript/base` (no React support)? ``` npm install eslint-config-airbnb-typescript@latest \ eslint-plugin-import@^2.18.2 \ @typescript-eslint/eslint-plugin@^2.3.0 \ --save-dev ```
1 parent bb144f0 commit 70e86f9

File tree

5 files changed

+799
-1578
lines changed

5 files changed

+799
-1578
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ Install dependencies. ESLint plugins [must also be installed](https://github.com
1212

1313
```bash
1414
npm install eslint-config-airbnb-typescript \
15-
eslint-plugin-import@^2.14.0 \
16-
eslint-plugin-jsx-a11y@^6.1.1 \
17-
eslint-plugin-react@^7.11.0 \
18-
@typescript-eslint/eslint-plugin@^1.11.0 \
15+
eslint-plugin-import@^2.18.2 \
16+
eslint-plugin-jsx-a11y@^6.2.3 \
17+
eslint-plugin-react@^7.14.3 \
18+
eslint-plugin-react-hooks@^1.7.0 \
19+
@typescript-eslint/eslint-plugin@^2.3.0 \
1920
--save-dev
2021
```
2122

@@ -39,8 +40,8 @@ Install dependencies. ESLint plugins [must also be installed](https://github.com
3940

4041
```bash
4142
npm install eslint-config-airbnb-typescript \
42-
eslint-plugin-import@^2.14.0 \
43-
@typescript-eslint/eslint-plugin@^1.11.0 \
43+
eslint-plugin-import@^2.18.2 \
44+
@typescript-eslint/eslint-plugin@^2.3.0 \
4445
--save-dev
4546
```
4647

lib/shared.js

Lines changed: 90 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,30 @@ module.exports = {
2222
},
2323
],
2424

25+
// Replace Airbnb 'brace-style' rule with '@typescript-eslint' version
26+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
27+
"brace-style": "off",
28+
"@typescript-eslint/brace-style": [
29+
"error",
30+
"1tbs",
31+
{ allowSingleLine: true },
32+
],
33+
2534
// Replace Airbnb 'camelcase' rule with '@typescript-eslint' version
2635
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md
2736
camelcase: "off",
28-
"@typescript-eslint/camelcase": ["error", { properties: "never" }],
37+
"@typescript-eslint/camelcase": [
38+
"error",
39+
{ properties: "never", ignoreDestructuring: false },
40+
],
41+
42+
// Replace Airbnb 'func-call-spacing' rule with '@typescript-eslint' version
43+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
44+
"func-call-spacing": "off",
45+
"@typescript-eslint/func-call-spacing": ["error", "never"],
2946

3047
// Replace Airbnb 'indent' rule with '@typescript-indent' version
48+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
3149
indent: "off",
3250
"@typescript-eslint/indent": [
3351
"error",
@@ -77,6 +95,44 @@ module.exports = {
7795
"no-array-constructor": "off",
7896
"@typescript-eslint/no-array-constructor": "error",
7997

98+
// Replace Airbnb 'no-empty-function' rule with '@typescript-indent' version
99+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
100+
"no-empty-function": "off",
101+
"@typescript-eslint/no-empty-function": [
102+
"error",
103+
{
104+
allow: ["arrowFunctions", "functions", "methods"],
105+
},
106+
],
107+
108+
// Replace Airbnb 'no-extra-parens' rule with '@typescript-indent' version
109+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
110+
"no-extra-parens": "off",
111+
"@typescript-eslint/no-extra-parens": [
112+
"off",
113+
"all",
114+
{
115+
conditionalAssign: true,
116+
nestedBinaryExpressions: false,
117+
returnAssign: false,
118+
ignoreJSX: "all", // delegate to eslint-plugin-react
119+
enforceForArrowConditionals: false,
120+
},
121+
],
122+
123+
// Replace Airbnb 'no-magic-numbers' rule with '@typescript-indent' version
124+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md
125+
"no-magic-numbers": "off",
126+
"@typescript-eslint/no-magic-numbers": [
127+
"off",
128+
{
129+
ignore: [],
130+
ignoreArrayIndexes: true,
131+
enforceConst: true,
132+
detectObjects: false,
133+
},
134+
],
135+
80136
// Replace Airbnb 'no-unused-vars' rule with '@typescript-eslint' version
81137
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
82138
"no-unused-vars": "off",
@@ -85,6 +141,39 @@ module.exports = {
85141
{ vars: "all", args: "after-used", ignoreRestSiblings: true },
86142
],
87143

144+
// Replace Airbnb 'no-use-before-define' rule with '@typescript-eslint' version
145+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
146+
"no-use-before-define": "off",
147+
"@typescript-eslint/no-use-before-define": [
148+
"error",
149+
{ functions: true, classes: true, variables: true },
150+
],
151+
152+
// Replace Airbnb 'no-useless-constructor' rule with '@typescript-eslint' version
153+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
154+
"no-useless-constructor": "off",
155+
"@typescript-eslint/no-useless-constructor": "error",
156+
157+
// Replace Airbnb 'semi' rule with '@typescript-eslint' version
158+
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
159+
semi: "off",
160+
"@typescript-eslint/semi": ["error", "always"],
161+
162+
// Append `ts` and `tsx` to Airbnb 'import/extensions' rule
163+
// Ensure consistent use of file extension within the import path
164+
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
165+
"import/extensions": [
166+
"error",
167+
"ignorePackages",
168+
{
169+
js: "never",
170+
mjs: "never",
171+
jsx: "never",
172+
ts: "never",
173+
tsx: "never",
174+
},
175+
],
176+
88177
// Append `ts` and `tsx` extensions to Airbnb 'import/no-extraneous-dependencies' rule
89178
// Forbid the use of extraneous packages
90179
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
@@ -116,25 +205,5 @@ module.exports = {
116205
optionalDependencies: false,
117206
},
118207
],
119-
120-
// Append `ts` and `tsx` to Airbnb 'import/extensions' rule
121-
// Ensure consistent use of file extension within the import path
122-
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
123-
"import/extensions": [
124-
"error",
125-
"ignorePackages",
126-
{
127-
js: "never",
128-
mjs: "never",
129-
jsx: "never",
130-
ts: "never",
131-
tsx: "never",
132-
},
133-
],
134-
135-
// Replace Airbnb 'semi' rule with '@typescript-eslint' version
136-
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
137-
semi: "off",
138-
"@typescript-eslint/semi": ["error", "always"],
139208
},
140209
}

lint-staged.config.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
module.exports = {
2-
linters: {
3-
"package.json": ["npm run format:package", "git add"],
4-
".editorconfig": ["prettier --write", "git add"],
5-
LICENSE: ["prettier --write", "git add"],
6-
"**/*.{json,md,yml}": ["prettier --write", "git add"],
7-
"**/*.js": ["prettier --write", "eslint --cache --fix", "git add"],
8-
},
9-
// The formatting tools are ordered to run sequentially
10-
concurrent: false,
2+
"**/*.{json,md,yml}": ["prettier --write", "git add"],
3+
"**/*.js": ["prettier --write", "eslint --cache --fix", "git add"],
4+
".editorconfig": ["prettier --write", "git add"],
5+
LICENSE: ["prettier --write", "git add"],
6+
"package.json": ["prettier --write", "npm run format:package", "git add"],
117
}

0 commit comments

Comments
 (0)