Skip to content

Commit

Permalink
feat: upgrade to eslint 7
Browse files Browse the repository at this point in the history
BREAKING CHANGE: require `eslint` 7 or higher
BREAKING CHANGE: require `prettier` 2 or higher
BREAKING CHANGE: require `@typescript-eslint` 4 or higher
BREAKING CHANGE: require `eslint-plugin-jest` 24 or higher
BREAKING CHANGE: require `eslint-plugin-jest-formatting` 2 or higher
BREAKING CHANGE: require `eslint-plugin-flowtype` 5 or higher
BREAKING CHANGE: require `eslint-plugin-node`
  • Loading branch information
G-Rath committed Sep 8, 2020
1 parent 16b0fbe commit 44b916d
Show file tree
Hide file tree
Showing 8 changed files with 542 additions and 359 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const config = {
rules: {
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-namespace': 'off',
'no-sync': 'off'
'node/no-sync': 'off'
}
};

Expand Down
33 changes: 10 additions & 23 deletions @typescript-eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const config = {
parserOptions: { sourceType: 'module' },
plugins: ['@typescript-eslint'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier/@typescript-eslint'
],
rules: {
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/default-param-last': 'error',
'@typescript-eslint/explicit-member-accessibility': 'error',
Expand Down Expand Up @@ -65,9 +65,8 @@ const config = {
}
],
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-namespace': [
'off', // todo: need to audit existing codebase to see if declare is fine
{
Expand All @@ -76,20 +75,14 @@ const config = {
}
],
'@typescript-eslint/no-parameter-properties': 'error',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-shadow': 'warn',
'@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true }],
'@typescript-eslint/no-throw-literal': 'error',
'@typescript-eslint/no-unnecessary-condition': [
'error',
// todo: remove once https://github.com/typescript-eslint/typescript-eslint/pull/1163 is merged
{ ignoreRhs: true }
],
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-type-arguments': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-use-before-define': [
Expand All @@ -99,30 +92,21 @@ const config = {
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-regexp-exec': 'warn',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-array-sort-compare': 'warn',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowBoolean: true,
allowNumber: true
}
],
// yes: with types, this is actually useful and correct
'@typescript-eslint/return-await': 'error',
'@typescript-eslint/unbound-method': 'warn', // can be a bit wrong
'@typescript-eslint/unified-signatures': 'warn', // can be a bit wrong

'array-callback-return': 'off',
'block-scoped-var': 'off',
'camelcase': 'off',
'consistent-return': 'off', // via --noImplicitReturns
'default-param-last': 'off',
'guard-for-in': 'off',
Expand All @@ -131,11 +115,14 @@ const config = {
'no-import-assign': 'off',
'no-invalid-this': 'off',
'no-iterator': 'off',
'no-loop-func': 'off', // @typescript-eslint
'no-proto': 'off', // TS2339
'no-setter-return': 'off', // TS2408
'no-shadow': 'off', // @typescript-eslint
'no-throw-literal': 'off', // @typescript-eslint
'no-underscore-dangle': 'off',
'no-unused-expressions': 'off',
'no-use-before-define': 'off',
'no-useless-constructor': 'off', // @typescript-eslint
'strict': 'off' // via --alwaysStrict
}
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Standard ESLint configurations for Ackama projects.

Install this package & the required plugins:

npm install --save-dev eslint-config-ackama @types/eslint eslint eslint-plugin-eslint-comments eslint-plugin-prettier eslint-plugin-import prettier
npm install --save-dev eslint-config-ackama @types/eslint eslint eslint-plugin-eslint-comments eslint-plugin-prettier eslint-plugin-import eslint-plugin-node prettier

Add an `.eslintrc.js` to your repo that extends from this config:

Expand Down Expand Up @@ -64,9 +64,10 @@ Below is a complete list of the configs provided, and their dependencies:
<!-- begin configs list -->

- `ackama`
- `eslint-plugin-import`
- `eslint-plugin-prettier`
- `eslint-plugin-eslint-comments`
- `eslint-plugin-prettier`
- `eslint-plugin-import`
- `eslint-plugin-node`
- `ackama/@typescript-eslint`
- `@typescript-eslint/eslint-plugin`
- `@typescript-eslint/parser`
Expand Down
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
const config = {
env: { es2017: true },
plugins: [
'import',
'eslint-comments',
'prettier', //
'eslint-comments'
'import',
'node'
],
extends: [
'eslint:recommended',
Expand Down Expand Up @@ -42,10 +43,17 @@ const config = {
'newlines-between': 'never'
}
],
'node/callback-return': 'warn',
'node/global-require': 'error',
'node/no-deprecated-api': 'error',
'node/no-mixed-requires': 'error',
'node/no-new-require': 'error',
'node/no-path-concat': 'error',
'node/no-process-exit': 'error',
'node/no-sync': 'warn',
'accessor-pairs': ['error', { enforceForClassMembers: true }],
'array-callback-return': 'error',
'block-scoped-var': 'warn',
'callback-return': 'warn',
'camelcase': ['error', { allow: ['child_process'] }],
'consistent-return': 'error',
'consistent-this': 'error',
Expand All @@ -55,7 +63,6 @@ const config = {
'dot-notation': 'error',
'eqeqeq': 'error',
'func-names': ['error', 'as-needed'],
'global-require': 'error',
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
'guard-for-in': 'error',
'init-declarations': 'error',
Expand All @@ -71,11 +78,9 @@ const config = {
'no-array-constructor': 'error',
'no-await-in-loop': 'error',
'no-bitwise': 'error',
'no-buffer-constructor': 'error',
'no-caller': 'error',
'no-constructor-return': 'error',
'no-dupe-else-if': 'error',
// 'no-duplicate-imports': 'error', // todo: enable once https://github.com/eslint/eslint/issues/12758 is resolved
'no-else-return': 'error',
'no-empty-function': 'error',
'no-eq-null': 'error',
Expand All @@ -93,20 +98,16 @@ const config = {
'no-lone-blocks': 'error',
'no-lonely-if': 'error',
'no-loop-func': 'error',
'no-mixed-requires': 'error',
'no-multi-assign': 'error',
'no-multi-str': 'error',
'no-nested-ternary': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-require': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-param-reassign': 'error',
'no-path-concat': 'error',
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'no-process-exit': 'error',
'no-proto': 'error',
'no-return-assign': 'error',
'no-return-await': 'error',
Expand All @@ -115,7 +116,6 @@ const config = {
'no-sequences': 'error',
'no-setter-return': 'error',
'no-shadow': 'warn',
'no-sync': 'warn',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-undef-init': 'error',
Expand Down
Loading

0 comments on commit 44b916d

Please sign in to comment.