diff --git a/.eslintrc.js b/.eslintrc.js index 708332e5..55097724 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,16 +9,181 @@ module.exports = { project: 'tsconfig.eslint.json', sourceType: 'module', }, + plugins: ['eslint-plugin-import', 'eslint-plugin-jsdoc', 'eslint-plugin-prefer-arrow', '@typescript-eslint'], rules: { - 'comma-dangle': ['error', 'always-multiline'], 'jest/expect-expect': [ 'error', { - assertFunctionNames: ['expect*', 'verify'], + assertFunctionNames: ['expect*', 'verify*'], }, ], + '@typescript-eslint/adjacent-overload-signatures': 'error', + '@typescript-eslint/array-type': [ + 'error', + { + default: 'array', + }, + ], + '@typescript-eslint/dot-notation': 'error', + '@typescript-eslint/member-delimiter-style': [ + 'error', + { + multiline: { + delimiter: 'semi', + requireLast: true, + }, + singleline: { + delimiter: 'semi', + requireLast: false, + }, + }, + ], + '@typescript-eslint/naming-convention': [ + 'error', + { + selector: 'default', + format: ['camelCase'], + leadingUnderscore: 'allow', + trailingUnderscore: 'forbid', + }, + { + selector: 'variable', + format: ['camelCase', 'UPPER_CASE'], + leadingUnderscore: 'allow', + trailingUnderscore: 'forbid', + }, + { + selector: 'enumMember', + format: ['camelCase', 'UPPER_CASE'], + }, + { + selector: 'typeLike', + format: ['PascalCase'], + }, + ], + '@typescript-eslint/no-empty-function': 'error', + '@typescript-eslint/no-empty-interface': 'error', + '@typescript-eslint/no-explicit-any': 'error', + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/no-for-in-array': 'error', + '@typescript-eslint/no-misused-new': 'error', + '@typescript-eslint/no-namespace': 'error', + '@typescript-eslint/no-parameter-properties': 'off', + '@typescript-eslint/no-this-alias': 'error', + '@typescript-eslint/no-unnecessary-qualifier': 'error', + '@typescript-eslint/no-unnecessary-type-arguments': 'error', + '@typescript-eslint/no-unnecessary-type-assertion': 'error', + '@typescript-eslint/no-unused-expressions': 'error', + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/no-var-requires': 'error', + '@typescript-eslint/prefer-for-of': 'error', + '@typescript-eslint/prefer-function-type': 'error', + '@typescript-eslint/prefer-namespace-keyword': 'error', + '@typescript-eslint/prefer-readonly': 'error', + '@typescript-eslint/promise-function-async': 'error', + '@typescript-eslint/quotes': 'off', + '@typescript-eslint/restrict-plus-operands': 'error', + '@typescript-eslint/no-unnecessary-condition': 'error', + '@typescript-eslint/semi': ['off', null], + '@typescript-eslint/strict-boolean-expressions': [ + 'error', + { + allowNullableObject: true, + allowNullableBoolean: false, + allowNullableString: false, + }, + ], + '@typescript-eslint/triple-slash-reference': [ + 'error', + { + path: 'always', + types: 'prefer-import', + lib: 'always', + }, + ], + '@typescript-eslint/type-annotation-spacing': 'error', + '@typescript-eslint/unified-signatures': 'error', + 'arrow-parens': ['error', 'always'], + 'brace-style': ['off', 'off'], + 'comma-dangle': 'off', + complexity: 'off', + 'constructor-super': 'error', + 'eol-last': 'off', + eqeqeq: ['error', 'smart'], + 'guard-for-in': 'error', + 'id-blacklist': [ + 'error', + 'any', + 'Number', + 'number', + 'String', + 'string', + 'Boolean', + 'boolean', + 'Undefined', + 'undefined', + ], + 'id-match': 'error', + 'import/no-deprecated': 'error', + 'import/no-extraneous-dependencies': 'off', + 'import/no-internal-modules': 'off', + 'import/order': 'off', + 'jsdoc/check-alignment': 'error', + 'jsdoc/check-indentation': 'error', + 'jsdoc/newline-after-description': 'error', + 'linebreak-style': 'off', + 'max-classes-per-file': 'off', + 'max-len': 'off', + 'new-parens': 'off', + 'newline-per-chained-call': 'off', + 'no-bitwise': 'error', + 'no-caller': 'error', + 'no-cond-assign': 'error', + 'no-console': 'error', + 'no-debugger': 'error', + 'no-duplicate-case': 'error', + 'no-duplicate-imports': 'error', + 'no-empty': 'error', + 'no-eval': 'error', + 'no-extra-bind': 'error', + 'no-extra-semi': 'off', + 'no-fallthrough': 'off', + 'no-invalid-this': 'off', + 'no-irregular-whitespace': 'off', + 'no-multiple-empty-lines': 'off', + 'no-new-func': 'error', + 'no-new-wrappers': 'error', + 'no-redeclare': 'error', + 'no-return-await': 'error', + 'no-sequences': 'error', + 'no-sparse-arrays': 'error', + 'no-template-curly-in-string': 'error', + 'no-throw-literal': 'error', + 'no-trailing-spaces': 'off', + 'no-undef-init': 'error', + 'no-unsafe-finally': 'error', + 'no-unused-labels': 'error', + 'no-var': 'error', + 'no-void': 'error', + 'object-shorthand': 'error', + 'one-var': ['error', 'never'], 'prefer-const': 'error', - '@typescript-eslint/strict-boolean-expressions': 'off', + 'quote-props': 'off', + radix: 'error', + 'react/jsx-curly-spacing': 'off', + 'react/jsx-equals-spacing': 'off', + 'react/jsx-wrap-multilines': 'off', + 'space-before-function-paren': 'off', + 'space-in-parens': ['off', 'never'], + 'spaced-comment': [ + 'error', + 'always', + { + markers: ['/'], + }, + ], + 'use-isnan': 'error', + 'valid-typeof': 'off', }, ignorePatterns: ['dist', 'tsconfig.json', 'tsconfig.eslint.json'], }; diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..53c37a16 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/package.json b/package.json index 0abd3e76..d76bf3b2 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "test": "jest --detectOpenHandles --forceExit", "test:unit": "npm run test \"^((?!\\.integration\\.).)*$\"", "test:integration": "npm run test integration", - "lint": "prettier --check \"**/*.{ts,tsx}\" --ignore-path \".gitignore\" && eslint .", - "format": "prettier --write \"**/*.{ts,tsx}\" --ignore-path \".gitignore\" && eslint . --fix" + "lint": "prettier --check \"**/*.ts\" && eslint \"**/*.{ts,js,json}\"", + "format": "prettier --write \"**/*.ts\" && eslint \"**/*.{ts,js,json}\"" }, "dependencies": { "human-interval": "2.0.1", diff --git a/test/connect.integration.spec.ts b/test/connect.integration.spec.ts index 18e7e5df..9aa8516a 100644 --- a/test/connect.integration.spec.ts +++ b/test/connect.integration.spec.ts @@ -11,7 +11,7 @@ describe('connect', () => { url = await mongo.getUri(); }); - afterAll(async () => await mongo.stop()); + afterAll(async () => mongo.stop()); it('connects mongo', async () => { await connect({ url }); diff --git a/tsconfig.json b/tsconfig.json index e8ffc83e..b0e7fa7c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "moduleResolution": "node", "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, + "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, "outDir": "dist",