Skip to content

Commit

Permalink
Support for @typescript-eslint/*@6.x.x (#669)
Browse files Browse the repository at this point in the history
* Closes Support for @typescript-eslint/*@6.x.x #665

* Consolidate to managed rulesets

* unicorn 48

* Bump 📦 to pick up fix for linting package
  • Loading branch information
tclindner committed Jul 25, 2023
1 parent a019ff6 commit 74792e1
Show file tree
Hide file tree
Showing 8 changed files with 4,086 additions and 11,325 deletions.
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['eslint-config-tc', './index.js'],
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
};
6 changes: 0 additions & 6 deletions .eslintrc.json

This file was deleted.

30 changes: 18 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[![license](https://img.shields.io/github/license/tclindner/eslint-config-typescript-tc.svg?maxAge=2592000&style=flat-square)](https://github.com/tclindner/eslint-config-typescript-tc/blob/main/LICENSE)
[![npm](https://img.shields.io/npm/v/eslint-config-typescript-tc.svg?maxAge=2592000?style=flat-square)](https://www.npmjs.com/package/eslint-config-typescript-tc)
![ci](https://github.com/tclindner/eslint-config-typescript-tc/workflows/ci/badge.svg?branch=main)
[![Dependency Status](https://david-dm.org/tclindner/eslint-config-typescript-tc.svg?style=flat-square)](https://david-dm.org/tclindner/eslint-config-typescript-tc)
[![devDependency Status](https://david-dm.org/tclindner/eslint-config-typescript-tc/dev-status.svg?style=flat-square)](https://david-dm.org/tclindner/eslint-config-typescript-tc#info=devDependencies)

## What is eslint-config-typescript-tc?

Expand Down Expand Up @@ -35,23 +33,31 @@ npx install-peerdeps --dev eslint-config-typescript-tc

## Usage

Add the following to your `.eslintrc.json` file:
Add the following to your `.eslintrc.js` file:

```json
{
"extends": "eslint-config-typescript-tc"
}
```js
module.exports = {
extends: ['eslint-config-tc', 'eslint-config-typescript-tc'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
};
```

If you need to override a rule, your `.eslintrc.json` file should look like the example below. All shared rules will be used, but `@typescript-eslint/array-type` will be turned off.
If you need to override a rule, your `.eslintrc.js` file should look like the example below. All shared rules will be used, but `@typescript-eslint/array-type` will be turned off.

```json
{
"extends": "eslint-config-typescript-tc",
```js
module.exports = {
extends: ['eslint-config-tc', 'eslint-config-typescript-tc'],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
},
"rules": {
"@typescript-eslint/array-type": "off"
}
}
};
```

## Related
Expand Down
64 changes: 8 additions & 56 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
module.exports = {
extends: ['plugin:@typescript-eslint/recommended', 'eslint-config-prettier'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:@typescript-eslint/strict',
'eslint-config-prettier',
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
settings: {
Expand All @@ -16,21 +21,8 @@ module.exports = {
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
},
rules: {
// @typescript-eslint rules
// -----------------------------

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/array-type.md
'@typescript-eslint/array-type': ['error', {default: 'array'}],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/consistent-type-definitions.md
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/explicit-function-return-type.md
// disable the rule for all files, see overrides below.
'@typescript-eslint/explicit-function-return-type': 'off',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/method-signature-style.md
'@typescript-eslint/method-signature-style': 'error',
// @typescript-eslint overrides that work better than ESLint.
// The base rule needs to be disabled to prevent false positives.

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md
camelcase: 'off',
Expand Down Expand Up @@ -60,38 +52,10 @@ module.exports = {
},
],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-dynamic-delete.md
'@typescript-eslint/no-dynamic-delete': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-explicit-any.md
'@typescript-eslint/no-explicit-any': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-enum-initializers.md
'@typescript-eslint/prefer-enum-initializers': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-optional-chain.md
'@typescript-eslint/prefer-optional-chain': 'error',

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-ts-expect-error.md
'@typescript-eslint/prefer-ts-expect-error': 'error',

// @typescript-eslint overrides
// that work better than ESLint
// The base rule needs to be disabled to prevent false positives.
// -----------------------------

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-between-class-members.md
'lines-between-class-members': 'off',
'@typescript-eslint/lines-between-class-members': ['error'],

// 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': ['error'],

// 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'],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loop-func.md
'no-loop-func': 'off',
'@typescript-eslint/no-loop-func': 'error',
Expand All @@ -104,10 +68,6 @@ module.exports = {
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
'no-array-constructor': 'off',
'@typescript-eslint/no-array-constructor': ['error'],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-expressions.md
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': ['error'],
Expand All @@ -116,14 +76,6 @@ module.exports = {
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],

// 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'],

// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': 'error',

// Override Airbnb 'import/extensions' rule. Add 'ts' and 'tsx'.
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
'import/extensions': [
Expand Down
Loading

0 comments on commit 74792e1

Please sign in to comment.