Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
feat: Update dependencies, support ESLint v6 (#17)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
iamturns authored Sep 19, 2019
1 parent bb144f0 commit 70e86f9
Show file tree
Hide file tree
Showing 5 changed files with 799 additions and 1,578 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ Install dependencies. ESLint plugins [must also be installed](https://github.com

```bash
npm install eslint-config-airbnb-typescript \
eslint-plugin-import@^2.14.0 \
eslint-plugin-jsx-a11y@^6.1.1 \
eslint-plugin-react@^7.11.0 \
@typescript-eslint/eslint-plugin@^1.11.0 \
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
```

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

```bash
npm install eslint-config-airbnb-typescript \
eslint-plugin-import@^2.14.0 \
@typescript-eslint/eslint-plugin@^1.11.0 \
eslint-plugin-import@^2.18.2 \
@typescript-eslint/eslint-plugin@^2.3.0 \
--save-dev
```

Expand Down
111 changes: 90 additions & 21 deletions lib/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,30 @@ module.exports = {
},
],

// Replace Airbnb 'brace-style' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
"brace-style": "off",
"@typescript-eslint/brace-style": [
"error",
"1tbs",
{ allowSingleLine: true },
],

// Replace Airbnb 'camelcase' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/camelcase.md
camelcase: "off",
"@typescript-eslint/camelcase": ["error", { properties: "never" }],
"@typescript-eslint/camelcase": [
"error",
{ properties: "never", ignoreDestructuring: false },
],

// Replace Airbnb 'func-call-spacing' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/func-call-spacing.md
"func-call-spacing": "off",
"@typescript-eslint/func-call-spacing": ["error", "never"],

// Replace Airbnb 'indent' rule with '@typescript-indent' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/indent.md
indent: "off",
"@typescript-eslint/indent": [
"error",
Expand Down Expand Up @@ -77,6 +95,44 @@ module.exports = {
"no-array-constructor": "off",
"@typescript-eslint/no-array-constructor": "error",

// Replace Airbnb 'no-empty-function' rule with '@typescript-indent' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
"no-empty-function": "off",
"@typescript-eslint/no-empty-function": [
"error",
{
allow: ["arrowFunctions", "functions", "methods"],
},
],

// Replace Airbnb 'no-extra-parens' rule with '@typescript-indent' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-extra-parens.md
"no-extra-parens": "off",
"@typescript-eslint/no-extra-parens": [
"off",
"all",
{
conditionalAssign: true,
nestedBinaryExpressions: false,
returnAssign: false,
ignoreJSX: "all", // delegate to eslint-plugin-react
enforceForArrowConditionals: false,
},
],

// Replace Airbnb 'no-magic-numbers' rule with '@typescript-indent' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-magic-numbers.md
"no-magic-numbers": "off",
"@typescript-eslint/no-magic-numbers": [
"off",
{
ignore: [],
ignoreArrayIndexes: true,
enforceConst: true,
detectObjects: false,
},
],

// Replace Airbnb 'no-unused-vars' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
"no-unused-vars": "off",
Expand All @@ -85,6 +141,39 @@ module.exports = {
{ vars: "all", args: "after-used", ignoreRestSiblings: true },
],

// Replace Airbnb 'no-use-before-define' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-use-before-define.md
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": [
"error",
{ functions: true, classes: true, variables: true },
],

// Replace Airbnb 'no-useless-constructor' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-useless-constructor.md
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",

// Replace Airbnb 'semi' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
semi: "off",
"@typescript-eslint/semi": ["error", "always"],

// Append `ts` and `tsx` to Airbnb 'import/extensions' rule
// Ensure consistent use of file extension within the import path
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
mjs: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],

// Append `ts` and `tsx` extensions to Airbnb 'import/no-extraneous-dependencies' rule
// Forbid the use of extraneous packages
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
Expand Down Expand Up @@ -116,25 +205,5 @@ module.exports = {
optionalDependencies: false,
},
],

// Append `ts` and `tsx` to Airbnb 'import/extensions' rule
// Ensure consistent use of file extension within the import path
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
mjs: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],

// Replace Airbnb 'semi' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/semi.md
semi: "off",
"@typescript-eslint/semi": ["error", "always"],
},
}
14 changes: 5 additions & 9 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module.exports = {
linters: {
"package.json": ["npm run format:package", "git add"],
".editorconfig": ["prettier --write", "git add"],
LICENSE: ["prettier --write", "git add"],
"**/*.{json,md,yml}": ["prettier --write", "git add"],
"**/*.js": ["prettier --write", "eslint --cache --fix", "git add"],
},
// The formatting tools are ordered to run sequentially
concurrent: false,
"**/*.{json,md,yml}": ["prettier --write", "git add"],
"**/*.js": ["prettier --write", "eslint --cache --fix", "git add"],
".editorconfig": ["prettier --write", "git add"],
LICENSE: ["prettier --write", "git add"],
"package.json": ["prettier --write", "npm run format:package", "git add"],
}
Loading

0 comments on commit 70e86f9

Please sign in to comment.