Skip to content

Commit

Permalink
fix: re-order rules (#32)
Browse files Browse the repository at this point in the history
* fix: re-order rules

* Create quiet-ducks-complain.md
  • Loading branch information
roikoren755 authored Jun 27, 2021
1 parent e88bd50 commit dfa78e1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-ducks-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-config-altnext": patch
---

fix: put rules in right configuration
29 changes: 1 addition & 28 deletions src/configs/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,25 +124,11 @@ const base: Linter.Config = {
'@typescript-eslint/consistent-type-definitions': ERROR,
'@typescript-eslint/consistent-type-imports': ERROR,
'@typescript-eslint/class-literal-property-style': ERROR,
'@typescript-eslint/dot-notation': ERROR,
'@typescript-eslint/default-param-last': ERROR,
'@typescript-eslint/explicit-function-return-type': [ERROR, { allowExpressions: true }],
'@typescript-eslint/explicit-member-accessibility': [ERROR, { accessibility: 'no-public' }],
'@typescript-eslint/interface-name-prefix': OFF,
'@typescript-eslint/method-signature-style': [ERROR, 'method'],
'@typescript-eslint/naming-convention': [
ERROR,
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
filter: { regex: '^process\\.env\\.[A-Z][A-Z_]*$', match: false },
},
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'typeAlias', format: ['PascalCase'], custom: { regex: '^I[A-Z]', match: false } },
{ selector: 'interface', format: ['PascalCase'], prefix: ['I'] },
],
'@typescript-eslint/no-empty-function': WARN,
'@typescript-eslint/no-empty-interface': [WARN, { allowSingleExtends: true }],
'@typescript-eslint/no-extra-non-null-assertion': ERROR,
Expand All @@ -152,12 +138,6 @@ const base: Linter.Config = {
'@typescript-eslint/no-parameter-properties': ERROR,
'@typescript-eslint/no-unused-expressions': [ERROR, { allowTernary: true }],
'@typescript-eslint/no-unused-vars': [ERROR, { ignoreRestSiblings: true }],

'@typescript-eslint/no-unsafe-assignment': WARN,
'@typescript-eslint/no-unsafe-call': WARN,
'@typescript-eslint/no-unsafe-member-access': WARN,
'@typescript-eslint/no-unsafe-return': WARN,

'@typescript-eslint/no-use-before-define': WARN,
'@typescript-eslint/no-useless-constructor': ERROR,
'@typescript-eslint/no-var-requires': WARN,
Expand All @@ -166,7 +146,6 @@ const base: Linter.Config = {
'@typescript-eslint/prefer-function-type': ERROR,
'@typescript-eslint/prefer-optional-chain': WARN,
'@typescript-eslint/prefer-ts-expect-error': ERROR,
'@typescript-eslint/require-await': OFF,
'@typescript-eslint/sort-type-union-intersection-members': ERROR,
'@typescript-eslint/unified-signatures': ERROR,

Expand Down Expand Up @@ -314,13 +293,7 @@ const base: Linter.Config = {
{ files: ['./**/*.story.tsx'], rules: { 'no-console': OFF } },
{
files: ['./**/*.spec.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': OFF,
'@typescript-eslint/no-unsafe-return': OFF,
'@typescript-eslint/no-var-requires': OFF,
'@typescript-eslint/unbound-method': OFF,
'unicorn/no-useless-undefined': OFF,
},
rules: { '@typescript-eslint/no-var-requires': OFF, 'unicorn/no-useless-undefined': OFF },
},
],
};
Expand Down
38 changes: 33 additions & 5 deletions src/configs/type-checking.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Linter } from 'eslint';

import { ERROR, WARN } from './consts';
import { ERROR, OFF, WARN } from './consts';

const typeChecking: Linter.Config = {
parserOptions: { ecmaFeatures: { impliedStrict: true, globalReturn: true }, ecmaVersion: 6 },
Expand All @@ -14,26 +14,54 @@ const typeChecking: Linter.Config = {
'import/resolver': { node: { extensions: ['.ts', '.jsx', '.js', '.tsx', '.json'] }, typescript: {} },
jest: { version: 27 },
},
extends: ['./src/configs/base', 'plugin:@typescript-eslint/recommended-requiring-type-checking'],
extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking', './src/configs/base'],
rules: {
'@typescript-eslint/dot-notation': ERROR,
'@typescript-eslint/naming-convention': [
ERROR,
{
selector: 'property',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
leadingUnderscore: 'allow',
filter: { regex: '^process\\.env\\.[A-Z][A-Z_]*$', match: false },
},
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE', 'PascalCase'], leadingUnderscore: 'allow' },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'typeAlias', format: ['PascalCase'], custom: { regex: '^I[A-Z]', match: false } },
{ selector: 'interface', format: ['PascalCase'], prefix: ['I'] },
],
'@typescript-eslint/no-base-to-string': ERROR,
'@typescript-eslint/no-confusing-void-expression': ERROR,
'@typescript-eslint/no-floating-promises': 1,
'@typescript-eslint/no-floating-promises': WARN,
'@typescript-eslint/no-implied-eval': ERROR,
'@typescript-eslint/no-throw-literal': ERROR,
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ERROR,
'@typescript-eslint/no-unnecessary-type-arguments': ERROR,
'@typescript-eslint/no-unsafe-assignment': WARN,
'@typescript-eslint/no-unsafe-call': WARN,
'@typescript-eslint/no-unsafe-member-access': WARN,
'@typescript-eslint/no-unsafe-return': WARN,
'@typescript-eslint/prefer-nullish-coalescing': WARN,
'@typescript-eslint/prefer-readonly': ERROR,
'@typescript-eslint/prefer-reduce-type-parameter': ERROR,
'@typescript-eslint/require-array-sort-compare': ERROR,
'@typescript-eslint/require-await': ERROR,
'@typescript-eslint/restrict-template-expressions': WARN,
'@typescript-eslint/return-await': [ERROR, 'in-try-catch'],
'@typescript-eslint/switch-exhaustiveness-check': ERROR,
'@typescript-eslint/unbound-method': WARN,
'@typescript-eslint/require-await': ERROR,
},
overrides: [{ files: ['./**/{__mocks__,__tests__}/*.ts{x,}'], rules: { '@typescript-eslint/require-await': 1 } }],
overrides: [
{ files: ['./**/{__mocks__,__tests__}/*.ts{x,}'], rules: { '@typescript-eslint/require-await': WARN } },
{
files: ['./**/*.spec.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': OFF,
'@typescript-eslint/no-unsafe-return': OFF,
'@typescript-eslint/unbound-method': OFF,
},
},
],
};

export = typeChecking;

0 comments on commit dfa78e1

Please sign in to comment.