From f50d8b1ec38e2f01e303abfa35a0498d1693e1a9 Mon Sep 17 00:00:00 2001 From: Tyler Butler Date: Tue, 5 Apr 2022 17:19:40 -0700 Subject: [PATCH] lint refresh --- common/build/eslint-config-fluid/README.md | 2 + common/build/eslint-config-fluid/eslint7.js | 381 ---------- common/build/eslint-config-fluid/index.js | 2 +- common/build/eslint-config-fluid/minimal.js | 176 ----- .../printed-configs/default.json | 526 ++++++++++---- .../printed-configs/test.json | 526 ++++++++++---- .../build/eslint-config-fluid/recommended.js | 52 -- .../scripts/cleanup-printed-configs.js | 7 +- .../eslint-config-fluid/shared-config.js | 682 ++++++++++++++++++ common/build/eslint-config-fluid/strict.js | 64 -- 10 files changed, 1494 insertions(+), 924 deletions(-) delete mode 100644 common/build/eslint-config-fluid/eslint7.js delete mode 100644 common/build/eslint-config-fluid/minimal.js delete mode 100644 common/build/eslint-config-fluid/recommended.js create mode 100644 common/build/eslint-config-fluid/shared-config.js delete mode 100644 common/build/eslint-config-fluid/strict.js diff --git a/common/build/eslint-config-fluid/README.md b/common/build/eslint-config-fluid/README.md index b7721625628ae..56486dc9bfca8 100644 --- a/common/build/eslint-config-fluid/README.md +++ b/common/build/eslint-config-fluid/README.md @@ -27,6 +27,8 @@ ESLint provides a way to print the config that would apply to a file (`--print-c print out the applied config as a JSON file. As we make changes to the config, we can print out the config again and get a diff to review as part of a PR -- just like we do with API reports for code changes. +When updating the lint config, run the `build` script for this package and commit the resulting changes. + ## Scripts diff --git a/common/build/eslint-config-fluid/eslint7.js b/common/build/eslint-config-fluid/eslint7.js deleted file mode 100644 index 5a03458284225..0000000000000 --- a/common/build/eslint-config-fluid/eslint7.js +++ /dev/null @@ -1,381 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "extends": [ - "eslint:recommended", - "plugin:eslint-comments/recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "plugin:@typescript-eslint/recommended-requiring-type-checking", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:import/typescript" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.json" - }, - "plugins": [ - "unicorn", - ], - "reportUnusedDisableDirectives": true, - "rules": { - // Please keep entries alphabetized within a group - - // @typescript-eslint - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/ban-types": "error", - "@typescript-eslint/brace-style": "off", - "@typescript-eslint/comma-dangle": [ - "error", - { - "arrays": "always-multiline", - "enums": "always-multiline", - "exports": "always-multiline", - "functions": "always-multiline", - "generics": "never", - "imports": "always-multiline", - "objects": "always-multiline", - "tuples": "always-multiline", - } - ], - "@typescript-eslint/comma-spacing": "off", - "@typescript-eslint/consistent-type-assertions": [ - "error", - { - "assertionStyle": "as", - "objectLiteralTypeAssertions": "never" - } - ], - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/dot-notation": "error", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/func-call-spacing": "off", - "@typescript-eslint/interface-name-prefix": "off", - "@typescript-eslint/keyword-spacing": "off", - "@typescript-eslint/member-delimiter-style": "off", - "@typescript-eslint/no-duplicate-imports": "error", - "@typescript-eslint/no-dynamic-delete": "error", - "@typescript-eslint/no-empty-function": "off", - "@typescript-eslint/no-empty-interface": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-extra-semi": "error", - "@typescript-eslint/no-extraneous-class": "error", - "@typescript-eslint/no-floating-promises": "error", - "@typescript-eslint/no-for-in-array": "error", - "@typescript-eslint/no-inferrable-types": "off", - "@typescript-eslint/no-invalid-this": "off", - "@typescript-eslint/no-magic-numbers": "off", - "@typescript-eslint/no-misused-new": "error", - "@typescript-eslint/no-namespace": "off", - "@typescript-eslint/no-non-null-assertion": "error", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/no-shadow": [ - "error", - { - "hoist": "all", - "ignoreTypeValueShadow": true, - } - ], - "@typescript-eslint/no-this-alias": "error", - "@typescript-eslint/no-throw-literal": "error", - "@typescript-eslint/no-unused-expressions": "error", - "@typescript-eslint/no-unused-vars": "off", - "@typescript-eslint/no-unnecessary-qualifier": "error", - "@typescript-eslint/no-unnecessary-type-arguments": "error", - "@typescript-eslint/no-unnecessary-type-assertion": "error", - "@typescript-eslint/no-use-before-declare": "off", - "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/object-curly-spacing": "off", - "@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": [ - "error", - "double", - { - "allowTemplateLiterals": true, - "avoidEscape": true - } - ], - "@typescript-eslint/restrict-plus-operands": "error", - "@typescript-eslint/restrict-template-expressions": "off", - "@typescript-eslint/require-await": "off", - "@typescript-eslint/semi": [ - "error", - "always" - ], - "@typescript-eslint/space-infix-ops": "error", - "@typescript-eslint/space-before-function-paren": [ - "error", - { - "anonymous": "never", - "asyncArrow": "always", - "named": "never" - } - ], - "@typescript-eslint/strict-boolean-expressions": "error", - "@typescript-eslint/triple-slash-reference": "error", - "@typescript-eslint/type-annotation-spacing": "error", - "@typescript-eslint/unbound-method": [ - "error", - { - "ignoreStatic": true - } - ], - "@typescript-eslint/unified-signatures": "error", - - // eslint-plugin-eslint-comments - "eslint-comments/disable-enable-pair": [ - "error", - { - "allowWholeFile": true - } - ], - - // eslint-plugin-import - "import/no-default-export": "error", - "import/no-deprecated": "off", - "import/no-extraneous-dependencies": [ - "error", - { - "devDependencies": ["**/*.spec.ts", "src/test/**"] - } - ], - "import/no-internal-modules": "error", - "import/no-unassigned-import": "error", - "import/no-unresolved": [ - "error", - { - "caseSensitive": true - } - ], - "import/no-unused-modules": "error", - "import/order": "error", - - // eslint-plugin-unicorn - "unicorn/better-regex": "error", - "unicorn/filename-case": [ - "error", - { - "cases": { - "camelCase": true, - "pascalCase": true - } - } - ], - "unicorn/no-new-buffer": "error", - "unicorn/no-unsafe-regex": "error", - - // eslint - "arrow-body-style": "off", - "arrow-parens": [ - "error", - "always" - ], - "camelcase": "off", // Superseded by @typescript-eslint/camelcase - "brace-style": "off", // Superseded by @typescript-eslint/brace-style - "capitalized-comments": "off", - "comma-dangle": "off", // Superseded by @typescript-eslint/comma-dangle - "comma-spacing": "off", // Superseded by @typescript-eslint/comma-spacing - "complexity": "off", - "constructor-super": "error", - "curly": "error", - "default-case": "error", - "dot-notation": "off", // Superseded by @typescript-eslint/dot-notation - "eol-last": "error", - "eqeqeq": [ - "error", - "smart" - ], - "func-call-spacing": "off", // Superseded by @typescript-eslint/func-call-spacing - "guard-for-in": "error", - "id-match": "error", - "linebreak-style": "off", - "keyword-spacing": "off", // Superseded by @typescript-eslint/keyword-spacing - "max-classes-per-file": "off", - "max-len": [ - "error", - { - "ignoreRegExpLiterals": false, - "ignoreStrings": false, - "code": 120 - } - ], - "max-lines": "off", - "new-parens": "error", - "newline-per-chained-call": "off", - "no-bitwise": "error", - "no-caller": "error", - "no-cond-assign": "error", - "no-constant-condition": "error", - "no-control-regex": "error", - "no-debugger": "off", - "no-duplicate-case": "error", - "no-duplicate-imports": "off", // Superseded by @typescript-eslint/no-duplicate-imports - "no-empty": "off", - "no-eval": "error", - "no-extra-semi": "off", // Superseded by @typescript-eslint/no-extra-semi - "no-fallthrough": "off", - "no-invalid-regexp": "error", - "no-invalid-this": "off", // Superseded by @typescript-eslint/no-invalid-this - "no-irregular-whitespace": "error", - "no-magic-numbers": "off", // Superseded by @typescript-eslint/no-magic-numbers - "no-multi-str": "off", - "no-multiple-empty-lines": [ - "error", - { - "max": 1, - "maxBOF": 0, - "maxEOF": 0, - } - ], - "no-nested-ternary": "off", // Superseded by unicorn/no-nested-ternary - "no-new-func": "error", - "no-new-wrappers": "error", - "no-octal": "error", - "no-octal-escape": "error", - "no-param-reassign": "error", - "no-redeclare": "off", // Superseded by @typescript-eslint/no-redeclare - "no-regex-spaces": "error", - "no-restricted-syntax": [ - "error", - "ForInStatement" - ], - "no-return-await": "error", - "no-sequences": "error", - "no-shadow": "off", // Superseded by @typescript-eslint/no-shadow - "no-sparse-arrays": "error", - "no-template-curly-in-string": "error", - "no-throw-literal": "off", // Superseded by @typescript-eslint/no-throw-literal - "no-trailing-spaces": "error", - "no-undef-init": "error", - "no-underscore-dangle": "off", - "no-unsafe-finally": "error", - "no-unused-expressions": "off", // Superseded by @typescript-eslint/no-unused-expressions - "no-unused-labels": "error", - "no-unused-vars": "off", - "no-var": "error", - "no-void": "off", - "no-whitespace-before-property": "error", - "object-curly-spacing": "off", // Superseded by @typescript-eslint/no-unused-expressions - "object-shorthand": "error", - "one-var": [ - "error", - "never" - ], - "padded-blocks": [ - "error", - "never" - ], - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "prev": "*", - "next": "return" - } - ], - "prefer-arrow-callback": "error", - "prefer-const": "error", - "prefer-object-spread": "error", - "prefer-promise-reject-errors": "error", - "prefer-template": "error", - "quote-props": [ - "error", - "consistent-as-needed" - ], - "quotes": "off", // Superseded by @typescript-eslint/quotes - "radix": "error", - "require-await": "off", // Superseded by @typescript-eslint/require-await - "semi": "off", // Superseded by @typescript-eslint/semi - "semi-spacing": "error", - "space-before-blocks": "error", - "space-before-function-paren": "off", // Superseded by @typescript-eslint/space-before-function-paren - "space-infix-ops": "off", // Superseded by @typescript-eslint/space-infix-ops - "space-in-parens": [ - "error", - "never" - ], - "spaced-comment": [ - "error", - "always", - { - "block": { - "markers": ["!"], - "balanced": true - } - } - ], - "use-isnan": "error", - "valid-typeof": "off", - "yoda": "off", - }, - "overrides": [ - { - // Rules only for TypeScript files - "files": ["*.ts", "*.tsx"], - "rules": { - "@typescript-eslint/indent": "off", // Off because it conflicts with typescript-formatter - "func-call-spacing": "off", // Off because it conflicts with typescript-formatter - - // TODO: Enable these ASAP - "@typescript-eslint/explicit-module-boundary-types": "off", - "@typescript-eslint/no-unsafe-argument": "off", - "@typescript-eslint/no-unsafe-assignment": "off", - "@typescript-eslint/no-unsafe-call": "off", - "@typescript-eslint/no-unsafe-member-access": "off", - } - } - ], - "settings": { - "import/extensions": [ - ".ts", - ".tsx", - ".d.ts", - ".js", - ".jsx" - ], - "import/parsers": { - "@typescript-eslint/parser": [ - ".ts", - ".tsx", - ".d.ts" - ] - }, - "import/resolver": { - "node": { - "extensions": [ - ".ts", - ".tsx", - ".d.ts", - ".js", - ".jsx" - ] - } - } - } -}; diff --git a/common/build/eslint-config-fluid/index.js b/common/build/eslint-config-fluid/index.js index f5c1423213a1a..33fabd6357f8a 100644 --- a/common/build/eslint-config-fluid/index.js +++ b/common/build/eslint-config-fluid/index.js @@ -3,4 +3,4 @@ * Licensed under the MIT License. */ -module.exports = require("./minimal.js") +module.exports = require("./shared-config.js") diff --git a/common/build/eslint-config-fluid/minimal.js b/common/build/eslint-config-fluid/minimal.js deleted file mode 100644 index 1dd4e65fca48e..0000000000000 --- a/common/build/eslint-config-fluid/minimal.js +++ /dev/null @@ -1,176 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -module.exports = { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "extends": [ - "./eslint7", - "plugin:eslint-comments/recommended", - "plugin:import/errors", - "plugin:import/warnings", - "plugin:import/typescript" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.json", - }, - "plugins": [ - // Plugin documentation: https://www.npmjs.com/package/@rushstack/eslint-plugin - "@rushstack/eslint-plugin", - // Plugin documentation: https://www.npmjs.com/package/@rushstack/eslint-plugin-security - "@rushstack/eslint-plugin-security", - // Plugin documentation: https://www.npmjs.com/package/@typescript-eslint/eslint-plugin - "@typescript-eslint/eslint-plugin", - // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-promise - "eslint-plugin-promise", - // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-react - "react", - // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-unicorn - "unicorn", - ], - "reportUnusedDisableDirectives": true, - "rules": { - - // The @rushstack rules are documented in the package README: - // https://www.npmjs.com/package/@rushstack/eslint-plugin - "@rushstack/no-new-null": "warn", - - // RATIONALE: Harmless. Our guideline is to only use leading underscores on private members - // when required to avoid a conflict between private fields and a public property. - // Docs: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md - "@typescript-eslint/naming-convention": [ - "error", - { - selector: "accessor", - modifiers: ["private"], - format: ["camelCase"], - "leadingUnderscore": "allow" - }, - ], - - // Encourages minimal disabling of eslint rules, while still permitting whole-file exclusions. - "eslint-comments/disable-enable-pair": [ - "error", { - "allowWholeFile": true - } - ], - - // ENABLED INTENTIONALLY - "@typescript-eslint/ban-types": "error", - "@typescript-eslint/dot-notation": "error", - "@typescript-eslint/no-non-null-assertion": "error", - "@typescript-eslint/no-unnecessary-type-assertion": "error", - "eqeqeq": [ - "error", - "smart" - ], - "max-len": [ - "error", - { - "ignoreRegExpLiterals": false, - "ignoreStrings": false, - "code": 120 - } - ], - "no-multi-spaces": [ - "error", - { - "ignoreEOLComments": true - } - ], - - // Catches a common coding mistake where "resolve" and "reject" are confused. - "promise/param-names": "warn", - - "unicorn/better-regex": "error", - "unicorn/filename-case": [ - "error", - { - "cases": { - "camelCase": true, - "pascalCase": true - } - } - ], - "unicorn/no-new-buffer": "error", - "unicorn/no-unsafe-regex": "error", - - // DISABLED INTENTIONALLY - // Disabled because we don't require that all variable declarations be explicitly typed. - "@rushstack/typedef-var": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-member-accessibility": "off", - "@typescript-eslint/indent": "off", // Off because it conflicts with typescript-formatter - "@typescript-eslint/member-ordering": "off", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@typescript-eslint/no-unused-vars": "off", - "@typescript-eslint/no-use-before-define": "off", - "@typescript-eslint/typedef": "off", - "func-call-spacing": "off", // Off because it conflicts with typescript-formatter - "no-empty": "off", - "no-void": "off", - "require-atomic-updates": "off", - "dot-notation": "off", // Superseded by @typescript-eslint/dot-notation - "no-unused-expressions": "off", // Superseded by @typescript-eslint/no-unused-expressions - }, - "overrides": [ - { - // Rules only for TypeScript files - "files": ["*.ts", "*.tsx"], - "rules": { - "dot-notation": "off", // Superseded by @typescript-eslint/dot-notation - "no-unused-expressions": "off", // Superseded by @typescript-eslint/no-unused-expressions - } - }, - { - // Rules only for test files - "files": ["*.spec.ts", "src/test/**"], - "rules": { - "@typescript-eslint/unbound-method": "off", // This rule has false positives in many of our test projects. - } - }, - ], - "settings": { - "import/extensions": [ - ".ts", - ".tsx", - ".d.ts", - ".js", - ".jsx" - ], - "import/parsers": { - "@typescript-eslint/parser": [ - ".ts", - ".tsx", - ".d.ts" - ] - }, - "import/resolver": { - "node": { - "extensions": [ - ".ts", - ".tsx", - ".d.ts", - ".js", - ".jsx" - ] - } - } - } -}; diff --git a/common/build/eslint-config-fluid/printed-configs/default.json b/common/build/eslint-config-fluid/printed-configs/default.json index 22dbc274f7f02..4ecf823a9c067 100644 --- a/common/build/eslint-config-fluid/printed-configs/default.json +++ b/common/build/eslint-config-fluid/printed-configs/default.json @@ -20,6 +20,8 @@ "plugins": [ "eslint-comments", "import", + "tsdoc", + "editorconfig", "unicorn", "react", "promise", @@ -30,7 +32,7 @@ "reportUnusedDisableDirectives": true, "rules": { "@rushstack/no-new-null": [ - "warn" + "error" ], "@rushstack/typedef-var": [ "off" @@ -51,7 +53,7 @@ "error" ], "@typescript-eslint/brace-style": [ - "off" + "error" ], "@typescript-eslint/comma-dangle": [ "error", @@ -60,14 +62,14 @@ "enums": "always-multiline", "exports": "always-multiline", "functions": "always-multiline", - "generics": "never", + "generics": "always-multiline", "imports": "always-multiline", "objects": "always-multiline", "tuples": "always-multiline" } ], "@typescript-eslint/comma-spacing": [ - "off" + "error" ], "@typescript-eslint/consistent-type-assertions": [ "error", @@ -77,37 +79,55 @@ } ], "@typescript-eslint/consistent-type-definitions": [ - "error" + "error", + "interface" + ], + "@typescript-eslint/consistent-type-imports": [ + "warn", + { + "prefer": "type-imports" + } ], "@typescript-eslint/dot-notation": [ "error" ], - "@typescript-eslint/explicit-function-return-type": [ + "@typescript-eslint/eol-last": [ "off" ], + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowConciseArrowFunctionExpressionsStartingWithVoid": false, + "allowDirectConstAssertionInArrowFunctions": true, + "allowExpressions": true, + "allowHigherOrderFunctions": true, + "allowTypedFunctionExpressions": true + } + ], "@typescript-eslint/explicit-member-accessibility": [ - "off" + "error", + { + "accessibility": "explicit", + "overrides": { + "accessors": "explicit", + "constructors": "explicit", + "methods": "explicit", + "parameterProperties": "explicit", + "properties": "explicit" + } + } ], "@typescript-eslint/explicit-module-boundary-types": [ - "off" - ], - "@typescript-eslint/func-call-spacing": [ - "off" + "error" ], "@typescript-eslint/indent": [ "off" ], - "@typescript-eslint/interface-name-prefix": [ - "off" - ], - "@typescript-eslint/keyword-spacing": [ + "@typescript-eslint/linebreak-style": [ "off" ], "@typescript-eslint/member-delimiter-style": [ - "off" - ], - "@typescript-eslint/member-ordering": [ - "off" + "error" ], "@typescript-eslint/naming-convention": [ "error", @@ -132,13 +152,13 @@ "error" ], "@typescript-eslint/no-empty-function": [ - "off" + "error" ], "@typescript-eslint/no-empty-interface": [ "error" ], "@typescript-eslint/no-explicit-any": [ - "off" + "warn" ], "@typescript-eslint/no-extra-non-null-assertion": [ "error" @@ -162,13 +182,13 @@ "off" ], "@typescript-eslint/no-invalid-this": [ - "off" + "error" ], "@typescript-eslint/no-loss-of-precision": [ "error" ], "@typescript-eslint/no-magic-numbers": [ - "off" + "error" ], "@typescript-eslint/no-misused-new": [ "error" @@ -177,7 +197,7 @@ "error" ], "@typescript-eslint/no-namespace": [ - "off" + "error" ], "@typescript-eslint/no-non-null-asserted-optional-chain": [ "error" @@ -186,7 +206,7 @@ "error" ], "@typescript-eslint/no-parameter-properties": [ - "off" + "warn" ], "@typescript-eslint/no-require-imports": [ "error" @@ -204,6 +224,9 @@ "@typescript-eslint/no-throw-literal": [ "error" ], + "@typescript-eslint/no-trailing-spaces": [ + "off" + ], "@typescript-eslint/no-unnecessary-qualifier": [ "error" ], @@ -217,16 +240,16 @@ "error" ], "@typescript-eslint/no-unsafe-argument": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-assignment": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-call": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-member-access": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-return": [ "error" @@ -235,20 +258,11 @@ "error" ], "@typescript-eslint/no-unused-vars": [ - "off" - ], - "@typescript-eslint/no-use-before-declare": [ - "off" - ], - "@typescript-eslint/no-use-before-define": [ - "off" + "warn" ], "@typescript-eslint/no-var-requires": [ "error" ], - "@typescript-eslint/object-curly-spacing": [ - "off" - ], "@typescript-eslint/prefer-as-const": [ "error" ], @@ -258,12 +272,30 @@ "@typescript-eslint/prefer-function-type": [ "error" ], + "@typescript-eslint/prefer-includes": [ + "error" + ], "@typescript-eslint/prefer-namespace-keyword": [ "error" ], + "@typescript-eslint/prefer-nullish-coalescing": [ + "error" + ], + "@typescript-eslint/prefer-optional-chain": [ + "error" + ], "@typescript-eslint/prefer-readonly": [ "error" ], + "@typescript-eslint/prefer-return-this-type": [ + "error" + ], + "@typescript-eslint/prefer-string-starts-ends-with": [ + "error" + ], + "@typescript-eslint/prefer-ts-expect-error": [ + "error" + ], "@typescript-eslint/promise-function-async": [ "error" ], @@ -276,18 +308,21 @@ } ], "@typescript-eslint/require-await": [ - "off" + "error" ], "@typescript-eslint/restrict-plus-operands": [ "error" ], "@typescript-eslint/restrict-template-expressions": [ - "off" + "error" ], "@typescript-eslint/semi": [ "error", "always" ], + "@typescript-eslint/sort-type-union-intersection-members": [ + "warn" + ], "@typescript-eslint/space-before-function-paren": [ "error", { @@ -299,30 +334,24 @@ "@typescript-eslint/space-infix-ops": [ "error" ], - "@typescript-eslint/strict-boolean-expressions": [ + "@typescript-eslint/switch-exhaustiveness-check": [ "error" ], "@typescript-eslint/triple-slash-reference": [ "error" ], - "@typescript-eslint/type-annotation-spacing": [ - "error" - ], - "@typescript-eslint/typedef": [ - "off" - ], "@typescript-eslint/unbound-method": [ "error", { "ignoreStatic": true } ], + "@typescript-eslint/unicode-bom": [ + "off" + ], "@typescript-eslint/unified-signatures": [ "error" ], - "arrow-body-style": [ - "off" - ], "arrow-parens": [ "error", "always" @@ -330,21 +359,12 @@ "brace-style": [ "off" ], - "camelcase": [ - "off" - ], - "capitalized-comments": [ - "off" - ], "comma-dangle": [ "off" ], "comma-spacing": [ "off" ], - "complexity": [ - "off" - ], "constructor-super": [ "error" ], @@ -357,9 +377,24 @@ "dot-notation": [ "off" ], - "eol-last": [ + "editorconfig/charset": [ + "error" + ], + "editorconfig/eol-last": [ + "error" + ], + "editorconfig/indent": [ + "off" + ], + "editorconfig/linebreak-style": [ "error" ], + "editorconfig/no-trailing-spaces": [ + "error" + ], + "eol-last": [ + "off" + ], "eqeqeq": [ "error", "smart" @@ -389,16 +424,13 @@ "off" ], "getter-return": [ - "off" - ], - "guard-for-in": [ "error" ], - "id-match": [ + "guard-for-in": [ "error" ], "import/default": [ - 2 + "off" ], "import/export": [ 2 @@ -407,13 +439,13 @@ "off" ], "import/namespace": [ - 2 + "off" ], "import/no-default-export": [ "error" ], "import/no-deprecated": [ - "off" + "warn" ], "import/no-duplicates": [ 1 @@ -434,33 +466,36 @@ 1 ], "import/no-named-as-default-member": [ - 1 + "off" + ], + "import/no-nodejs-modules": [ + "warn" ], "import/no-unassigned-import": [ "error" ], "import/no-unresolved": [ - 2, + "error", { "caseSensitive": true, "caseSensitiveStrict": false } ], "import/no-unused-modules": [ - "error" + "error", + { + "missingExports": true + } ], "import/order": [ "error" ], - "keyword-spacing": [ + "indent": [ "off" ], "linebreak-style": [ "off" ], - "max-classes-per-file": [ - "off" - ], "max-len": [ "error", { @@ -469,15 +504,6 @@ "ignoreStrings": false } ], - "max-lines": [ - "off" - ], - "new-parens": [ - "error" - ], - "newline-per-chained-call": [ - "off" - ], "no-array-constructor": [ "off" ], @@ -512,7 +538,7 @@ "error" ], "no-debugger": [ - "off" + "error" ], "no-delete-var": [ "error" @@ -536,7 +562,7 @@ "off" ], "no-empty": [ - "off" + "error" ], "no-empty-character-class": [ "error" @@ -560,7 +586,7 @@ "off" ], "no-fallthrough": [ - "off" + "error" ], "no-func-assign": [ "off" @@ -581,7 +607,7 @@ "error" ], "no-invalid-this": [ - "off" + "error" ], "no-irregular-whitespace": [ "error" @@ -604,9 +630,6 @@ "ignoreEOLComments": true } ], - "no-multi-str": [ - "off" - ], "no-multiple-empty-lines": [ "error", { @@ -651,10 +674,6 @@ "no-regex-spaces": [ "error" ], - "no-restricted-syntax": [ - "error", - "ForInStatement" - ], "no-return-await": [ "error" ], @@ -686,7 +705,7 @@ "off" ], "no-trailing-spaces": [ - "error" + "off" ], "no-undef": [ "off" @@ -694,9 +713,6 @@ "no-undef-init": [ "error" ], - "no-underscore-dangle": [ - "off" - ], "no-unexpected-multiline": [ "error" ], @@ -734,7 +750,7 @@ "error" ], "no-void": [ - "off" + "error" ], "no-whitespace-before-property": [ "error" @@ -742,9 +758,6 @@ "no-with": [ "error" ], - "object-curly-spacing": [ - "off" - ], "object-shorthand": [ "error" ], @@ -756,15 +769,6 @@ "error", "never" ], - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "next": "return", - "prev": "*" - } - ], "prefer-arrow-callback": [ "error" ], @@ -800,7 +804,7 @@ "error" ], "require-atomic-updates": [ - "off" + "error" ], "require-await": [ "off" @@ -811,21 +815,15 @@ "semi": [ "off" ], - "semi-spacing": [ - "error" - ], "space-before-blocks": [ "error" ], - "space-before-function-paren": [ - "off" - ], "space-in-parens": [ "error", "never" ], "space-infix-ops": [ - "off" + "error" ], "spaced-comment": [ "error", @@ -839,9 +837,39 @@ } } ], + "unicode-bom": [ + "off" + ], "unicorn/better-regex": [ "error" ], + "unicorn/catch-error-name": [ + "error" + ], + "unicorn/consistent-destructuring": [ + "error" + ], + "unicorn/consistent-function-scoping": [ + "error" + ], + "unicorn/custom-error-definition": [ + "off" + ], + "unicorn/empty-brace-spaces": [ + "off" + ], + "unicorn/error-message": [ + "error" + ], + "unicorn/escape-case": [ + "error" + ], + "unicorn/expiring-todo-comments": [ + "error" + ], + "unicorn/explicit-length-check": [ + "error" + ], "unicorn/filename-case": [ "error", { @@ -851,19 +879,271 @@ } } ], + "unicorn/import-index": [ + "off" + ], + "unicorn/import-style": [ + "error" + ], + "unicorn/new-for-builtins": [ + "error" + ], + "unicorn/no-abusive-eslint-disable": [ + "error" + ], + "unicorn/no-array-callback-reference": [ + "error" + ], + "unicorn/no-array-for-each": [ + "error" + ], + "unicorn/no-array-method-this-argument": [ + "error" + ], + "unicorn/no-array-push-push": [ + "error" + ], + "unicorn/no-array-reduce": [ + "error" + ], + "unicorn/no-await-expression-member": [ + "error" + ], + "unicorn/no-console-spaces": [ + "error" + ], + "unicorn/no-document-cookie": [ + "error" + ], + "unicorn/no-empty-file": [ + "error" + ], + "unicorn/no-for-loop": [ + "error" + ], + "unicorn/no-hex-escape": [ + "error" + ], + "unicorn/no-instanceof-array": [ + "error" + ], + "unicorn/no-invalid-remove-event-listener": [ + "error" + ], + "unicorn/no-keyword-prefix": [ + "off" + ], + "unicorn/no-lonely-if": [ + "error" + ], + "unicorn/no-nested-ternary": [ + "error" + ], + "unicorn/no-new-array": [ + "error" + ], "unicorn/no-new-buffer": [ "error" ], + "unicorn/no-null": [ + "error" + ], + "unicorn/no-object-as-default-parameter": [ + "error" + ], + "unicorn/no-process-exit": [ + "error" + ], + "unicorn/no-static-only-class": [ + "error" + ], + "unicorn/no-thenable": [ + "error" + ], + "unicorn/no-this-assignment": [ + "error" + ], + "unicorn/no-unreadable-array-destructuring": [ + "error" + ], "unicorn/no-unsafe-regex": [ "error" ], - "use-isnan": [ + "unicorn/no-unused-properties": [ + "off" + ], + "unicorn/no-useless-fallback-in-spread": [ "error" ], - "valid-typeof": [ + "unicorn/no-useless-length-check": [ + "error" + ], + "unicorn/no-useless-promise-resolve-reject": [ + "error" + ], + "unicorn/no-useless-spread": [ + "error" + ], + "unicorn/no-useless-undefined": [ + "error" + ], + "unicorn/no-zero-fractions": [ + "error" + ], + "unicorn/number-literal-case": [ + "error" + ], + "unicorn/numeric-separators-style": [ + "error" + ], + "unicorn/prefer-add-event-listener": [ + "error" + ], + "unicorn/prefer-array-find": [ + "error" + ], + "unicorn/prefer-array-flat": [ + "error" + ], + "unicorn/prefer-array-flat-map": [ + "error" + ], + "unicorn/prefer-array-index-of": [ + "error" + ], + "unicorn/prefer-array-some": [ + "error" + ], + "unicorn/prefer-at": [ + "error" + ], + "unicorn/prefer-code-point": [ + "error" + ], + "unicorn/prefer-date-now": [ + "error" + ], + "unicorn/prefer-default-parameters": [ + "error" + ], + "unicorn/prefer-dom-node-append": [ + "error" + ], + "unicorn/prefer-dom-node-dataset": [ + "error" + ], + "unicorn/prefer-dom-node-remove": [ + "error" + ], + "unicorn/prefer-dom-node-text-content": [ + "error" + ], + "unicorn/prefer-export-from": [ + "error" + ], + "unicorn/prefer-includes": [ + "error" + ], + "unicorn/prefer-json-parse-buffer": [ + "error" + ], + "unicorn/prefer-keyboard-event-key": [ + "error" + ], + "unicorn/prefer-math-trunc": [ + "error" + ], + "unicorn/prefer-modern-dom-apis": [ + "error" + ], + "unicorn/prefer-module": [ + "error" + ], + "unicorn/prefer-negative-index": [ + "error" + ], + "unicorn/prefer-node-protocol": [ "off" ], - "yoda": [ + "unicorn/prefer-number-properties": [ + "error" + ], + "unicorn/prefer-object-from-entries": [ + "error" + ], + "unicorn/prefer-optional-catch-binding": [ + "error" + ], + "unicorn/prefer-prototype-methods": [ + "error" + ], + "unicorn/prefer-query-selector": [ + "error" + ], + "unicorn/prefer-reflect-apply": [ + "error" + ], + "unicorn/prefer-regexp-test": [ + "error" + ], + "unicorn/prefer-set-has": [ + "error" + ], + "unicorn/prefer-spread": [ + "error" + ], + "unicorn/prefer-string-replace-all": [ + "off" + ], + "unicorn/prefer-string-slice": [ + "error" + ], + "unicorn/prefer-string-starts-ends-with": [ + "error" + ], + "unicorn/prefer-string-trim-start-end": [ + "error" + ], + "unicorn/prefer-switch": [ + "error" + ], + "unicorn/prefer-ternary": [ + "error" + ], + "unicorn/prefer-top-level-await": [ + "off" + ], + "unicorn/prefer-type-error": [ + "error" + ], + "unicorn/prevent-abbreviations": [ + "off" + ], + "unicorn/relative-url-style": [ + "error" + ], + "unicorn/require-array-join-separator": [ + "error" + ], + "unicorn/require-number-to-fixed-digits-argument": [ + "error" + ], + "unicorn/require-post-message-target-origin": [ + "off" + ], + "unicorn/string-content": [ + "off" + ], + "unicorn/template-indent": [ + "warn" + ], + "unicorn/throw-new-error": [ + "error" + ], + "use-isnan": [ + "error" + ], + "valid-typeof": [ "off" ] }, diff --git a/common/build/eslint-config-fluid/printed-configs/test.json b/common/build/eslint-config-fluid/printed-configs/test.json index 5873058d8739d..a597edd04c221 100644 --- a/common/build/eslint-config-fluid/printed-configs/test.json +++ b/common/build/eslint-config-fluid/printed-configs/test.json @@ -20,6 +20,8 @@ "plugins": [ "eslint-comments", "import", + "tsdoc", + "editorconfig", "unicorn", "react", "promise", @@ -30,7 +32,7 @@ "reportUnusedDisableDirectives": true, "rules": { "@rushstack/no-new-null": [ - "warn" + "error" ], "@rushstack/typedef-var": [ "off" @@ -51,7 +53,7 @@ "error" ], "@typescript-eslint/brace-style": [ - "off" + "error" ], "@typescript-eslint/comma-dangle": [ "error", @@ -60,14 +62,14 @@ "enums": "always-multiline", "exports": "always-multiline", "functions": "always-multiline", - "generics": "never", + "generics": "always-multiline", "imports": "always-multiline", "objects": "always-multiline", "tuples": "always-multiline" } ], "@typescript-eslint/comma-spacing": [ - "off" + "error" ], "@typescript-eslint/consistent-type-assertions": [ "error", @@ -77,37 +79,55 @@ } ], "@typescript-eslint/consistent-type-definitions": [ - "error" + "error", + "interface" + ], + "@typescript-eslint/consistent-type-imports": [ + "warn", + { + "prefer": "type-imports" + } ], "@typescript-eslint/dot-notation": [ "error" ], - "@typescript-eslint/explicit-function-return-type": [ + "@typescript-eslint/eol-last": [ "off" ], + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowConciseArrowFunctionExpressionsStartingWithVoid": false, + "allowDirectConstAssertionInArrowFunctions": true, + "allowExpressions": true, + "allowHigherOrderFunctions": true, + "allowTypedFunctionExpressions": true + } + ], "@typescript-eslint/explicit-member-accessibility": [ - "off" + "error", + { + "accessibility": "explicit", + "overrides": { + "accessors": "explicit", + "constructors": "explicit", + "methods": "explicit", + "parameterProperties": "explicit", + "properties": "explicit" + } + } ], "@typescript-eslint/explicit-module-boundary-types": [ - "off" - ], - "@typescript-eslint/func-call-spacing": [ - "off" + "error" ], "@typescript-eslint/indent": [ "off" ], - "@typescript-eslint/interface-name-prefix": [ - "off" - ], - "@typescript-eslint/keyword-spacing": [ + "@typescript-eslint/linebreak-style": [ "off" ], "@typescript-eslint/member-delimiter-style": [ - "off" - ], - "@typescript-eslint/member-ordering": [ - "off" + "error" ], "@typescript-eslint/naming-convention": [ "error", @@ -132,13 +152,13 @@ "error" ], "@typescript-eslint/no-empty-function": [ - "off" + "error" ], "@typescript-eslint/no-empty-interface": [ "error" ], "@typescript-eslint/no-explicit-any": [ - "off" + "warn" ], "@typescript-eslint/no-extra-non-null-assertion": [ "error" @@ -162,13 +182,13 @@ "off" ], "@typescript-eslint/no-invalid-this": [ - "off" + "error" ], "@typescript-eslint/no-loss-of-precision": [ "error" ], "@typescript-eslint/no-magic-numbers": [ - "off" + "error" ], "@typescript-eslint/no-misused-new": [ "error" @@ -177,7 +197,7 @@ "error" ], "@typescript-eslint/no-namespace": [ - "off" + "error" ], "@typescript-eslint/no-non-null-asserted-optional-chain": [ "error" @@ -186,7 +206,7 @@ "error" ], "@typescript-eslint/no-parameter-properties": [ - "off" + "warn" ], "@typescript-eslint/no-require-imports": [ "error" @@ -204,6 +224,9 @@ "@typescript-eslint/no-throw-literal": [ "error" ], + "@typescript-eslint/no-trailing-spaces": [ + "off" + ], "@typescript-eslint/no-unnecessary-qualifier": [ "error" ], @@ -217,16 +240,16 @@ "error" ], "@typescript-eslint/no-unsafe-argument": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-assignment": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-call": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-member-access": [ - "off" + "error" ], "@typescript-eslint/no-unsafe-return": [ "error" @@ -235,20 +258,11 @@ "error" ], "@typescript-eslint/no-unused-vars": [ - "off" - ], - "@typescript-eslint/no-use-before-declare": [ - "off" - ], - "@typescript-eslint/no-use-before-define": [ - "off" + "warn" ], "@typescript-eslint/no-var-requires": [ "error" ], - "@typescript-eslint/object-curly-spacing": [ - "off" - ], "@typescript-eslint/prefer-as-const": [ "error" ], @@ -258,12 +272,30 @@ "@typescript-eslint/prefer-function-type": [ "error" ], + "@typescript-eslint/prefer-includes": [ + "error" + ], "@typescript-eslint/prefer-namespace-keyword": [ "error" ], + "@typescript-eslint/prefer-nullish-coalescing": [ + "error" + ], + "@typescript-eslint/prefer-optional-chain": [ + "error" + ], "@typescript-eslint/prefer-readonly": [ "error" ], + "@typescript-eslint/prefer-return-this-type": [ + "error" + ], + "@typescript-eslint/prefer-string-starts-ends-with": [ + "error" + ], + "@typescript-eslint/prefer-ts-expect-error": [ + "error" + ], "@typescript-eslint/promise-function-async": [ "error" ], @@ -276,18 +308,21 @@ } ], "@typescript-eslint/require-await": [ - "off" + "error" ], "@typescript-eslint/restrict-plus-operands": [ "error" ], "@typescript-eslint/restrict-template-expressions": [ - "off" + "error" ], "@typescript-eslint/semi": [ "error", "always" ], + "@typescript-eslint/sort-type-union-intersection-members": [ + "warn" + ], "@typescript-eslint/space-before-function-paren": [ "error", { @@ -299,30 +334,24 @@ "@typescript-eslint/space-infix-ops": [ "error" ], - "@typescript-eslint/strict-boolean-expressions": [ + "@typescript-eslint/switch-exhaustiveness-check": [ "error" ], "@typescript-eslint/triple-slash-reference": [ "error" ], - "@typescript-eslint/type-annotation-spacing": [ - "error" - ], - "@typescript-eslint/typedef": [ - "off" - ], "@typescript-eslint/unbound-method": [ "off", { "ignoreStatic": true } ], + "@typescript-eslint/unicode-bom": [ + "off" + ], "@typescript-eslint/unified-signatures": [ "error" ], - "arrow-body-style": [ - "off" - ], "arrow-parens": [ "error", "always" @@ -330,21 +359,12 @@ "brace-style": [ "off" ], - "camelcase": [ - "off" - ], - "capitalized-comments": [ - "off" - ], "comma-dangle": [ "off" ], "comma-spacing": [ "off" ], - "complexity": [ - "off" - ], "constructor-super": [ "error" ], @@ -357,9 +377,24 @@ "dot-notation": [ "off" ], - "eol-last": [ + "editorconfig/charset": [ + "error" + ], + "editorconfig/eol-last": [ + "error" + ], + "editorconfig/indent": [ + "off" + ], + "editorconfig/linebreak-style": [ "error" ], + "editorconfig/no-trailing-spaces": [ + "error" + ], + "eol-last": [ + "off" + ], "eqeqeq": [ "error", "smart" @@ -389,16 +424,13 @@ "off" ], "getter-return": [ - "off" - ], - "guard-for-in": [ "error" ], - "id-match": [ + "guard-for-in": [ "error" ], "import/default": [ - 2 + "off" ], "import/export": [ 2 @@ -407,13 +439,13 @@ "off" ], "import/namespace": [ - 2 + "off" ], "import/no-default-export": [ "error" ], "import/no-deprecated": [ - "off" + "warn" ], "import/no-duplicates": [ 1 @@ -434,33 +466,36 @@ 1 ], "import/no-named-as-default-member": [ - 1 + "off" + ], + "import/no-nodejs-modules": [ + "warn" ], "import/no-unassigned-import": [ "error" ], "import/no-unresolved": [ - 2, + "error", { "caseSensitive": true, "caseSensitiveStrict": false } ], "import/no-unused-modules": [ - "error" + "error", + { + "missingExports": true + } ], "import/order": [ "error" ], - "keyword-spacing": [ + "indent": [ "off" ], "linebreak-style": [ "off" ], - "max-classes-per-file": [ - "off" - ], "max-len": [ "error", { @@ -469,15 +504,6 @@ "ignoreStrings": false } ], - "max-lines": [ - "off" - ], - "new-parens": [ - "error" - ], - "newline-per-chained-call": [ - "off" - ], "no-array-constructor": [ "off" ], @@ -512,7 +538,7 @@ "error" ], "no-debugger": [ - "off" + "error" ], "no-delete-var": [ "error" @@ -536,7 +562,7 @@ "off" ], "no-empty": [ - "off" + "error" ], "no-empty-character-class": [ "error" @@ -560,7 +586,7 @@ "off" ], "no-fallthrough": [ - "off" + "error" ], "no-func-assign": [ "off" @@ -581,7 +607,7 @@ "error" ], "no-invalid-this": [ - "off" + "error" ], "no-irregular-whitespace": [ "error" @@ -604,9 +630,6 @@ "ignoreEOLComments": true } ], - "no-multi-str": [ - "off" - ], "no-multiple-empty-lines": [ "error", { @@ -651,10 +674,6 @@ "no-regex-spaces": [ "error" ], - "no-restricted-syntax": [ - "error", - "ForInStatement" - ], "no-return-await": [ "error" ], @@ -686,7 +705,7 @@ "off" ], "no-trailing-spaces": [ - "error" + "off" ], "no-undef": [ "off" @@ -694,9 +713,6 @@ "no-undef-init": [ "error" ], - "no-underscore-dangle": [ - "off" - ], "no-unexpected-multiline": [ "error" ], @@ -734,7 +750,7 @@ "error" ], "no-void": [ - "off" + "error" ], "no-whitespace-before-property": [ "error" @@ -742,9 +758,6 @@ "no-with": [ "error" ], - "object-curly-spacing": [ - "off" - ], "object-shorthand": [ "error" ], @@ -756,15 +769,6 @@ "error", "never" ], - "padding-line-between-statements": [ - "off", - "error", - { - "blankLine": "always", - "next": "return", - "prev": "*" - } - ], "prefer-arrow-callback": [ "error" ], @@ -800,7 +804,7 @@ "error" ], "require-atomic-updates": [ - "off" + "error" ], "require-await": [ "off" @@ -811,21 +815,15 @@ "semi": [ "off" ], - "semi-spacing": [ - "error" - ], "space-before-blocks": [ "error" ], - "space-before-function-paren": [ - "off" - ], "space-in-parens": [ "error", "never" ], "space-infix-ops": [ - "off" + "error" ], "spaced-comment": [ "error", @@ -839,9 +837,39 @@ } } ], + "unicode-bom": [ + "off" + ], "unicorn/better-regex": [ "error" ], + "unicorn/catch-error-name": [ + "error" + ], + "unicorn/consistent-destructuring": [ + "error" + ], + "unicorn/consistent-function-scoping": [ + "error" + ], + "unicorn/custom-error-definition": [ + "off" + ], + "unicorn/empty-brace-spaces": [ + "off" + ], + "unicorn/error-message": [ + "error" + ], + "unicorn/escape-case": [ + "error" + ], + "unicorn/expiring-todo-comments": [ + "error" + ], + "unicorn/explicit-length-check": [ + "error" + ], "unicorn/filename-case": [ "error", { @@ -851,19 +879,271 @@ } } ], + "unicorn/import-index": [ + "off" + ], + "unicorn/import-style": [ + "error" + ], + "unicorn/new-for-builtins": [ + "error" + ], + "unicorn/no-abusive-eslint-disable": [ + "error" + ], + "unicorn/no-array-callback-reference": [ + "error" + ], + "unicorn/no-array-for-each": [ + "error" + ], + "unicorn/no-array-method-this-argument": [ + "error" + ], + "unicorn/no-array-push-push": [ + "error" + ], + "unicorn/no-array-reduce": [ + "error" + ], + "unicorn/no-await-expression-member": [ + "error" + ], + "unicorn/no-console-spaces": [ + "error" + ], + "unicorn/no-document-cookie": [ + "error" + ], + "unicorn/no-empty-file": [ + "error" + ], + "unicorn/no-for-loop": [ + "error" + ], + "unicorn/no-hex-escape": [ + "error" + ], + "unicorn/no-instanceof-array": [ + "error" + ], + "unicorn/no-invalid-remove-event-listener": [ + "error" + ], + "unicorn/no-keyword-prefix": [ + "off" + ], + "unicorn/no-lonely-if": [ + "error" + ], + "unicorn/no-nested-ternary": [ + "error" + ], + "unicorn/no-new-array": [ + "error" + ], "unicorn/no-new-buffer": [ "error" ], + "unicorn/no-null": [ + "error" + ], + "unicorn/no-object-as-default-parameter": [ + "error" + ], + "unicorn/no-process-exit": [ + "error" + ], + "unicorn/no-static-only-class": [ + "error" + ], + "unicorn/no-thenable": [ + "error" + ], + "unicorn/no-this-assignment": [ + "error" + ], + "unicorn/no-unreadable-array-destructuring": [ + "error" + ], "unicorn/no-unsafe-regex": [ "error" ], - "use-isnan": [ + "unicorn/no-unused-properties": [ + "off" + ], + "unicorn/no-useless-fallback-in-spread": [ "error" ], - "valid-typeof": [ + "unicorn/no-useless-length-check": [ + "error" + ], + "unicorn/no-useless-promise-resolve-reject": [ + "error" + ], + "unicorn/no-useless-spread": [ + "error" + ], + "unicorn/no-useless-undefined": [ + "error" + ], + "unicorn/no-zero-fractions": [ + "error" + ], + "unicorn/number-literal-case": [ + "error" + ], + "unicorn/numeric-separators-style": [ + "error" + ], + "unicorn/prefer-add-event-listener": [ + "error" + ], + "unicorn/prefer-array-find": [ + "error" + ], + "unicorn/prefer-array-flat": [ + "error" + ], + "unicorn/prefer-array-flat-map": [ + "error" + ], + "unicorn/prefer-array-index-of": [ + "error" + ], + "unicorn/prefer-array-some": [ + "error" + ], + "unicorn/prefer-at": [ + "error" + ], + "unicorn/prefer-code-point": [ + "error" + ], + "unicorn/prefer-date-now": [ + "error" + ], + "unicorn/prefer-default-parameters": [ + "error" + ], + "unicorn/prefer-dom-node-append": [ + "error" + ], + "unicorn/prefer-dom-node-dataset": [ + "error" + ], + "unicorn/prefer-dom-node-remove": [ + "error" + ], + "unicorn/prefer-dom-node-text-content": [ + "error" + ], + "unicorn/prefer-export-from": [ + "error" + ], + "unicorn/prefer-includes": [ + "error" + ], + "unicorn/prefer-json-parse-buffer": [ + "error" + ], + "unicorn/prefer-keyboard-event-key": [ + "error" + ], + "unicorn/prefer-math-trunc": [ + "error" + ], + "unicorn/prefer-modern-dom-apis": [ + "error" + ], + "unicorn/prefer-module": [ + "error" + ], + "unicorn/prefer-negative-index": [ + "error" + ], + "unicorn/prefer-node-protocol": [ "off" ], - "yoda": [ + "unicorn/prefer-number-properties": [ + "error" + ], + "unicorn/prefer-object-from-entries": [ + "error" + ], + "unicorn/prefer-optional-catch-binding": [ + "error" + ], + "unicorn/prefer-prototype-methods": [ + "error" + ], + "unicorn/prefer-query-selector": [ + "error" + ], + "unicorn/prefer-reflect-apply": [ + "error" + ], + "unicorn/prefer-regexp-test": [ + "error" + ], + "unicorn/prefer-set-has": [ + "error" + ], + "unicorn/prefer-spread": [ + "error" + ], + "unicorn/prefer-string-replace-all": [ + "off" + ], + "unicorn/prefer-string-slice": [ + "error" + ], + "unicorn/prefer-string-starts-ends-with": [ + "error" + ], + "unicorn/prefer-string-trim-start-end": [ + "error" + ], + "unicorn/prefer-switch": [ + "error" + ], + "unicorn/prefer-ternary": [ + "error" + ], + "unicorn/prefer-top-level-await": [ + "off" + ], + "unicorn/prefer-type-error": [ + "error" + ], + "unicorn/prevent-abbreviations": [ + "off" + ], + "unicorn/relative-url-style": [ + "error" + ], + "unicorn/require-array-join-separator": [ + "error" + ], + "unicorn/require-number-to-fixed-digits-argument": [ + "error" + ], + "unicorn/require-post-message-target-origin": [ + "off" + ], + "unicorn/string-content": [ + "off" + ], + "unicorn/template-indent": [ + "warn" + ], + "unicorn/throw-new-error": [ + "error" + ], + "use-isnan": [ + "error" + ], + "valid-typeof": [ "off" ] }, diff --git a/common/build/eslint-config-fluid/recommended.js b/common/build/eslint-config-fluid/recommended.js deleted file mode 100644 index ec44df5750307..0000000000000 --- a/common/build/eslint-config-fluid/recommended.js +++ /dev/null @@ -1,52 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -module.exports = { - "extends": [ - "./minimal.js", - "plugin:unicorn/recommended", - "plugin:editorconfig/all", - ], - "plugins": [ - "editorconfig", - "eslint-plugin-tsdoc", - ], - "rules": { - // RECOMMENDED RULES - "@rushstack/no-new-null": "error", - "no-empty": "error", - "no-void": "error", - "require-atomic-updates": "error", - - // This rule ensures that our Intellisense looks good by verifying the TSDoc syntax. - "tsdoc/syntax": "error", - - // In some cases, type inference can be wrong, and this can cause a "flip-flop" of type changes in our - // API documentation. For example, type inference might decide a function returns a concrete type - // instead of an interface. This has no runtime impact, but would cause compilation problems. - "@typescript-eslint/explicit-function-return-type": [ - "error", - { - "allowExpressions": false, - "allowTypedFunctionExpressions": true, - "allowHigherOrderFunctions": true, - "allowDirectConstAssertionInArrowFunctions": true, - "allowConciseArrowFunctionExpressionsStartingWithVoid": false, - } - ], - "unicorn/empty-brace-spaces": "off", - "unicorn/prevent-abbreviations": "off", - }, - "overrides": [ - { - // Rules only for TypeScript files - "files": ["**/*.{ts,tsx}"], - "rules": { - "editorconfig/indent": "off", // We use tsfmt for "official" formatting. - } - } - ] -}; - diff --git a/common/build/eslint-config-fluid/scripts/cleanup-printed-configs.js b/common/build/eslint-config-fluid/scripts/cleanup-printed-configs.js index f72f3a2ee2a72..191f010d991c8 100644 --- a/common/build/eslint-config-fluid/scripts/cleanup-printed-configs.js +++ b/common/build/eslint-config-fluid/scripts/cleanup-printed-configs.js @@ -8,16 +8,15 @@ const path = require("path"); const sortJson = require("sort-json"); (async () => { - const myArgs = process.argv.slice(2); - const sourcePath = myArgs[0] ? myArgs[0] : undefined; + const args = process.argv.slice(2); + const sourcePath = args[0]; const files = await fs.promises.readdir(sourcePath); for (const file of files) { - let json; let filePath = path.join(sourcePath, file); let content = fs.readFileSync(filePath); - json = JSON.parse(content); + let json = JSON.parse(content); // Remove the parser property because it's an absolute path and will vary based on the local environment. delete json.parser; diff --git a/common/build/eslint-config-fluid/shared-config.js b/common/build/eslint-config-fluid/shared-config.js new file mode 100644 index 0000000000000..647ca95875b1c --- /dev/null +++ b/common/build/eslint-config-fluid/shared-config.js @@ -0,0 +1,682 @@ +/*! + * Copyright (c) Microsoft Corporation and contributors. All rights reserved. + * Licensed under the MIT License. + */ + +module.exports = { + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": [ + "eslint:recommended", + "plugin:eslint-comments/recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:@typescript-eslint/recommended-requiring-type-checking", + "plugin:unicorn/recommended", + "plugin:editorconfig/all", + "plugin:editorconfig/noconflict", + "plugin:import/errors", + "plugin:import/warnings", + "plugin:import/typescript", + ], + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 2018, + "sourceType": "module", + "project": "./tsconfig.json", + }, + "plugins": [ + // Plugin documentation: https://www.npmjs.com/package/@rushstack/eslint-plugin + "@rushstack/eslint-plugin", + // Plugin documentation: https://www.npmjs.com/package/@rushstack/eslint-plugin-security + "@rushstack/eslint-plugin-security", + // Plugin documentation: https://www.npmjs.com/package/@typescript-eslint/eslint-plugin + "@typescript-eslint/eslint-plugin", + // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-promise + "eslint-plugin-promise", + // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-react + "react", + // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-unicorn + "unicorn", + // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-editorconfig + "editorconfig", + // Plugin documentation: https://www.npmjs.com/package/eslint-plugin-tsdoc + "eslint-plugin-tsdoc", + ], + "reportUnusedDisableDirectives": true, + "rules": { + // Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require + // null. + "@rushstack/no-new-null": "error", + + // Disabled because we don't require that all variable declarations be explicitly typed. + "@rushstack/typedef-var": "off", + + // Use default array type (e.g. MyArray: int[]) consistently. + "@typescript-eslint/array-type": "error", + + // Enforce consistent brace style for blocks. + "@typescript-eslint/brace-style": "error", + + // Use dangling commas where possible. + "@typescript-eslint/comma-dangle": [ + "error", + { + "arrays": "always-multiline", + "enums": "always-multiline", + "exports": "always-multiline", + "functions": "always-multiline", + "generics": "always-multiline", + "imports": "always-multiline", + "objects": "always-multiline", + "tuples": "always-multiline", + } + ], + + // Enforces consistent spacing before and after commas. + "@typescript-eslint/comma-spacing": "error", + + // Enforces consistent usage of type assertions. + "@typescript-eslint/consistent-type-assertions": [ + "error", + { + "assertionStyle": "as", + "objectLiteralTypeAssertions": "never" + } + ], + + // Prefer `interface` over `type` when defining types. + "@typescript-eslint/consistent-type-definitions": ["error", "interface"], + + // Prefer type-only imports where possible, + "@typescript-eslint/consistent-type-imports": [ + "warn", + { + prefer: "type-imports" + } + ], + + // Enforce dot notation whenever possible. + "@typescript-eslint/dot-notation": "error", + + // Require all members have explicit private/public/etc. + "@typescript-eslint/explicit-member-accessibility": [ + "error", + { + accessibility: "explicit", + overrides: { + accessors: "explicit", + constructors: "explicit", + methods: "explicit", + properties: "explicit", + parameterProperties: "explicit" + } + }, + ], + + // Requires explicit typing for anything exported from a module. Explicit types for function return values and + // arguments makes it clear to any calling code what is the module boundary's input and output. + "@typescript-eslint/explicit-module-boundary-types": "error", + + // Standardize using semicolons to delimit members for interfaces and type literals. + "@typescript-eslint/member-delimiter-style": "error", + + // Our guideline is to only use leading underscores on private members when required to avoid a conflict between + // private fields and a public property. + "@typescript-eslint/naming-convention": [ + "error", + { + selector: "accessor", + modifiers: ["private"], + format: ["camelCase"], + "leadingUnderscore": "allow" + }, + ], + + // Disallow duplicate imports. + "@typescript-eslint/no-duplicate-imports": "error", + + // Disallow the delete operator with computed key expressions. Deleting dynamically computed keys can be + // dangerous and in some cases not well optimized. + "@typescript-eslint/no-dynamic-delete": "error", + + // Disallow empty functions. + "@typescript-eslint/no-empty-function": "error", + + // Disallow the declaration of empty interfaces. An empty interface is equivalent to its supertype. If the + // interface does not implement a supertype, then the interface is equivalent to an empty object ({}). In both + // cases it can be omitted. + "@typescript-eslint/no-empty-interface": "error", + + // In some cases, type inference can be wrong, and this can cause a "flip-flop" of type changes in our + // API documentation. For example, type inference might decide a function returns a concrete type + // instead of an interface. This has no runtime impact, but would cause compilation problems. + "@typescript-eslint/explicit-function-return-type": [ + "error", + { + "allowExpressions": true, + "allowTypedFunctionExpressions": true, + "allowHigherOrderFunctions": true, + "allowDirectConstAssertionInArrowFunctions": true, + "allowConciseArrowFunctionExpressionsStartingWithVoid": false, + } + ], + + // Forbids the use of classes as namespaces. + "@typescript-eslint/no-extraneous-class": "error", + + // This rule disallows explicit type declarations for inferrable types. Disabled because sometimes explicit + // type declarations help readability. + "@typescript-eslint/no-inferrable-types": "off", + + // Disallow this keywords outside of classes or class-like objects. + "@typescript-eslint/no-invalid-this": "error", + + // Disallow magic numbers. + "@typescript-eslint/no-magic-numbers": "error", + + // Disallows non-null assertions using the `!` postfix operator. + "@typescript-eslint/no-non-null-assertion": "error", + + // Parameter properties can be confusing to those new to TypeScript as they are less explicit than other + // ways of declaring and initializing class members. + "@typescript-eslint/no-parameter-properties": "warn", + + // Prefer ES6-style imports over require(). + "@typescript-eslint/no-require-imports": "error", + + // Disallow variable declarations from shadowing variables declared in the outer scope. + "@typescript-eslint/no-shadow": [ + "error", + { + "hoist": "all", + "ignoreTypeValueShadow": true, + } + ], + + // Disallow throwing literals as exceptions. It is considered good practice to only throw the Error object + // itself or an object using the Error object as base objects for user-defined exceptions. The fundamental + // benefit of Error objects is that they automatically keep track of where they were built and originated. + "@typescript-eslint/no-throw-literal": "error", + + // Disallows non-null assertions using the `!` postfix operator. + "@typescript-eslint/no-unnecessary-qualifier": "error", + + // Enforces that type arguments will not be used if not required. + "@typescript-eslint/no-unnecessary-type-arguments": "error", + + // Prohibits using a type assertion that does not change the type of an expression. + "@typescript-eslint/no-unnecessary-type-assertion": "error", + + // Disallows assigning any to a variable, and assigning any[] to an array destructuring. Assigning an + // any typed value to a variable can be hard to pick up on, particularly if it leaks in from an external + // library. + "@typescript-eslint/no-unsafe-assignment": "error", + + // Disallows calling any variable that is typed as any. The arguments to, and return value of calling an + // any typed variable are not checked at all by TypeScript. + "@typescript-eslint/no-unsafe-call": "error", + + // Disallows member access on any variable that is typed as any. The arguments to, and return value of + // calling an any typed variable are not checked at all by TypeScript. + "@typescript-eslint/no-unsafe-member-access": "error", + + // Disallow unused expressions. + "@typescript-eslint/no-unused-expressions": "error", + + // Prefer a `for-of` loop over a standard `for` loop if the index is only used to access the array being + // iterated. + "@typescript-eslint/prefer-for-of": "error", + + // Use function types instead of interfaces with call signatures. + "@typescript-eslint/prefer-function-type": "error", + + // Enforce includes method over indexOf method. + "@typescript-eslint/prefer-includes": "error", + + // Require the use of the namespace keyword instead of the module keyword to declare custom TypeScript modules. + "@typescript-eslint/prefer-namespace-keyword": "error", + + // Enforce the usage of the nullish coalescing operator instead of logical chaining. + "@typescript-eslint/prefer-nullish-coalescing": "error", + + // Prefer using concise optional chain expressions instead of chained logical ands. + "@typescript-eslint/prefer-optional-chain": "error", + + // Requires that private members are marked as readonly if they're never modified outside of the constructor. + "@typescript-eslint/prefer-readonly": "error", + + // Enforce that `this` is used when only `this` type is returned. Method chaining is a common pattern in OOP + // languages and TypeScript provides a special polymorphic `this` type. If any type other than `this` is + // specified as the return type of these chaining methods, TypeScript will fail to cast it when invoking in + // subclass. + "@typescript-eslint/prefer-return-this-type": "error", + + // Enforce the use of String#startsWith and String#endsWith instead of other equivalent methods of checking + // substrings. + "@typescript-eslint/prefer-string-starts-ends-with": "error", + + // Recommends using @ts-expect-error over @ts-ignore. + "@typescript-eslint/prefer-ts-expect-error": "error", + + // Requires any function or method that returns a Promise to be marked async. + "@typescript-eslint/promise-function-async": "error", + + // Enforce the consistent use of double quotes. + "@typescript-eslint/quotes": [ + "error", + "double", + { + "allowTemplateLiterals": true, + "avoidEscape": true + } + ], + + // Disallow `async` functions which have no await expression. + "@typescript-eslint/require-await": "error", + + // When adding two variables, operands must both be of type number or of type string. + "@typescript-eslint/restrict-plus-operands": "error", + + // Enforce template literal expressions to be of string type. + "@typescript-eslint/restrict-template-expressions": "error", + + "@typescript-eslint/semi": [ + "error", + "always" + ], + + // Enforces that members of a type union/intersection are sorted alphabetically. + "@typescript-eslint/sort-type-union-intersection-members": "warn", + + // Enforces consistent spacing before function parentheses. + "@typescript-eslint/space-before-function-paren": [ + "error", + { + "anonymous": "never", + "asyncArrow": "always", + "named": "never" + } + ], + + // This rule is aimed at ensuring there are spaces around infix operators. + "@typescript-eslint/space-infix-ops": "error", + + // Exhaustiveness checking in switch with union type. + "@typescript-eslint/switch-exhaustiveness-check": "error", + + // Enforces unbound methods are called with their expected scope. Warns when a method is used outside of a + // method call. Class functions don't preserve the class scope when passed as standalone variables. + "@typescript-eslint/unbound-method": [ + "error", + { + "ignoreStatic": true + } + ], + + // Warns for any two overloads that could be unified into one by using a union or an optional/rest parameter. + "@typescript-eslint/unified-signatures": "error", + + "arrow-parens": [ + "error", + "always" + ], + + // Superseded by @typescript-eslint/brace-style. + "brace-style": "off", + + // Superseded by @typescript-eslint/comma-dangle. + "comma-dangle": "off", + + // Superseded by @typescript-eslint/comma-spacing. + "comma-spacing": "off", + + // Constructors must call super(). + "constructor-super": "error", + + // Requires following curly brace conventions. + "curly": "error", + + // Requires a default case in switch statements. + "default-case": "error", + + // Disabled becuase it doesn't work well for all our files. + "editorconfig/indent": "off", + + // Requires the use of === and !==. + "eqeqeq": [ + "error", + "smart" + ], + + // Requires that eslint disable comments have a start and an end, rather than being open-ended. Encourages + // minimal disabling of eslint rules, while still permitting whole-file exclusions. + "eslint-comments/disable-enable-pair": [ + "error", { + "allowWholeFile": true + } + ], + + // Superseded by @typescript-eslint/func-call-spacing. + "func-call-spacing": "off", + + // Enforces that a return statement is present in property getters. + "getter-return": "error", + + // Requires for in loops to include an if statement. + "guard-for-in": "error", + + // Disabled because TypeScript already checks this. https://typescript-eslint.io/docs/linting/troubleshooting/#eslint-plugin-import + "import/default": "off", + + // Disabled because TypeScript already checks this. https://typescript-eslint.io/docs/linting/troubleshooting/#eslint-plugin-import + "import/namespace": "off", + + // Prohibit default exports. + "import/no-default-export": "error", + + // Reports use of a deprecated name. + "import/no-deprecated": "warn", + + // Forbid the import of external modules that are not declared in package.json. + "import/no-extraneous-dependencies": [ + "error", + { + "devDependencies": ["**/*.spec.ts", "src/test/**"] + } + ], + + // Prevent importing the submodules of other modules. + "import/no-internal-modules": "error", + + // Disabled because TypeScript already checks this. https://typescript-eslint.io/docs/linting/troubleshooting/#eslint-plugin-import + "import/no-named-as-default-member": "off", + + // Forbid nodejs modules; + "import/no-nodejs-modules": "warn", + + // Forbid unassigned imports. + "import/no-unassigned-import": "error", + + // Ensures an imported module can be resolved to a module on the local filesystem. + "import/no-unresolved": [ + "error", + { + "caseSensitive": true + } + ], + + // Requires that modules have a export. + "import/no-unused-modules": [ + "error", + { + "missingExports": true + } + ], + + // Enforce a convention in the order of require() / import statements. + "import/order": "error", + + // Enforces a maximum line length. + "max-len": [ + "error", + { + "ignoreRegExpLiterals": false, + "ignoreStrings": false, + "code": 120 + } + ], + + // Disallows bitwise operators. The use of bitwise operators in JavaScript is very rare and often & or | is + // simply a mistyped && or ||, which will lead to unexpected behavior. + "no-bitwise": "error", + + // Disallows use of caller/callee. The use of arguments.caller and arguments.callee make several code + // optimizations impossible. They have been deprecated in future versions of JavaScript and their use is + // forbidden in ES5 while in strict mode. + "no-caller": "error", + + // Superseded by @typescript-eslint/no-empty-function. + "no-empty-function": "off", + + // Superseded by @typescript-eslint/no-duplicate-imports. + "no-duplicate-imports": "off", + + // Disallows eval(). JavaScript's eval() function is potentially dangerous and is often misused. Using eval() on + // untrusted code can open a program up to several different injection attacks. The use of eval() in most + // contexts can be substituted for a better, alternative approach to a problem. + "no-eval": "error", + + // Disallows case statement fallthroughs. + "no-fallthrough": "error", + + // Disallows use of this in contexts where the value of this is undefined. Under the strict mode, this keywords + // outside of classes or class-like objects might be undefined and raise a TypeError. + "no-invalid-this": "error", + + // Superseded by @typescript-eslint/no-magic-numbers. + "no-magic-numbers": "off", + + // Disallows multiple consecutive spaces. + "no-multi-spaces": [ + "error", + { + "ignoreEOLComments": true + } + ], + + // Prevent multiple empty lines. + "no-multiple-empty-lines": [ + "error", + { + "max": 1, + "maxBOF": 0, + "maxEOF": 0, + } + ], + + // Disallows whitespace before properties. + "no-whitespace-before-property": "error", + + // Disallows new operators with the Function object. + "no-new-func": "error", + + // Disallows new operators with the String, Number, and Boolean objects. + "no-new-wrappers": "error", + + // Disallows octal escape sequences in string literals. + "no-octal-escape": "error", + + // Disallows reassignment of function parameters. + "no-param-reassign": "error", + + // Superseded by @typescript-eslint/no-redeclare. + "no-redeclare": "off", + + // Disallows unnecessary return await. Using return await inside an async function keeps the current function in + // the call stack until the Promise that is being awaited has resolved, at the cost of an extra microtask before + // resolving the outer Promise. return await can also be used in a try/catch statement to catch errors from + // another function that returns a Promise. + "no-return-await": "error", + + // Disallows use of the comma operator. + "no-sequences": "error", + + // Superseded by @typescript-eslint/no-shadow. + "no-shadow": "off", + + // Disallows template literal placeholder syntax in regular strings. + "no-template-curly-in-string": "error", + + // Superseded by @typescript-eslint/no-throw-literal. + "no-throw-literal": "off", + + // Disallows initializing variables to undefined. + "no-undef-init": "error", + + // Superseded by @typescript-eslint/no-unused-expressions. + "no-unused-expressions": "off", + + // Disallows use of the void operator. + "no-void": "error", + + // Enforces the use of the shorthand syntax. + "object-shorthand": "error", + + // Require variables to be declared either together or separately in functions. + "one-var": [ + "error", + "never" + ], + + // Disallows empty lines at the beginning and ending of block statements, function bodies, class static blocks, + // classes, and switch statements. + "padded-blocks": [ + "error", + "never" + ], + + // Require using arrow functions for callbacks. + "prefer-arrow-callback": "error", + + // Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread + // instead. + "prefer-object-spread": "error", + + // Requires using Error objects as Promise rejection reasons. + "prefer-promise-reject-errors": "error", + + // Require template literals instead of string concatenation. + "prefer-template": "error", + + // Catches a common coding mistake where "resolve" and "reject" are confused. + "promise/param-names": "warn", + + // Require quotes around object literal property names. + "quote-props": [ + "error", + "consistent-as-needed" + ], + + // Superseded by @typescript-eslint/quotes. + "quotes": "off", + + // Enforces the consistent use of the radix argument when using parseInt(). + "radix": "error", + + // Disallow assignments that can lead to race conditions due to usage of `await` or `yield`. + "require-atomic-updates": "error", + + // Superseded by @typescript-eslint/require-await. + "require-await": "off", + + // Superseded by @typescript-eslint/semi. + "semi": "off", + + // Enforce consistent spacing before blocks. + "space-before-blocks": "error", + + // Superseded by @typescript-eslint/space-infix-ops. + "space-infix-ops": "error", + + // Enforce consistent spacing inside parentheses. + "space-in-parens": [ + "error", + "never" + ], + + // Enforces consistent spacing after the // or /* in a comment. + "spaced-comment": [ + "error", + "always", + { + "block": { + "markers": ["!"], + "balanced": true + } + } + ], + + "unicorn/empty-brace-spaces": "off", + + // Enforces all linted files to have their names in a certain case style and lowercase file extension. + "unicorn/filename-case": [ + "error", + { + "cases": { + "camelCase": true, + "pascalCase": true + } + } + ], + + // Disallow potentially catastrophic exponential-time regular expressions. + "unicorn/no-unsafe-regex": "error", + + // Disabled because it interferes with our automated assert tagging. + "unicorn/numeric-separators-style": "off", + + // Prefer .at() method for index access and String#charAt(). + "unicorn/prefer-at": "error", + + // Disabled because the node protocol causes problems, especially for isomorphic packages. + "unicorn/prefer-node-protocol": "off", + + // Disabled because we don't care about using abbreviations. + "unicorn/prevent-abbreviations": "off", + }, + "overrides": [ + { + // Rules only for TypeScript files + "files": ["*.ts", "*.tsx"], + "rules": { + "dot-notation": "off", // Superseded by @typescript-eslint/dot-notation + "no-unused-expressions": "off", // Superseded by @typescript-eslint/no-unused-expressions + } + }, + { + // Rules only for test files + "files": ["*.spec.ts", "src/test/**"], + "rules": { + "@typescript-eslint/unbound-method": "off", // This rule has false positives in many of our test projects. + } + }, + ], + "settings": { + "import/extensions": [ + ".ts", + ".tsx", + ".d.ts", + ".js", + ".jsx" + ], + "import/parsers": { + "@typescript-eslint/parser": [ + ".ts", + ".tsx", + ".d.ts" + ] + }, + "import/resolver": { + "node": { + "extensions": [ + ".ts", + ".tsx", + ".d.ts", + ".js", + ".jsx" + ] + } + } + } +}; diff --git a/common/build/eslint-config-fluid/strict.js b/common/build/eslint-config-fluid/strict.js deleted file mode 100644 index c12304e536cc4..0000000000000 --- a/common/build/eslint-config-fluid/strict.js +++ /dev/null @@ -1,64 +0,0 @@ -/*! - * Copyright (c) Microsoft Corporation and contributors. All rights reserved. - * Licensed under the MIT License. - */ - -module.exports = { - "extends": [ - "./recommended.js" - ], - "overrides": [ - { - // Rules only for TypeScript files - "files": ["*.ts", "*.tsx"], - "rules": { - // STRICT RULES - "@typescript-eslint/explicit-member-accessibility": [ - "error", - { - accessibility: "explicit", - overrides: { - accessors: "explicit", - constructors: "no-public", - methods: "explicit", - properties: "explicit", - parameterProperties: "explicit" - } - }, - ], - - // Parameter properties can be confusing to those new to TypeScript as they are less explicit than other - // ways of declaring and initializing class members. - "@typescript-eslint/no-parameter-properties": [ - "warn", - { - "allows": [ - "private", - "private readonly", - "public readonly", - "readonly", - ] - }, - ], - - // Requires explicit typing for anything exported from a module. Explicit types for function return - // values and arguments makes it clear to any calling code what is the module boundary's input and - // output. - "@typescript-eslint/explicit-module-boundary-types": "error", - - // Disallows assigning any to a variable, and assigning any[] to an array destructuring. Assigning an - // any typed value to a variable can be hard to pick up on, particularly if it leaks in from an external - // library. - "@typescript-eslint/no-unsafe-assignment": "error", - - // Disallows calling any variable that is typed as any. The arguments to, and return value of calling an - // any typed variable are not checked at all by TypeScript. - "@typescript-eslint/no-unsafe-call": "error", - - // Disallows member access on any variable that is typed as any. The arguments to, and return value of - // calling an any typed variable are not checked at all by TypeScript. - "@typescript-eslint/no-unsafe-member-access": "error", - } - } - ] -};