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

Commit

Permalink
chore: Update to latest @typescript-eslint (#63)
Browse files Browse the repository at this point in the history
Includes support for latest TypeScript version.

BREAKING CHANGE: You must set parserOptions.project within your ESLint config file. You must upgrade your local dependency of @typescript-eslint/eslint-plugin to 2.19.0. For more details, see PR #63.
  • Loading branch information
iamturns committed Feb 9, 2020
1 parent 0584b7d commit faf7a74
Show file tree
Hide file tree
Showing 6 changed files with 550 additions and 707 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
module.exports = {
extends: ['./base.js', 'prettier', 'prettier/@typescript-eslint'],
parserOptions: {
project: './tsconfig.json',
},
};
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm install eslint-config-airbnb-typescript \
eslint-plugin-jsx-a11y@^6.2.3 \
eslint-plugin-react@^7.15.1 \
eslint-plugin-react-hooks@^1.7.0 \
@typescript-eslint/eslint-plugin@^2.7.0 \
@typescript-eslint/eslint-plugin@^2.19.0 \
--save-dev
```

Expand All @@ -23,6 +23,9 @@ Within your ESLint config file:
```js
module.exports = {
extends: ['airbnb-typescript'],
parserOptions: {
project: './tsconfig.json',
},
};
```

Expand All @@ -39,7 +42,7 @@ Install dependencies. ESLint plugins [must also be installed](https://github.com
```bash
npm install eslint-config-airbnb-typescript \
eslint-plugin-import@^2.18.2 \
@typescript-eslint/eslint-plugin@^2.7.0 \
@typescript-eslint/eslint-plugin@^2.19.0 \
--save-dev
```

Expand All @@ -48,6 +51,9 @@ Within your ESLint config file:
```js
module.exports = {
extends: ['airbnb-typescript/base'],
parserOptions: {
project: './tsconfig.json',
},
};
```

Expand Down
35 changes: 30 additions & 5 deletions lib/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ module.exports = {
camelcase: 'off',
'@typescript-eslint/camelcase': baseStyleRules.camelcase,

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

// 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',
Expand All @@ -48,6 +53,11 @@ module.exports = {
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': baseStyleRules['no-array-constructor'],

// Replace Airbnb 'no-dupe-class-members' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dupe-class-members.md
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': baseES6Rules['no-dupe-class-members'],

// Replace Airbnb 'no-empty-function' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-empty-function.md
'no-empty-function': 'off',
Expand All @@ -58,11 +68,26 @@ module.exports = {
'no-extra-parens': 'off',
'@typescript-eslint/no-extra-parens': baseErrorsRules['no-extra-parens'],

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

// Replace Airbnb 'no-implied-eval' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': baseBestPracticesRules['no-implied-eval'],

// Replace Airbnb 'no-magic-numbers' rule with '@typescript-eslint' 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': baseBestPracticesRules['no-magic-numbers'],

// Replace Airbnb 'no-throw-literal' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': baseBestPracticesRules['no-throw-literal'],

// Replace Airbnb 'no-unused-expressions' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
'no-unused-expressions': 'off',
Expand Down Expand Up @@ -93,6 +118,11 @@ module.exports = {
semi: 'off',
'@typescript-eslint/semi': baseStyleRules.semi,

// Replace Airbnb 'space-before-function-paren' rule with '@typescript-eslint' version
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/space-before-function-paren.md
'space-before-function-paren': 'off',
'@typescript-eslint/space-before-function-paren': baseStyleRules['space-before-function-paren'],

// Append 'ts' and 'tsx' to Airbnb 'import/extensions' rule
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': [
Expand Down Expand Up @@ -125,11 +155,6 @@ module.exports = {
// https://github.com/iamturns/eslint-config-airbnb-typescript/issues/50
// This will be caught by TypeScript compiler if `strictNullChecks` (or `strict`) is enabled
'no-undef': 'off',

// Disable `no-dupe-class-members` rule within TypeScript files beause it incorrectly errors when overloading methods
// https://github.com/iamturns/eslint-config-airbnb-typescript/issues/61
// Duplicate identifiers will be caught by TypeScript compiler
'no-dupe-class-members': 'off',
},
},
],
Expand Down
Loading

0 comments on commit faf7a74

Please sign in to comment.