diff --git a/.eslintignore b/.eslintignore index d079d1063..b512c09d4 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1 @@ -# builtin file has a lot of formatting issues -builtin.ts - -src/**/*.spec.ts - -src/test-helpers.ts \ No newline at end of file +node_modules \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js index e68809a48..8c31ae633 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,1280 +1,63 @@ module.exports = { - "env": { - "es6": true, - "node": true, - }, - "extends": [ - "airbnb-typescript/base", - // "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - // "plugin:@typescript-eslint/eslint-recommended" - // 'plugin:import/errors', - // 'plugin:import/warnings', - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.eslint.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/naming-convention": [ - "error", - // custom rule to ignore cases that require quoting - { - "selector": "property", - "format": ["camelCase", "UPPER_CASE"], - "leadingUnderscore": "allow", - "filter": { - // you can expand this regex as you find more cases that require quoting that you want to allow - "regex": "[_ ]", - "match": false - } - } - ], - "@typescript-eslint/consistent-type-assertions": "error", - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/dot-notation": "warn", - "@typescript-eslint/explicit-member-accessibility": [ - "error", - { - "accessibility": "explicit" - } - ], - "@typescript-eslint/indent": [ - "off", - 2, - { - "CallExpression": { - "arguments": "first" - }, - "ArrayExpression": "first", - "ObjectExpression": "first", - "FunctionDeclaration": { - "parameters": "first" - }, - "FunctionExpression": { - "parameters": "first" - } - } - ], - "@typescript-eslint/member-delimiter-style": [ - "error", - { - "multiline": { - "delimiter": "semi", - "requireLast": true - }, - "singleline": { - "delimiter": "semi", - "requireLast": false - } - } - ], - "@typescript-eslint/no-empty-function": "error", - "@typescript-eslint/no-dynamic-delete" : "error", - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/no-for-in-array": "error", - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/no-this-alias": "error", - "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", - "@typescript-eslint/no-unused-expressions": "error", - "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/prefer-regexp-exec" : "off", - "@typescript-eslint/quotes": [ - "error", - "single", - { - "avoidEscape": true - } - ], - "@typescript-eslint/semi": [ - "error", - "always" - ], - "@typescript-eslint/strict-boolean-expressions": "error", - // Equivalent of typedef in TSLint - "@typescript-eslint/explicit-function-return-type": "error", - "@typescript-eslint/type-annotation-spacing": "error", - "accessor-pairs": "off", - "array-bracket-newline": [ - "off", - "consistent" - ], - "array-bracket-spacing": [ - "error", - "never" - ], - "array-callback-return": [ - "error", - { - "allowImplicit": true, - "checkForEach": false - } - ], - "array-element-newline": [ - "off", - { - "multiline": true, - "minItems": 3 - } - ], - "arrow-body-style": [ - "error", - "as-needed", - { - "requireReturnForObjectLiteral": false - } - ], - "arrow-parens": [ - "off", - "always" - ], - "arrow-spacing": [ - "error", - { - "before": true, - "after": true - } - ], - "block-scoped-var": "error", - "block-spacing": [ - "error", - "always" - ], - "brace-style": [ - "error", - "1tbs" - ], - "callback-return": "off", - "camelcase": "off", - "capitalized-comments": [ - "off", - "never", - { - "line": { - "ignorePattern": ".*", - "ignoreInlineComments": true, - "ignoreConsecutiveComments": true - }, - "block": { - "ignorePattern": ".*", - "ignoreInlineComments": true, - "ignoreConsecutiveComments": true - } - } - ], - "class-methods-use-this": [ - "error", - { - "exceptMethods": [] - } - ], - "comma-dangle": [ - "error", - "always-multiline" - ], - "comma-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "comma-style": [ - "error", - "last", - { - "exceptions": { - "ArrayExpression": false, - "ArrayPattern": false, - "ArrowFunctionExpression": false, - "CallExpression": false, - "FunctionDeclaration": false, - "FunctionExpression": false, - "ImportDeclaration": false, - "ObjectExpression": false, - "ObjectPattern": false, - "VariableDeclaration": false, - "NewExpression": false - } - } - ], - "complexity": [ - "off", - 11 - ], - "computed-property-spacing": [ - "error", - "never" - ], - "consistent-return": "error", - "consistent-this": "off", - "constructor-super": "error", - "curly": [ - "error", - "multi-line" - ], - "default-case": [ - "error", - { - "commentPattern": "^no default$" - } - ], - "default-case-last": "off", - "default-param-last": "off", - "dot-location": [ - "error", - "property" - ], - "eol-last": "error", - "eqeqeq": [ - "error", - "smart" - ], - "for-direction": "error", - "func-call-spacing": [ - "error", - "never" - ], - "func-name-matching": [ - "off", - "always", - { - "includeCommonJSModuleExports": false, - "considerPropertyDescriptor": true - } - ], - "func-names": "warn", - "func-style": [ - "off", - "expression" - ], - "function-call-argument-newline": [ - "off", - "consistent" - ], - "function-paren-newline": [ - "error", - "consistent" - ], - "generator-star-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "getter-return": [ - "error", - { - "allowImplicit": true - } - ], - "global-require": "error", - "grouped-accessor-pairs": "off", - "guard-for-in": "error", - "handle-callback-err": "off", - "id-blacklist": [ - "error", - "any", - "Number", - "number", - "String", - "string", - "Boolean", - "boolean", - "Undefined", - "undefined" - ], - "id-length": "off", - "id-match": "error", - "implicit-arrow-linebreak": [ - "error", - "beside" - ], - "import/default": "off", - "import/dynamic-import-chunkname": [ - "off", - { - "importFunctions": [], - "webpackChunknameFormat": "[0-9a-zA-Z-_/.]+" - } - ], - "import/export": "error", - "import/exports-last": "off", - "import/extensions": "off", - // "import/extensions": [ - // "error", - // "ignorePackages", - // { - // "js": "never", - // // "mjs": "never", - // "ts": "never" - // } - // ], - "import/first": "error", - "import/group-exports": "off", - "import/imports-first": "off", - "import/max-dependencies": [ - "off", - { - "max": 10 - } - ], - "import/named": "error", - "import/namespace": "off", - "import/newline-after-import": "error", - "import/no-absolute-path": "error", - "import/no-amd": "error", - "import/no-anonymous-default-export": [ - "off", - { - "allowArray": false, - "allowArrowFunction": false, - "allowAnonymousClass": false, - "allowAnonymousFunction": false, - "allowLiteral": false, - "allowObject": false - } - ], - "import/no-commonjs": "off", - // "import/no-cycle": [ - // "error", - // { - // "maxDepth": null, - // "ignoreExternal": false - // } - // ], - "import/no-default-export": "off", - "import/no-deprecated": "off", - "import/no-duplicates": "error", - "import/no-dynamic-require": "error", - "import/no-extraneous-dependencies": "error", - "import/no-internal-modules": "error", - "import/no-mutable-exports": "error", - "import/no-named-as-default": "error", - "import/no-named-as-default-member": "error", - "import/no-named-default": "error", - "import/no-named-export": "off", - "import/no-namespace": "off", - "import/no-nodejs-modules": "off", - "import/no-relative-parent-imports": "off", - "import/no-restricted-paths": "off", - "import/no-self-import": "error", - "import/no-unassigned-import": "off", - "import/no-unresolved": "off", - "import/no-unused-modules": [ - "off", - { - "ignoreExports": [], - "missingExports": true, - "unusedExports": true - } - ], - "import/no-useless-path-segments": [ - "error", - { - "commonjs": true - } - ], - "import/no-webpack-loader-syntax": "error", - "import/order": [ - "off", - { - "groups": [ - [ - "builtin", - "external", - "internal" - ] - ] - } - ], - "import/prefer-default-export": "off", - "import/unambiguous": "off", - "indent": ["off", 2], - "init-declarations": "off", - // "jsdoc/check-alignment": "error", - // "jsdoc/check-indentation": "error", - // "jsdoc/newline-after-description": "error", - // "jsdoc/no-types": "error", - // "jsx-quotes": [ - // "off", - // "prefer-double" - // ], - "key-spacing": [ - "error", - { - "beforeColon": false, - "afterColon": true - } - ], - "keyword-spacing": [ - "error", - { - "before": true, - "after": true, - "overrides": { - "return": { - "after": true - }, - "throw": { - "after": true - }, - "case": { - "after": true - } - } - } - ], - "line-comment-position": [ - "off", - { - "position": "above", - "ignorePattern": "", - "applyDefaultPatterns": true - } - ], - "linebreak-style": [ - "error", - "unix" - ], - "lines-around-comment": "off", - "lines-around-directive": [ - "error", - { - "before": "always", - "after": "always" - } - ], - "lines-between-class-members": [ - "error", - "always", - { - "exceptAfterSingleLine": false - } - ], - "max-classes-per-file": [ - "error", - 1 - ], - "max-depth": [ - "off", - 4 - ], - "max-len": [ - "error", - { - "code": 120 - } - ], - "max-lines": [ - "off", - { - "max": 300, - "skipBlankLines": true, - "skipComments": true - } - ], - "max-lines-per-function": [ - "off", - { - "max": 50, - "skipBlankLines": true, - "skipComments": true, - "IIFEs": true - } - ], - "max-nested-callbacks": "off", - "max-params": [ - "off", - 3 - ], - "max-statements": [ - "off", - 10 - ], - "max-statements-per-line": [ - "off", - { - "max": 1 - } - ], - "multiline-comment-style": [ - "off", - "starred-block" - ], - "multiline-ternary": [ - "off", - "never" - ], - "new-cap": [ - "error", - { - "newIsCap": true, - "newIsCapExceptions": [], - "capIsNew": false, - "capIsNewExceptions": [ - "Immutable.Map", - "Immutable.Set", - "Immutable.List" - ], - "properties": true - } - ], - "new-parens": "error", - "newline-after-var": "off", - "newline-before-return": "off", - "newline-per-chained-call": [ - "error", - { - "ignoreChainWithDepth": 4 - } - ], - "no-alert": "warn", - "no-array-constructor": "error", - "no-async-promise-executor": "error", - "no-await-in-loop": "error", - "no-bitwise": "error", - "no-buffer-constructor": "error", - "no-caller": "error", - "no-case-declarations": "error", - "no-catch-shadow": "off", - "no-class-assign": "error", - "no-compare-neg-zero": "error", - "no-cond-assign": [ - "error", - "always" - ], - "no-confusing-arrow": [ - "error", - { - "allowParens": true - } - ], - "no-console": "warn", - "no-const-assign": "error", - "no-constant-condition": "warn", - "no-constructor-return": "off", - "no-continue": "error", - "no-control-regex": "error", - "no-debugger": "error", - "no-delete-var": "error", - "no-div-regex": "off", - "no-dupe-args": "error", - "no-dupe-class-members": "error", - "no-dupe-else-if": "off", - "no-dupe-keys": "error", - "no-duplicate-case": "error", - "no-duplicate-imports": "error", - "no-else-return": [ - "error", - { - "allowElseIf": false - } - ], - "no-empty": "error", - "no-empty-character-class": "error", - "no-empty-function": [ - "error", - { - "allow": [ - "arrowFunctions", - "functions", - "methods" - ] - } - ], - "no-empty-pattern": "error", - "no-eq-null": "off", - "no-eval": "error", - "no-ex-assign": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-boolean-cast": "error", - "no-extra-label": "error", - "no-extra-parens": [ - "off", - "all", - { - "conditionalAssign": true, - "nestedBinaryExpressions": false, - "returnAssign": false, - "ignoreJSX": "all", - "enforceForArrowConditionals": false - } - ], - "no-extra-semi": "error", - "no-fallthrough": "error", - "no-floating-decimal": "error", - "no-func-assign": "error", - "no-global-assign": [ - "error", - { - "exceptions": [] - } - ], - "no-implicit-coercion": [ - "off", - { - "boolean": false, - "number": true, - "string": true, - "allow": [] - } - ], - "no-implicit-globals": "off", - "no-implied-eval": "error", - "no-import-assign": "off", - "no-inline-comments": "off", - "no-inner-declarations": "error", - "no-invalid-regexp": "error", - "no-invalid-this": "off", - "no-irregular-whitespace": "error", - "no-iterator": "error", - "no-label-var": "error", - "no-labels": [ - "error", - { - "allowLoop": false, - "allowSwitch": false - } - ], - "no-lone-blocks": "error", - "no-lonely-if": "error", - "no-loop-func": "error", - "no-loss-of-precision": "off", - "no-magic-numbers": [ - "off", - { - "ignore": [], - "ignoreArrayIndexes": true, - "enforceConst": true, - "detectObjects": false - } - ], - "no-misleading-character-class": "error", - "no-mixed-operators": [ - "error", - { - "groups": [ - [ - "%", - "**" - ], - [ - "%", - "+" - ], - [ - "%", - "-" - ], - [ - "%", - "*" - ], - [ - "%", - "/" - ], - [ - "/", - "*" - ], - [ - "&", - "|", - "<<", - ">>", - ">>>" - ], - [ - "==", - "!=", - "===", - "!==" - ], - [ - "&&", - "||" - ] - ], - "allowSamePrecedence": false - } - ], - "no-mixed-requires": [ - "off", - false - ], - "no-mixed-spaces-and-tabs": "error", - "no-multi-assign": "error", - "no-multi-spaces": [ - "error", - { - "ignoreEOLComments": false - } - ], - "no-multi-str": "error", - "no-multiple-empty-lines": "error", - "no-native-reassign": "off", - "no-negated-condition": "off", - "no-negated-in-lhs": "off", - "no-nested-ternary": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-object": "error", - "no-new-require": "error", - "no-new-symbol": "error", - "no-new-wrappers": "error", - "no-obj-calls": "error", - "no-octal": "error", - "no-octal-escape": "error", - "no-param-reassign": [ - "error", - { - "props": true, - "ignorePropertyModificationsFor": [ - "acc", - "accumulator", - "e", - "ctx", - "context", - "req", - "request", - "res", - "response", - "$scope", - "staticContext" - ] - } - ], - "no-path-concat": "error", - "no-plusplus": "error", - "no-process-env": "off", - "no-process-exit": "off", - "no-proto": "error", - "no-prototype-builtins": "error", - "no-redeclare": "error", - "no-regex-spaces": "error", - "no-restricted-exports": [ - "off", - { - "restrictedNamedExports": [ - "default", - "then" - ] - } - ], - "no-restricted-globals": [ - "error", - "isFinite", - "isNaN", - "addEventListener", - "blur", - "close", - "closed", - "confirm", - "defaultStatus", - "defaultstatus", - "event", - "external", - "find", - "focus", - "frameElement", - "frames", - "history", - "innerHeight", - "innerWidth", - "length", - "location", - "locationbar", - "menubar", - "moveBy", - "moveTo", - "name", - "onblur", - "onerror", - "onfocus", - "onload", - "onresize", - "onunload", - "open", - "opener", - "opera", - "outerHeight", - "outerWidth", - "pageXOffset", - "pageYOffset", - "parent", - "print", - "removeEventListener", - "resizeBy", - "resizeTo", - "screen", - "screenLeft", - "screenTop", - "screenX", - "screenY", - "scroll", - "scrollbars", - "scrollBy", - "scrollTo", - "scrollX", - "scrollY", - "self", - "status", - "statusbar", - "stop", - "toolbar", - "top" - ], - "no-restricted-imports": [ - "off", - { - "paths": [], - "patterns": [] - } - ], - "no-restricted-modules": "off", - "no-restricted-properties": [ - "error", - { - "object": "arguments", - "property": "callee", - "message": "arguments.callee is deprecated" - }, - { - "object": "global", - "property": "isFinite", - "message": "Please use Number.isFinite instead" - }, - { - "object": "self", - "property": "isFinite", - "message": "Please use Number.isFinite instead" - }, - { - "object": "window", - "property": "isFinite", - "message": "Please use Number.isFinite instead" - }, - { - "object": "global", - "property": "isNaN", - "message": "Please use Number.isNaN instead" - }, - { - "object": "self", - "property": "isNaN", - "message": "Please use Number.isNaN instead" - }, - { - "object": "window", - "property": "isNaN", - "message": "Please use Number.isNaN instead" - }, - { - "property": "__defineGetter__", - "message": "Please use Object.defineProperty instead." - }, - { - "property": "__defineSetter__", - "message": "Please use Object.defineProperty instead." - }, - { - "object": "Math", - "property": "pow", - "message": "Use the exponentiation operator (**) instead." - } - ], - "no-restricted-syntax": [ - "error", - { - "selector": "ForInStatement", - "message": "for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array." - }, - { - "selector": "ForOfStatement", - "message": "iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations." - }, - { - "selector": "LabeledStatement", - "message": "Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand." - }, - { - "selector": "WithStatement", - "message": "`with` is disallowed in strict mode because it makes code impossible to predict and optimize." - } - ], - "no-return-assign": [ - "error", - "always" - ], - "no-return-await": "error", - "no-script-url": "error", - "no-self-assign": [ - "error", - { - "props": true - } - ], - "no-self-compare": "error", - "no-sequences": "error", - "no-setter-return": "off", - "no-shadow": "error", - "no-shadow-restricted-names": "error", - "no-spaced-func": "error", - "no-sparse-arrays": "error", - "no-sync": "off", - "no-tabs": "error", - "no-template-curly-in-string": "error", - "no-ternary": "off", - "no-this-before-super": "error", - "no-throw-literal": "error", - "no-trailing-spaces": "error", - "no-undef": "error", - "no-undef-init": "error", - "no-undefined": "off", - "no-underscore-dangle": "error", - "no-unexpected-multiline": "error", - "no-unmodified-loop-condition": "off", - "no-unneeded-ternary": [ - "error", - { - "defaultAssignment": false - } - ], - "no-unreachable": "error", - "no-unsafe-finally": "error", - "no-unsafe-negation": "error", - "no-unused-expressions": [ - "error", - { - "allowShortCircuit": false, - "allowTernary": false, - "allowTaggedTemplates": false - } - ], - "no-unused-labels": "error", - "no-unused-vars": "off", - // "no-unused-vars": [ - // "error", - // { - // "vars": "all", - // "args": "after-used", - // "ignoreRestSiblings": true - // } - // ], - "no-use-before-define": [ - "off" - ], - "no-useless-backreference": "off", - "no-useless-call": "off", - "no-useless-catch": "error", - "no-useless-computed-key": "error", - "no-useless-concat": "error", - "no-useless-constructor": "error", - "no-useless-escape": "error", - "no-useless-rename": [ - "error", - { - "ignoreDestructuring": false, - "ignoreImport": false, - "ignoreExport": false - } - ], - "no-useless-return": "error", - "no-var": "error", - "no-void": "error", - "no-warning-comments": [ - "off", - { - "terms": [ - "todo", - "fixme", - "xxx" - ], - "location": "start" - } - ], - "no-whitespace-before-property": "error", - "no-with": "error", - "nonblock-statement-body-position": [ - "error", - "beside", - { - "overrides": {} - } - ], - "object-curly-newline": [ - "error", - { - "ObjectExpression": { - "minProperties": 4, - "multiline": true, - "consistent": true - }, - "ObjectPattern": { - "minProperties": 4, - "multiline": true, - "consistent": true - }, - "ImportDeclaration": { - "minProperties": 4, - "multiline": true, - "consistent": true - }, - "ExportDeclaration": { - "minProperties": 4, - "multiline": true, - "consistent": true - } - } - ], - "object-curly-spacing": [ - "error", - "always" - ], - "object-property-newline": [ - "error", - { - "allowAllPropertiesOnSameLine": true, - "allowMultiplePropertiesPerLine": false - } - ], - "object-shorthand": "error", - "one-var": [ - "error", - "never" - ], - "one-var-declaration-per-line": [ - "error", - "always" - ], - "operator-assignment": [ - "error", - "always" - ], - "operator-linebreak": [ - "error", - "before", - { - "overrides": { - "=": "none" - } - } - ], - "padded-blocks": [ - "error", - { - "blocks": "never", - "classes": "never", - "switches": "never" - }, - { - "allowSingleLineBlocks": true - } - ], - "padding-line-between-statements": "off", - "prefer-arrow-callback": [ - "error", - { - "allowNamedFunctions": false, - "allowUnboundThis": true - } - ], - "prefer-const": "error", - "prefer-destructuring": [ - "error", - { - "VariableDeclarator": { - "array": false, - "object": true - }, - "AssignmentExpression": { - "array": true, - "object": false - } - }, - { - "enforceForRenamedProperties": false - } - ], - "prefer-exponentiation-operator": "off", - "prefer-named-capture-group": "off", - "prefer-numeric-literals": "error", - "prefer-object-spread": "error", - "prefer-promise-reject-errors": [ - "error", - { - "allowEmptyReject": true - } - ], - "prefer-reflect": "off", - "prefer-regex-literals": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "error", - "quote-props": [ - "error", - "as-needed" - ], - "quotes": [ - "error", - "single", - { - "avoidEscape": true - } - ], - "radix": "error", - "require-atomic-updates": "off", - "require-await": "off", - "require-jsdoc": "off", - "require-unicode-regexp": "off", - "require-yield": "error", - "rest-spread-spacing": [ - "error", - "never" - ], - "semi": [ - "error", - "always" - ], - "semi-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "semi-style": [ - "error", - "last" - ], - "sort-imports": [ - "off", - { - "ignoreCase": false, - "ignoreDeclarationSort": false, - "ignoreMemberSort": false, - "memberSyntaxSortOrder": [ - "none", - "all", - "multiple", - "single" - ] - } - ], - "sort-keys": [ - "off", - "asc", - { - "caseSensitive": false, - "natural": true - } - ], - "sort-vars": "off", - "space-before-blocks": "error", - "space-before-function-paren": [ - "error", - { - "anonymous": "always", - "named": "never" - } - ], - "space-in-parens": [ - "error", - "never" - ], - "space-infix-ops": "error", - "space-unary-ops": [ - "error", - { - "words": true, - "nonwords": false, - "overrides": {} - } - ], - "spaced-comment": [ - "error", - "always", - { - "markers": [ - "/" - ] - } - ], - "strict": [ - "error", - "never" - ], - "switch-colon-spacing": [ - "error", - { - "after": true, - "before": false - } - ], - "symbol-description": "error", - "template-curly-spacing": "error", - "template-tag-spacing": [ - "error", - "never" - ], - "unicode-bom": [ - "error", - "never" - ], - "use-isnan": "error", - "valid-jsdoc": "off", - "valid-typeof": [ - "error", - { - "requireStringLiterals": true - } - ], - "vars-on-top": "error", - "wrap-iife": [ - "error", - "outside", - { - "functionPrototypeMethods": false - } - ], - "wrap-regex": "off", - "yield-star-spacing": [ - "error", - "after" - ], - "yoda": "error" - }, - "settings": { - "react": { - "version": "999.999.999" - }, - "import/resolver": { - "node": { - "extensions": [ - ".mjs", - ".js", - ".json" - ] - } - }, - "import/extensions": [ - ".js", - // ".mjs", - ".ts" - ], - "import/core-modules": [], - "import/ignore": [ - "node_modules", - "\\.(coffee|scss|css|less|hbs|svg|json)$" - ] - } + env: { + es6: true, + node: true, + }, + extends: [ + 'airbnb-typescript/base', + /* TODO: Uncomment rule below once jsdoc comments are added. + This matches the jsdoc rules in the TSLint config */ + // "plugin:jsdoc/recommended", + 'prettier', + 'prettier/@typescript-eslint', + './eslint-config-base', // the common settings in eslint-config-base + ], + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.eslint.json', + }, + plugins: ['@typescript-eslint', 'jsdoc'], + ignorePatterns: ["**/*.spec.ts", "src/test-helpers.ts"], + rules: { + /* Below are some of the new 'airbnb-typescript' rules that the project currently does not follow. + They've been disabled here since they raise errors in a few files. The best course + of action is likely to adopt these rules and make the quick (and mostly automated) fixes + needed in the repo to conform to these. ESLint and the airbnb-typecript config is more strict + than the original TSLint configuration that this project had. */ + 'import/first': ['off'], + 'import/prefer-default-export': ['off'], + 'import/newline-after-import': ['off'], + 'import/no-cycle': ['off'], + 'import/no-useless-path-segments': ['off'], + 'import/order': ['off'], + 'max-classes-per-file': ['off', 1], + '@typescript-eslint/no-use-before-define': 'off', + '@typescript-eslint/lines-between-class-members': 'off', + 'no-nested-ternary': 'off', + 'no-restricted-globals': 'off', + 'no-lonely-if': 'off', + 'no-undef-init': 'off', + 'no-multi-assign': 'off', + 'prefer-object-spread': 'off', + 'consistent-return': 'off', + 'no-restricted-syntax': 'off', + 'prefer-destructuring': 'off', + + /* Some currently-enabled additional rules. Uncomment to disable. The project currently conforms to them + so there it's best to just keep these commented or delete them entirely */ + // '@typescript-eslint/ban-types': 'off', + // '@typescript-eslint/no-empty-interface': 'off', + // '@typescript-eslint/no-unsafe-assign': 'off', + // '@typescript-eslint/no-explicit-any': 'off', + // '@typescript-eslint/no-unsafe-member-access': 'off', + // '@typescript-eslint/no-unsafe-return': 'off', + // '@typescript-eslint/no-unnecessary-type-assertion': 'off', + // '@typescript-eslint/no-non-null-assertion': 'off', + // '@typescript-eslint/no-unsafe-assignment': 'off', + // '@typescript-eslint/no-unsafe-call': 'off', + // '@typescript-eslint/restrict-template-expressions': 'off', + // '@typescript-eslint/unbound-method': 'off', + // '@typescript-eslint/explicit-module-boundary-types': 'off', + // '@typescript-eslint/require-await': 'off', + }, }; diff --git a/.eslintrc.test.js b/.eslintrc.test.js index c7d1f4b4c..947ee288e 100644 --- a/.eslintrc.test.js +++ b/.eslintrc.test.js @@ -1,26 +1,26 @@ module.exports = { - "extends": [ - "plugin:@typescript-eslint/recommended-requiring-type-checking" - ], - "env": { - "commonjs": true, - "mocha": true - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "project": "tsconfig.test.json", - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "@typescript-eslint/no-unsafe-member-access": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/require-await": "off", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/no-unnecessary-type-assertion": "warn", - "prefer-rest-params": "off" - } - + extends: [ + 'plugin:@typescript-eslint/recommended-requiring-type-checking', + './eslint-config-base', + ], + env: { + commonjs: true, + mocha: true, + }, + parser: '@typescript-eslint/parser', + parserOptions: { + project: './tsconfig.test.json', + }, + plugins: ['@typescript-eslint'], + rules: { + /* The rules below currently raise errors. They are easy and mostly automated fixes so conforming to them + would be a good idea. Make sure to remove the rules below if you chose to adopt these rules. */ + '@typescript-eslint/no-unsafe-member-access': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/require-await': 'off', + '@typescript-eslint/restrict-template-expressions': 'off', + '@typescript-eslint/no-unnecessary-type-assertion': 'warn', + 'prefer-rest-params': 'off', + 'brace-style': 'off', + }, }; diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 000000000..358ac0dd6 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,15 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "useTabs": true, + "tabWidth": 4, + "printWidth": 120, + "overrides": [ + { + "files": "*.ts", + "options": { + "parser": "typescript" + } + } + ] +} \ No newline at end of file diff --git a/eslint-config-base/index.js b/eslint-config-base/index.js new file mode 100644 index 000000000..558335b3e --- /dev/null +++ b/eslint-config-base/index.js @@ -0,0 +1,71 @@ +module.exports = { + rules: { + // The rules below are ESLint equivalents for the old TSLint rules in tslint.json + // Matches the quotemark rule + '@typescript-eslint/quotes': [ + 'error', + 'single', + { + 'avoidEscape': true, + 'allowTemplateLiterals': false, + }, + ], + // matches the variable-name rule + '@typescript-eslint/naming-convention': [ + 'error', + // custom rule to ignore cases that require quoting + { + 'selector': 'variableLike', + 'format': ['camelCase', 'UPPER_CASE'], + 'leadingUnderscore': 'allow', + 'filter': { + // you can expand this regex as you find more cases that require quoting that you want to allow + 'regex': '[_ ]', + 'match': false, + }, + }, + ], + // matches ban-comma-operator rule + 'no-sequences': 'error', + // matches the await-promise rule + '@typescript-eslint/await-thenable': 'error', + // matches interface-over-type-literal rule + '@typescript-eslint/consistent-type-definitions': 'error', + // matches member-access rule + '@typescript-eslint/explicit-member-accessibility': [ + 'error', + { + 'accessibility': 'explicit', + 'overrides': { + 'constructors': 'no-public', + }, + }, + ], + // matches no-duplicate-switch-case + 'no-duplicate-case': 'error', + // matches no-duplicate-variable + 'no-redeclare': 'error', + // matches no-require-imports + '@typescript-eslint/no-require-imports': 'error', + // matches no-return-await + 'no-return-await': 'error', + // matches no-submodule-imports (slightly different) + // "import/no-internal-modules": "error", + // matches no-this-assignment + '@typescript-eslint/no-this-alias': 'error', + // matches no-unused-expression + '@typescript-eslint/no-unused-expressions': 'error', + // matches no-var-requires + '@typescript-eslint/no-var-requires': 'error', + // sorta matches one-line (Prettier takes care of this) + 'brace-style': ['error', '1tbs'], + // matches strict-boolean-expressions + '@typescript-eslint/strict-boolean-expressions': 'error', + // matches typedef + // REVIEW: This raised errors in a couple of the files. To view these errors, its value from 'off' to 'error' + '@typescript-eslint/explicit-function-return-type': 'off', + // matches typedef-whitespace + '@typescript-eslint/type-annotation-spacing': 'error', + // max-line-length is matched by Prettier + }, +}; diff --git a/package.json b/package.json index 88b4242a4..3ef5dfa42 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,8 @@ "prepare": "npm run build", "build": "tsc", "build:clean": "shx rm -rf ./dist ./coverage ./.nyc_output", - "lint": "eslint src/**/*.ts", - "test-lint": "eslint --no-eslintrc -c .eslintrc.test.js \"src/**/*.spec.ts\" --no-ignore && eslint --no-eslintrc -c .eslintrc.test.js \"src/test-helpers.ts\" --no-ignore", + "lint": "eslint --ext .ts src", + "test-lint": "eslint --no-eslintrc -c .eslintrc.test.js \"src/**/*.spec.ts\" && eslint --no-eslintrc -c .eslintrc.test.js \"src/test-helpers.ts\"", "mocha": "TS_NODE_PROJECT=tsconfig.test.json nyc mocha --config .mocharc.json \"src/**/*.spec.ts\"", "test": "npm run lint && npm run test-lint && npm run mocha && npm run test:types", "test:types": "tsd", @@ -51,6 +51,7 @@ "axios": "^0.19.0", "express": "^4.16.4", "please-upgrade-node": "^3.2.0", + "prettier": "^2.0.5", "promise.allsettled": "^1.0.2", "raw-body": "^2.3.3", "tsscmp": "^1.0.6" @@ -59,14 +60,15 @@ "@types/chai": "^4.1.7", "@types/mocha": "^5.2.6", "@types/sinon": "^7.0.11", - "@typescript-eslint/eslint-plugin": "^3.4.0", + "@typescript-eslint/eslint-plugin": "^3.6.0", "@typescript-eslint/eslint-plugin-tslint": "^3.4.0", "@typescript-eslint/parser": "^3.4.0", "chai": "^4.2.0", "codecov": "^3.2.0", - "eslint": "^7.2.0", + "eslint": "^7.3.1", "eslint-config-airbnb-typescript": "^8.0.2", - "eslint-plugin-import": "^2.21.2", + "eslint-config-prettier": "^6.11.0", + "eslint-plugin-import": "^2.22.0", "eslint-plugin-jsdoc": "^28.5.1", "mocha": "^6.1.4", "nyc": "^14.0.0", diff --git a/src/App.spec.ts b/src/App.spec.ts index c10819651..1b841e80f 100644 --- a/src/App.spec.ts +++ b/src/App.spec.ts @@ -1,4 +1,3 @@ -// eslint-disable import/no-extraneous-dependencies import 'mocha'; import sinon, { SinonSpy } from 'sinon'; import { assert } from 'chai'; @@ -44,7 +43,7 @@ describe('App', () => { withNoopAppMetadata(), withSuccessfulBotUserFetchingWebClient(fakeBotId, fakeBotUserId), ); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ token: '', signingSecret: '' }); @@ -57,7 +56,7 @@ describe('App', () => { it('should succeed with an authorize callback', async () => { // Arrange const authorizeCallback = sinon.fake(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ authorize: authorizeCallback, signingSecret: '' }); @@ -69,7 +68,7 @@ describe('App', () => { it('should fail without a token for single team authorization or authorize callback or oauth installer', async () => { // Arrange - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act try { @@ -83,7 +82,7 @@ describe('App', () => { it('should fail when both a token and authorize callback are specified', async () => { // Arrange const authorizeCallback = sinon.fake(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act try { @@ -99,7 +98,7 @@ describe('App', () => { it('should fail when both a token is specified and OAuthInstaller is initialized', async () => { // Arrange const authorizeCallback = sinon.fake(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act try { @@ -115,7 +114,7 @@ describe('App', () => { it('should fail when both a authorize callback is specified and OAuthInstaller is initialized', async () => { // Arrange const authorizeCallback = sinon.fake(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act try { @@ -131,7 +130,7 @@ describe('App', () => { describe('with a custom receiver', () => { it('should succeed with no signing secret', async () => { // Arrange - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ receiver: new FakeReceiver(), authorize: noopAuthorize }); @@ -142,7 +141,7 @@ describe('App', () => { }); it('should fail when no signing secret for the default receiver is specified', async () => { // Arrange - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act try { @@ -163,7 +162,7 @@ describe('App', () => { withMemoryStore(fakeMemoryStore), withConversationContext(fakeConversationContext), ); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ authorize: noopAuthorize, signingSecret: '' }); @@ -181,7 +180,7 @@ describe('App', () => { withNoopWebClient(), withConversationContext(fakeConversationContext), ); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ convoStore: false, authorize: noopAuthorize, signingSecret: '' }); @@ -200,7 +199,7 @@ describe('App', () => { withConversationContext(fakeConversationContext), ); const dummyConvoStore = Symbol() as unknown as ConversationStore; - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ convoStore: dummyConvoStore, authorize: noopAuthorize, signingSecret: '' }); @@ -224,12 +223,12 @@ describe('App', () => { }, }, ); - // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match - const App = await importApp(overrides); + + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const clientOptions = { slackApiUrl: 'proxy.slack.com' }; - // eslint-disable-line @typescript-eslint/no-unused-expressions - new App({ clientOptions, authorize: noopAuthorize, signingSecret: '', logLevel: LogLevel.ERROR }); + + new App({ clientOptions, authorize: noopAuthorize, signingSecret: '', logLevel: LogLevel.ERROR }); // eslint-disable-line @typescript-eslint/no-unused-expressions assert.ok(fakeConstructor.called); @@ -250,7 +249,7 @@ describe('App', () => { const dummyReturn = Symbol(); const dummyParams = [Symbol(), Symbol()]; const fakeReceiver = new FakeReceiver(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const app = new App({ receiver: fakeReceiver, authorize: noopAuthorize }); fakeReceiver.start = sinon.fake.returns(dummyReturn); @@ -269,11 +268,11 @@ describe('App', () => { const dummyReturn = Symbol(); const dummyParams = [Symbol(), Symbol()]; const fakeReceiver = new FakeReceiver(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match fakeReceiver.stop = sinon.fake.returns(dummyReturn); // Act - const app = new App({ receiver: fakeReceiver, authorize: noopAuthorize }); + const app = new App({ receiver: fakeReceiver, authorize: noopAuthorize }); // eslint-disable-line @typescript-eslint/no-unused-expressions const actualReturn = await app.stop(...dummyParams); // Assert @@ -309,7 +308,7 @@ describe('App', () => { const fakeLogger = createFakeLogger(); const fakeMiddleware = sinon.fake(noopMiddleware); const invalidReceiverEvents = createInvalidReceiverEvents(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ receiver: fakeReceiver, logger: fakeLogger, authorize: noopAuthorize }); @@ -329,7 +328,7 @@ describe('App', () => { const dummyOrigError = new Error('auth failed'); const dummyAuthorizationError = new AuthorizationError('auth failed', dummyOrigError); const dummyReceiverEvent = createDummyReceiverEvent(); - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ @@ -363,7 +362,7 @@ describe('App', () => { withMemoryStore(sinon.fake()), withConversationContext(fakeConversationContext), ); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match dummyReceiverEvent = createDummyReceiverEvent(); fakeFirstMiddleware = sinon.fake(noopMiddleware); @@ -512,7 +511,7 @@ describe('App', () => { const dummyReceiverEvent = createDummyReceiverEvent(eventType); beforeEach(async () => { - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match app = new App({ receiver: fakeReceiver, authorize: sinon.fake.resolves(dummyAuthorizationResult), @@ -733,7 +732,7 @@ describe('App', () => { const viewFn = sinon.fake.resolves({}); const optionsFn = sinon.fake.resolves({}); const overrides = buildOverrides([withNoopWebClient()]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const dummyReceiverEvents = createReceiverEvents(); // Act @@ -812,7 +811,7 @@ describe('App', () => { const actionId = 'block_action_id'; const fakeAxiosPost = sinon.fake.resolves({}); const overrides = buildOverrides([withNoopWebClient(), withAxiosPost(fakeAxiosPost)]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ receiver: fakeReceiver, authorize: sinon.fake.resolves(dummyAuthorizationResult) }); @@ -848,7 +847,7 @@ describe('App', () => { const actionId = 'block_action_id'; const fakeAxiosPost = sinon.fake.resolves({}); const overrides = buildOverrides([withNoopWebClient(), withAxiosPost(fakeAxiosPost)]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match // Act const app = new App({ receiver: fakeReceiver, authorize: sinon.fake.resolves(dummyAuthorizationResult) }); @@ -881,7 +880,7 @@ describe('App', () => { it('should be available in middleware/listener args', async () => { // Arrange - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const fakeLogger = createFakeLogger(); const app = new App({ logger: fakeLogger, @@ -928,7 +927,7 @@ describe('App', () => { it('should work in the case both logger and logLevel are given', async () => { // Arrange - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const fakeLogger = createFakeLogger(); const app = new App({ logger: fakeLogger, @@ -980,7 +979,7 @@ describe('App', () => { it('should be available in middleware/listener args', async () => { // Arrange - const App = await importApp(mergeOverrides( // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(mergeOverrides( // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match withNoopAppMetadata(), withSuccessfulBotUserFetchingWebClient('B123', 'U123'), )); @@ -1048,7 +1047,7 @@ describe('App', () => { it('should be to the global app client when authorization doesn\'t produce a token', async () => { // Arrange - const App = await importApp(); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const app = new App({ receiver: fakeReceiver, authorize: noopAuthorize, @@ -1140,7 +1139,7 @@ describe('App', () => { // Arrange const fakePostMessage = sinon.fake.resolves({}); const overrides = buildOverrides([withPostMessage(fakePostMessage)]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const dummyMessage = 'test'; const dummyReceiverEvents = createChannelContextualReceiverEvents(dummyChannelId); @@ -1170,7 +1169,7 @@ describe('App', () => { // Arrange const fakePostMessage = sinon.fake.resolves({}); const overrides = buildOverrides([withPostMessage(fakePostMessage)]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const dummyMessage = { text: 'test' }; const dummyReceiverEvents = createChannelContextualReceiverEvents(dummyChannelId); @@ -1247,7 +1246,7 @@ describe('App', () => { it('should not exist in the arguments on incoming events that don\'t support say', async () => { // Arrange const overrides = buildOverrides([withNoopWebClient()]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const assertionAggregator = sinon.fake(); const dummyReceiverEvents = createReceiverEventsWithoutSay(dummyChannelId); @@ -1271,7 +1270,7 @@ describe('App', () => { // Arrange const fakePostMessage = sinon.fake.rejects(new Error('fake error')); const overrides = buildOverrides([withPostMessage(fakePostMessage)]); - const App = await importApp(overrides); // eslint-disable-line camelcase, no-underscore-dangle, id-blacklist, id-match + const App = await importApp(overrides); // eslint-disable-line @typescript-eslint/naming-convention, no-underscore-dangle, id-blacklist, id-match const dummyMessage = { text: 'test' }; const dummyReceiverEvents = createChannelContextualReceiverEvents(dummyChannelId); diff --git a/src/App.ts b/src/App.ts index 126bb0d7f..ed58f11e2 100644 --- a/src/App.ts +++ b/src/App.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-member-accessibility, @typescript-eslint/strict-boolean-expressions */ import { Agent } from 'http'; import { SecureContextOptions } from 'tls'; import util from 'util'; @@ -55,8 +56,8 @@ import { AppInitializationError, MultipleListenerError, } from './errors'; -import allSettled = require('promise.allsettled'); // tslint:disable-line:no-require-imports import-name -const packageJson = require('../package.json'); // tslint:disable-line:no-require-imports no-var-requires +import allSettled = require('promise.allsettled'); // eslint-disable-line @typescript-eslint/no-require-imports +const packageJson = require('../package.json'); // eslint-disable-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires /** App initialization options */ export interface AppOptions { diff --git a/src/ExpressReceiver.ts b/src/ExpressReceiver.ts index c7df980f1..8d88d8cc8 100644 --- a/src/ExpressReceiver.ts +++ b/src/ExpressReceiver.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/explicit-member-accessibility, @typescript-eslint/strict-boolean-expressions */ + import { AnyMiddlewareArgs, Receiver, ReceiverEvent } from './types'; import { createServer, Server } from 'http'; import express, { Request, Response, Application, RequestHandler, Router } from 'express'; diff --git a/src/conversation-store.spec.ts b/src/conversation-store.spec.ts index 61f82851f..ba1ed3894 100644 --- a/src/conversation-store.spec.ts +++ b/src/conversation-store.spec.ts @@ -1,4 +1,4 @@ -// tslint:disable:no-implicit-dependencies +// eslint-disable import/no-extraneous-dependencies import 'mocha'; import { assert, AssertionError } from 'chai'; import sinon, { SinonSpy } from 'sinon'; @@ -125,7 +125,7 @@ describe('MemoryStore', () => { describe('constructor', () => { it('should initialize successfully', async () => { // Arrange - const { MemoryStore } = await importConversationStore(); + const { MemoryStore } = await importConversationStore(); // eslint-disable-line @typescript-eslint/naming-convention // Act const store = new MemoryStore(); @@ -143,7 +143,7 @@ describe('MemoryStore', () => { // Arrange const dummyConversationState = Symbol(); const dummyConversationId = 'CONVERSATION_ID'; - const { MemoryStore } = await importConversationStore(); + const { MemoryStore } = await importConversationStore(); // eslint-disable-line @typescript-eslint/naming-convention // Act const store = new MemoryStore(); @@ -156,7 +156,7 @@ describe('MemoryStore', () => { it('should reject lookup of conversation state when the conversation is not stored', async () => { // Arrange - const { MemoryStore } = await importConversationStore(); + const { MemoryStore } = await importConversationStore(); // eslint-disable-line @typescript-eslint/naming-convention // Act const store = new MemoryStore(); @@ -175,7 +175,7 @@ describe('MemoryStore', () => { const dummyConversationId = 'CONVERSATION_ID'; const dummyConversationState = Symbol(); const expiresInMs = 5; - const { MemoryStore } = await importConversationStore(); + const { MemoryStore } = await importConversationStore(); // eslint-disable-line @typescript-eslint/naming-convention // Act const store = new MemoryStore(); diff --git a/src/errors.ts b/src/errors.ts index 50f8817f3..b626e06f8 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/explicit-member-accessibility */ export interface CodedError extends Error { code: string; // This can be a value from ErrorCode, or WebClient's ErrorCode, or a NodeJS error code } diff --git a/src/index.ts b/src/index.ts index 84431a28d..f88e42741 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -const packageJson = require('../package.json'); // tslint:disable-line:no-require-imports no-var-requires +const packageJson = require('../package.json'); // eslint-disable-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires import pleaseUpgradeNode from 'please-upgrade-node'; pleaseUpgradeNode(packageJson); diff --git a/src/middleware/builtin.ts b/src/middleware/builtin.ts index 68ca834d2..5f29c4e89 100644 --- a/src/middleware/builtin.ts +++ b/src/middleware/builtin.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/dot-notation */ + import { Middleware, AnyMiddlewareArgs, @@ -311,7 +313,7 @@ export function ignoreSelf(): Middleware { }; } -export function subtype(subtype: string): Middleware> { +export function subtype(subtype: string): Middleware> { // eslint-disable-line no-shadow return async ({ message, next }) => { if (message.subtype === subtype) { // TODO: remove the non-null assertion operator diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index c225026ad..b10b1b2ff 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -4,5 +4,5 @@ "compilerOptions": { // ensure that this config cannot be used for a build "noEmit": true - } + }, } \ No newline at end of file diff --git a/tsconfig.test.json b/tsconfig.test.json index a8d4317b4..67566a4c3 100644 --- a/tsconfig.test.json +++ b/tsconfig.test.json @@ -1,4 +1,5 @@ { - "extends": "./tsconfig.json", - "exclude": [] + "extends": "./tsconfig.json", + "include": ["**/*.spec.ts", "src/test-helpers.ts"], + "exclude": [] }