From ae0271cd8d6406e2fa54403f49e5072bd729bddd Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 6 Mar 2021 21:58:30 +0100 Subject: [PATCH 01/19] docs(eslint-plugin): correct no longer valid references and examples (#3152) --- .../eslint-plugin/docs/rules/consistent-type-imports.md | 2 +- packages/eslint-plugin/docs/rules/no-magic-numbers.md | 8 ++++---- .../eslint-plugin/docs/rules/triple-slash-reference.md | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/eslint-plugin/docs/rules/consistent-type-imports.md b/packages/eslint-plugin/docs/rules/consistent-type-imports.md index c30e59b40b9..a5808b45578 100644 --- a/packages/eslint-plugin/docs/rules/consistent-type-imports.md +++ b/packages/eslint-plugin/docs/rules/consistent-type-imports.md @@ -61,6 +61,6 @@ const x: import('Bar') = 1; ## When Not To Use It - If you are not using TypeScript 3.8 (or greater), then you will not be able to use this rule, as type-only imports are not allowed. -- Certain libraries use the non-inlined imports to infer information about the variables. For example, for dependency injection. +- Certain libraries use the non-inlined imports to infer information about the variables. For example, for dependency injection.
type-only imports cannot be used with these libraries. See [#2559](https://github.com/typescript-eslint/typescript-eslint/issues/2559#issuecomment-692780580) - If you specifically want to use both import kinds for stylistic reasons, you can disable this rule. diff --git a/packages/eslint-plugin/docs/rules/no-magic-numbers.md b/packages/eslint-plugin/docs/rules/no-magic-numbers.md index f41204c132b..8149ad6ddd6 100644 --- a/packages/eslint-plugin/docs/rules/no-magic-numbers.md +++ b/packages/eslint-plugin/docs/rules/no-magic-numbers.md @@ -53,8 +53,8 @@ Examples of **incorrect** code for the `{ "ignoreEnums": false }` option: ```ts /*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreEnums": false }]*/ -enum foo = { - SECOND = 1000, +enum foo { + SECOND = 1000, } ``` @@ -63,8 +63,8 @@ Examples of **correct** code for the `{ "ignoreEnums": true }` option: ```ts /*eslint @typescript-eslint/no-magic-numbers: ["error", { "ignoreEnums": true }]*/ -enum foo = { - SECOND = 1000, +enum foo { + SECOND = 1000, } ``` diff --git a/packages/eslint-plugin/docs/rules/triple-slash-reference.md b/packages/eslint-plugin/docs/rules/triple-slash-reference.md index af9e5498b6d..9eb463a3c79 100644 --- a/packages/eslint-plugin/docs/rules/triple-slash-reference.md +++ b/packages/eslint-plugin/docs/rules/triple-slash-reference.md @@ -2,8 +2,6 @@ Use of triple-slash reference type directives is discouraged in favor of the newer `import` style. This rule allows you to ban use of `/// `, `/// `, or `/// ` directives. -Consider using this rule in place of [`no-triple-slash-reference`](./no-triple-slash-reference.md) which has been deprecated. - ## Rule Details With `{ "path": "never", "types": "never", "lib": "never" }` options set, the following will all be **incorrect** usage: From 3f9e9a1e9fc3e507bd01d1913ef642cd129de402 Mon Sep 17 00:00:00 2001 From: Nikita Stefaniak Date: Mon, 8 Mar 2021 18:33:28 +0100 Subject: [PATCH 02/19] feat(eslint-plugin): [strict-bool-expr] add fixes and suggestions (#2847) --- packages/eslint-plugin/README.md | 2 +- .../docs/rules/strict-boolean-expressions.md | 32 + .../src/rules/strict-boolean-expressions.ts | 473 +++++++++++++- .../src/util/getWrappingFixer.ts | 109 ++++ packages/eslint-plugin/src/util/index.ts | 1 + .../rules/strict-boolean-expressions.test.ts | 604 ++++++++++++++++-- 6 files changed, 1167 insertions(+), 54 deletions(-) create mode 100644 packages/eslint-plugin/src/util/getWrappingFixer.ts diff --git a/packages/eslint-plugin/README.md b/packages/eslint-plugin/README.md index 3a504fe7d83..69ea06c2308 100644 --- a/packages/eslint-plugin/README.md +++ b/packages/eslint-plugin/README.md @@ -169,7 +169,7 @@ Pro Tip: For larger codebases you may want to consider splitting our linting int | [`@typescript-eslint/restrict-plus-operands`](./docs/rules/restrict-plus-operands.md) | When adding two variables, operands must both be of type number or of type string | :heavy_check_mark: | | :thought_balloon: | | [`@typescript-eslint/restrict-template-expressions`](./docs/rules/restrict-template-expressions.md) | Enforce template literal expressions to be of string type | :heavy_check_mark: | | :thought_balloon: | | [`@typescript-eslint/sort-type-union-intersection-members`](./docs/rules/sort-type-union-intersection-members.md) | Enforces that members of a type union/intersection are sorted alphabetically | | :wrench: | | -| [`@typescript-eslint/strict-boolean-expressions`](./docs/rules/strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | | :thought_balloon: | +| [`@typescript-eslint/strict-boolean-expressions`](./docs/rules/strict-boolean-expressions.md) | Restricts the types allowed in boolean expressions | | :wrench: | :thought_balloon: | | [`@typescript-eslint/switch-exhaustiveness-check`](./docs/rules/switch-exhaustiveness-check.md) | Exhaustiveness checking in switch with union type | | | :thought_balloon: | | [`@typescript-eslint/triple-slash-reference`](./docs/rules/triple-slash-reference.md) | Sets preference level for triple slash directives versus ES6-style import declarations | :heavy_check_mark: | | | | [`@typescript-eslint/type-annotation-spacing`](./docs/rules/type-annotation-spacing.md) | Require consistent spacing around type annotations | | :wrench: | | diff --git a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md index 9eb5712ab48..b1ad94d8b34 100644 --- a/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md +++ b/packages/eslint-plugin/docs/rules/strict-boolean-expressions.md @@ -155,6 +155,38 @@ You should be using `strictNullChecks` to ensure complete type-safety in your co If for some reason you cannot turn on `strictNullChecks`, but still want to use this rule - you can use this option to allow it - but know that the behavior of this rule is _undefined_ with the compiler option turned off. We will not accept bug reports if you are using this option. +## Fixes and suggestions + +This rule provides following fixes and suggestions for particular types in boolean context: + +- `boolean` - Always allowed - no fix needed. +- `string` - (when `allowString` is `false`) - Provides following suggestions: + - Change condition to check string's length (`str` → `str.length > 0`) + - Change condition to check for empty string (`str` → `str !== ""`) + - Explicitly cast value to a boolean (`str` → `Boolean(str)`) +- `number` - (when `allowNumber` is `false`): + - For `array.length` - Provides **autofix**: + - Change condition to check for 0 (`array.length` → `array.length > 0`) + - For other number values - Provides following suggestions: + - Change condition to check for 0 (`num` → `num !== 0`) + - Change condition to check for NaN (`num` → `!Number.isNaN(num)`) + - Explicitly cast value to a boolean (`num` → `Boolean(num)`) +- `object | null | undefined` - (when `allowNullableObject` is `false`) - Provides **autofix**: + - Change condition to check for null/undefined (`maybeObj` → `maybeObj != null`) +- `boolean | null | undefined` - Provides following suggestions: + - Explicitly treat nullish value the same as false (`maybeBool` → `maybeBool ?? false`) + - Change condition to check for true/false (`maybeBool` → `maybeBool === true`) +- `string | null | undefined` - Provides following suggestions: + - Change condition to check for null/undefined (`maybeStr` → `maybeStr != null`) + - Explicitly treat nullish value the same as an empty string (`maybeStr` → `maybeStr ?? ""`) + - Explicitly cast value to a boolean (`maybeStr` → `Boolean(maybeStr)`) +- `number | null | undefined` - Provides following suggestions: + - Change condition to check for null/undefined (`maybeNum` → `maybeNum != null`) + - Explicitly treat nullish value the same as 0 (`maybeNum` → `maybeNum ?? 0`) + - Explicitly cast value to a boolean (`maybeNum` → `Boolean(maybeNum)`) +- `any` and `unknown` - Provides following suggestions: + - Explicitly cast value to a boolean (`value` → `Boolean(value)`) + ## Related To - TSLint: [strict-boolean-expressions](https://palantir.github.io/tslint/rules/strict-boolean-expressions) diff --git a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts index 51265feb136..b8e25d4542a 100644 --- a/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts +++ b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts @@ -1,9 +1,10 @@ import { - TSESTree, AST_NODE_TYPES, + ParserServices, + TSESTree, } from '@typescript-eslint/experimental-utils'; -import * as ts from 'typescript'; import * as tsutils from 'tsutils'; +import * as ts from 'typescript'; import * as util from '../util'; export type Options = [ @@ -30,12 +31,24 @@ export type MessageId = | 'conditionErrorNullableNumber' | 'conditionErrorObject' | 'conditionErrorNullableObject' - | 'noStrictNullCheck'; + | 'noStrictNullCheck' + | 'conditionFixDefaultFalse' + | 'conditionFixDefaultEmptyString' + | 'conditionFixDefaultZero' + | 'conditionFixCompareNullish' + | 'conditionFixCastBoolean' + | 'conditionFixCompareTrue' + | 'conditionFixCompareFalse' + | 'conditionFixCompareStringLength' + | 'conditionFixCompareEmptyString' + | 'conditionFixCompareZero' + | 'conditionFixCompareNaN'; export default util.createRule({ name: 'strict-boolean-expressions', meta: { type: 'suggestion', + fixable: 'code', docs: { description: 'Restricts the types allowed in boolean expressions', category: 'Best Practices', @@ -93,6 +106,29 @@ export default util.createRule({ 'An explicit null check is required.', noStrictNullCheck: 'This rule requires the `strictNullChecks` compiler option to be turned on to function correctly.', + + conditionFixDefaultFalse: + 'Explicitly treat nullish value the same as false (`value ?? false`)', + conditionFixDefaultEmptyString: + 'Explicitly treat nullish value the same as an empty string (`value ?? ""`)', + conditionFixDefaultZero: + 'Explicitly treat nullish value the same as 0 (`value ?? 0`)', + conditionFixCompareNullish: + 'Change condition to check for null/undefined (`value != null`)', + conditionFixCastBoolean: + 'Explicitly cast value to a boolean (`Boolean(value)`)', + conditionFixCompareTrue: + 'Change condition to check if true (`value === true`)', + conditionFixCompareFalse: + 'Change condition to check if false (`value === false`)', + conditionFixCompareStringLength: + "Change condition to check string's length (`value.length !== 0`)", + conditionFixCompareEmptyString: + 'Change condition to check for empty string (`value !== ""`)', + conditionFixCompareZero: + 'Change condition to check for 0 (`value !== 0`)', + conditionFixCompareNaN: + 'Change condition to check for NaN (`!Number.isNaN(value)`)', }, }, defaultOptions: [ @@ -108,9 +144,10 @@ export default util.createRule({ }, ], create(context, [options]) { - const service = util.getParserServices(context); - const checker = service.program.getTypeChecker(); - const compilerOptions = service.program.getCompilerOptions(); + const parserServices = util.getParserServices(context); + const typeChecker = parserServices.program.getTypeChecker(); + const compilerOptions = parserServices.program.getCompilerOptions(); + const sourceCode = context.getSourceCode(); const isStrictNullChecks = tsutils.isStrictCompilerOptionEnabled( compilerOptions, 'strictNullChecks', @@ -187,8 +224,8 @@ export default util.createRule({ return; } - const tsNode = service.esTreeNodeToTSNodeMap.get(node); - const type = util.getConstrainedTypeAtLocation(checker, tsNode); + const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); + const type = util.getConstrainedTypeAtLocation(typeChecker, tsNode); const types = inspectVariantTypes(tsutils.unionTypeParts(type)); const is = (...wantedTypes: readonly VariantType[]): boolean => @@ -217,7 +254,56 @@ export default util.createRule({ // nullable boolean if (is('nullish', 'boolean')) { if (!options.allowNullableBoolean) { - context.report({ node, messageId: 'conditionErrorNullableBoolean' }); + if (isLogicalNegationExpression(node.parent!)) { + // if (!nullableBoolean) + context.report({ + node, + messageId: 'conditionErrorNullableBoolean', + suggest: [ + { + messageId: 'conditionFixDefaultFalse', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} ?? false`, + }), + }, + { + messageId: 'conditionFixCompareFalse', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code} === false`, + }), + }, + ], + }); + } else { + // if (nullableBoolean) + context.report({ + node, + messageId: 'conditionErrorNullableBoolean', + suggest: [ + { + messageId: 'conditionFixDefaultFalse', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} ?? false`, + }), + }, + { + messageId: 'conditionFixCompareTrue', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} === true`, + }), + }, + ], + }); + } } return; } @@ -225,7 +311,74 @@ export default util.createRule({ // string if (is('string')) { if (!options.allowString) { - context.report({ node, messageId: 'conditionErrorString' }); + if (isLogicalNegationExpression(node.parent!)) { + // if (!string) + context.report({ + node, + messageId: 'conditionErrorString', + suggest: [ + { + messageId: 'conditionFixCompareStringLength', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code}.length === 0`, + }), + }, + { + messageId: 'conditionFixCompareEmptyString', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code} === ""`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `!Boolean(${code})`, + }), + }, + ], + }); + } else { + // if (string) + context.report({ + node, + messageId: 'conditionErrorString', + suggest: [ + { + messageId: 'conditionFixCompareStringLength', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code}.length > 0`, + }), + }, + { + messageId: 'conditionFixCompareEmptyString', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} !== ""`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `Boolean(${code})`, + }), + }, + ], + }); + } } return; } @@ -233,7 +386,73 @@ export default util.createRule({ // nullable string if (is('nullish', 'string')) { if (!options.allowNullableString) { - context.report({ node, messageId: 'conditionErrorNullableString' }); + if (isLogicalNegationExpression(node.parent!)) { + // if (!nullableString) + context.report({ + node, + messageId: 'conditionErrorNullableString', + suggest: [ + { + messageId: 'conditionFixCompareNullish', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code} == null`, + }), + }, + { + messageId: 'conditionFixDefaultEmptyString', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} ?? ""`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `!Boolean(${code})`, + }), + }, + ], + }); + } else { + // if (nullableString) + context.report({ + node, + messageId: 'conditionErrorNullableString', + suggest: [ + { + messageId: 'conditionFixCompareNullish', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} != null`, + }), + }, + { + messageId: 'conditionFixDefaultEmptyString', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} ?? ""`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `Boolean(${code})`, + }), + }, + ], + }); + } } return; } @@ -241,7 +460,101 @@ export default util.createRule({ // number if (is('number')) { if (!options.allowNumber) { - context.report({ node, messageId: 'conditionErrorNumber' }); + if (isArrayLengthExpression(node, typeChecker, parserServices)) { + if (isLogicalNegationExpression(node.parent!)) { + // if (!array.length) + context.report({ + node, + messageId: 'conditionErrorNumber', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code} === 0`, + }), + }); + } else { + // if (array.length) + context.report({ + node, + messageId: 'conditionErrorNumber', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} > 0`, + }), + }); + } + } else if (isLogicalNegationExpression(node.parent!)) { + // if (!number) + context.report({ + node, + messageId: 'conditionErrorNumber', + suggest: [ + { + messageId: 'conditionFixCompareZero', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + // TODO: we have to compare to 0n if the type is bigint + wrap: code => `${code} === 0`, + }), + }, + { + // TODO: don't suggest this for bigint because it can't be NaN + messageId: 'conditionFixCompareNaN', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `Number.isNaN(${code})`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `!Boolean(${code})`, + }), + }, + ], + }); + } else { + // if (number) + context.report({ + node, + messageId: 'conditionErrorNumber', + suggest: [ + { + messageId: 'conditionFixCompareZero', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} !== 0`, + }), + }, + { + messageId: 'conditionFixCompareNaN', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `!Number.isNaN(${code})`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `Boolean(${code})`, + }), + }, + ], + }); + } } return; } @@ -249,7 +562,73 @@ export default util.createRule({ // nullable number if (is('nullish', 'number')) { if (!options.allowNullableNumber) { - context.report({ node, messageId: 'conditionErrorNullableNumber' }); + if (isLogicalNegationExpression(node.parent!)) { + // if (!nullableNumber) + context.report({ + node, + messageId: 'conditionErrorNullableNumber', + suggest: [ + { + messageId: 'conditionFixCompareNullish', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code} == null`, + }), + }, + { + messageId: 'conditionFixDefaultZero', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} ?? 0`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `!Boolean(${code})`, + }), + }, + ], + }); + } else { + // if (nullableNumber) + context.report({ + node, + messageId: 'conditionErrorNullableNumber', + suggest: [ + { + messageId: 'conditionFixCompareNullish', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} != null`, + }), + }, + { + messageId: 'conditionFixDefaultZero', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} ?? 0`, + }), + }, + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `Boolean(${code})`, + }), + }, + ], + }); + } } return; } @@ -264,7 +643,30 @@ export default util.createRule({ // nullable object if (is('nullish', 'object')) { if (!options.allowNullableObject) { - context.report({ node, messageId: 'conditionErrorNullableObject' }); + if (isLogicalNegationExpression(node.parent!)) { + // if (!nullableObject) + context.report({ + node, + messageId: 'conditionErrorNullableObject', + fix: util.getWrappingFixer({ + sourceCode, + node: node.parent, + innerNode: node, + wrap: code => `${code} == null`, + }), + }); + } else { + // if (nullableObject) + context.report({ + node, + messageId: 'conditionErrorNullableObject', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `${code} != null`, + }), + }); + } } return; } @@ -272,7 +674,20 @@ export default util.createRule({ // any if (is('any')) { if (!options.allowAny) { - context.report({ node, messageId: 'conditionErrorAny' }); + context.report({ + node, + messageId: 'conditionErrorAny', + suggest: [ + { + messageId: 'conditionFixCastBoolean', + fix: util.getWrappingFixer({ + sourceCode, + node, + wrap: code => `Boolean(${code})`, + }), + }, + ], + }); } return; } @@ -370,3 +785,31 @@ export default util.createRule({ } }, }); + +function isLogicalNegationExpression( + node: TSESTree.Node, +): node is TSESTree.UnaryExpression { + return node.type === AST_NODE_TYPES.UnaryExpression && node.operator === '!'; +} + +function isArrayLengthExpression( + node: TSESTree.Node, + typeChecker: ts.TypeChecker, + parserServices: ParserServices, +): node is TSESTree.MemberExpressionNonComputedName { + if (node.type !== AST_NODE_TYPES.MemberExpression) { + return false; + } + if (node.computed) { + return false; + } + if (node.property.name !== 'length') { + return false; + } + const objectTsNode = parserServices.esTreeNodeToTSNodeMap.get(node.object); + const objectType = util.getConstrainedTypeAtLocation( + typeChecker, + objectTsNode, + ); + return util.isTypeArrayTypeOrUnionOfArrayTypes(objectType, typeChecker); +} diff --git a/packages/eslint-plugin/src/util/getWrappingFixer.ts b/packages/eslint-plugin/src/util/getWrappingFixer.ts new file mode 100644 index 00000000000..4a9edcfcc98 --- /dev/null +++ b/packages/eslint-plugin/src/util/getWrappingFixer.ts @@ -0,0 +1,109 @@ +import { + AST_NODE_TYPES, + TSESLint, + TSESTree, +} from '@typescript-eslint/experimental-utils'; +import * as util from '../util'; + +interface WrappingFixerParams { + /** Source code. */ + sourceCode: Readonly; + /** The node we want to modify. */ + node: TSESTree.Node; + /** + * Descendant of `node` we want to preserve. + * Use this to replace some code with another. + * By default it's the node we are modifying (so nothing is removed). + */ + innerNode?: TSESTree.Node; + /** + * The function which gets the code of the `innerNode` and returns some code around it. + * E.g. ``code => `${code} != null` `` + */ + wrap: (code: string) => string; +} + +/** + * Wraps node with some code. Adds parenthesis as necessary. + * @returns Fixer which adds the specified code and parens if necessary. + */ +export function getWrappingFixer( + params: WrappingFixerParams, +): TSESLint.ReportFixFunction { + const { sourceCode, node, innerNode = node, wrap } = params; + return (fixer): TSESLint.RuleFix => { + let code = sourceCode.getText(innerNode); + + // check the inner expression's precedence + if ( + innerNode.type !== AST_NODE_TYPES.Literal && + innerNode.type !== AST_NODE_TYPES.Identifier && + innerNode.type !== AST_NODE_TYPES.MemberExpression && + innerNode.type !== AST_NODE_TYPES.CallExpression + ) { + // we are wrapping something else than a simple variable or function call + // the code we are adding might have stronger precedence than our wrapped node + // let's wrap our node in parens in case it has a weaker precedence than the code we are wrapping it in + code = `(${code})`; + } + + // do the wrapping + code = wrap(code); + + let parent = util.nullThrows( + node.parent, + util.NullThrowsReasons.MissingParent, + ); + + // check the outer expression's precedence + if ( + parent.type !== AST_NODE_TYPES.IfStatement && + parent.type !== AST_NODE_TYPES.ForStatement && + parent.type !== AST_NODE_TYPES.WhileStatement && + parent.type !== AST_NODE_TYPES.DoWhileStatement + ) { + // the whole expression's parent is something else than condition of if/for/while + // we wrapped the node in some expression which very likely has a different precedence than original wrapped node + // let's wrap the whole expression in parens just in case + if (!util.isParenthesized(node, sourceCode)) { + code = `(${code})`; + } + } + + // check if we need to insert semicolon + for (;;) { + const prevParent = parent; + parent = parent.parent!; + if ( + parent.type === AST_NODE_TYPES.LogicalExpression || + parent.type === AST_NODE_TYPES.BinaryExpression + ) { + if (parent.left === prevParent) { + // the next parent is a binary expression and current node is on the left + continue; + } + } + if (parent.type === AST_NODE_TYPES.ExpressionStatement) { + const block = parent.parent!; + if ( + block.type === AST_NODE_TYPES.Program || + block.type === AST_NODE_TYPES.BlockStatement + ) { + // the next parent is an expression in a block + const statementIndex = block.body.indexOf(parent); + const previousStatement = block.body[statementIndex - 1]; + if ( + statementIndex > 0 && + sourceCode.getLastToken(previousStatement)!.value !== ';' + ) { + // the previous statement in a block doesn't end with a semicolon + code = `;${code}`; + } + } + } + break; + } + + return fixer.replaceText(node, code); + }; +} diff --git a/packages/eslint-plugin/src/util/index.ts b/packages/eslint-plugin/src/util/index.ts index fc5346f7346..e7bb53547fc 100644 --- a/packages/eslint-plugin/src/util/index.ts +++ b/packages/eslint-plugin/src/util/index.ts @@ -4,6 +4,7 @@ export * from './astUtils'; export * from './collectUnusedVariables'; export * from './createRule'; export * from './getFunctionHeadLoc'; +export * from './getWrappingFixer'; export * from './isTypeReadonly'; export * from './misc'; export * from './nullThrows'; diff --git a/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts b/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts index 0d697ebb905..d24de92ac65 100644 --- a/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts +++ b/packages/eslint-plugin/tests/rules/strict-boolean-expressions.test.ts @@ -1,13 +1,13 @@ import * as path from 'path'; import rule, { - Options, MessageId, + Options, } from '../../src/rules/strict-boolean-expressions'; import { batchedSingleLineTests, getFixturesRootDir, - RuleTester, noFormat, + RuleTester, } from '../RuleTester'; const rootPath = getFixturesRootDir(); @@ -142,13 +142,49 @@ if (x) { { allowString: false, allowNumber: false, allowNullableObject: false }, ], code: noFormat` - if (true && 1) {} - while (false || "a") {} + if (true && (1 + 1)) {} + while (false || "a" + "b") {} (x: object) => true || false || x ? true : false; `, errors: [ - { messageId: 'conditionErrorNumber', line: 2, column: 13 }, - { messageId: 'conditionErrorString', line: 3, column: 25 }, + { + messageId: 'conditionErrorNumber', + line: 2, + column: 14, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: 'if (true && ((1 + 1) !== 0)) {}', + }, + { + messageId: 'conditionFixCompareNaN', + output: 'if (true && (!Number.isNaN((1 + 1)))) {}', + }, + { + messageId: 'conditionFixCastBoolean', + output: 'if (true && (Boolean((1 + 1)))) {}', + }, + ], + }, + { + messageId: 'conditionErrorString', + line: 3, + column: 25, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: ' while (false || (("a" + "b").length > 0)) {}', + }, + { + messageId: 'conditionFixCompareEmptyString', + output: ' while (false || (("a" + "b") !== "")) {}', + }, + { + messageId: 'conditionFixCastBoolean', + output: ' while (false || (Boolean(("a" + "b")))) {}', + }, + ], + }, { messageId: 'conditionErrorObject', line: 4, column: 41 }, ], }), @@ -158,15 +194,48 @@ if (x) { options: [ { allowString: false, allowNumber: false, allowNullableObject: false }, ], - code: ` - if (('' && {}) || (0 && void 0)) { - } - `, + code: noFormat`if (('' && {}) || (0 && void 0)) { }`, errors: [ - { messageId: 'conditionErrorString', line: 2, column: 14 }, - { messageId: 'conditionErrorObject', line: 2, column: 20 }, - { messageId: 'conditionErrorNumber', line: 2, column: 28 }, - { messageId: 'conditionErrorNullish', line: 2, column: 33 }, + { + messageId: 'conditionErrorString', + line: 1, + column: 6, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: noFormat`if (((''.length > 0) && {}) || (0 && void 0)) { }`, + }, + { + messageId: 'conditionFixCompareEmptyString', + output: noFormat`if ((('' !== "") && {}) || (0 && void 0)) { }`, + }, + { + messageId: 'conditionFixCastBoolean', + output: noFormat`if (((Boolean('')) && {}) || (0 && void 0)) { }`, + }, + ], + }, + { messageId: 'conditionErrorObject', line: 1, column: 12 }, + { + messageId: 'conditionErrorNumber', + line: 1, + column: 20, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: noFormat`if (('' && {}) || ((0 !== 0) && void 0)) { }`, + }, + { + messageId: 'conditionFixCompareNaN', + output: noFormat`if (('' && {}) || ((!Number.isNaN(0)) && void 0)) { }`, + }, + { + messageId: 'conditionFixCastBoolean', + output: noFormat`if (('' && {}) || ((Boolean(0)) && void 0)) { }`, + }, + ], + }, + { messageId: 'conditionErrorNullish', line: 1, column: 25 }, ], }, @@ -213,15 +282,105 @@ if (x) { while ("") {} for (; "foo";) {} declare const x: string; if (x) {} - (x: string) => !x; + (x: string) => (!x); (x: T) => x ? 1 : 0; `, errors: [ - { messageId: 'conditionErrorString', line: 2, column: 8 }, - { messageId: 'conditionErrorString', line: 3, column: 16 }, - { messageId: 'conditionErrorString', line: 4, column: 38 }, - { messageId: 'conditionErrorString', line: 5, column: 25 }, - { messageId: 'conditionErrorString', line: 6, column: 37 }, + { + messageId: 'conditionErrorString', + line: 2, + column: 8, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: `while ("".length > 0) {}`, + }, + { + messageId: 'conditionFixCompareEmptyString', + output: `while ("" !== "") {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: `while (Boolean("")) {}`, + }, + ], + }, + { + messageId: 'conditionErrorString', + line: 3, + column: 16, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: ` for (; "foo".length > 0;) {}`, + }, + { + messageId: 'conditionFixCompareEmptyString', + output: ` for (; "foo" !== "";) {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` for (; Boolean("foo");) {}`, + }, + ], + }, + { + messageId: 'conditionErrorString', + line: 4, + column: 38, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: ` declare const x: string; if (x.length > 0) {}`, + }, + { + messageId: 'conditionFixCompareEmptyString', + output: ` declare const x: string; if (x !== "") {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` declare const x: string; if (Boolean(x)) {}`, + }, + ], + }, + { + messageId: 'conditionErrorString', + line: 5, + column: 26, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: ` (x: string) => (x.length === 0);`, + }, + { + messageId: 'conditionFixCompareEmptyString', + output: ` (x: string) => (x === "");`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` (x: string) => (!Boolean(x));`, + }, + ], + }, + { + messageId: 'conditionErrorString', + line: 6, + column: 37, + suggestions: [ + { + messageId: 'conditionFixCompareStringLength', + output: ` (x: T) => (x.length > 0) ? 1 : 0;`, + }, + { + messageId: 'conditionFixCompareEmptyString', + output: ` (x: T) => (x !== "") ? 1 : 0;`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` (x: T) => (Boolean(x)) ? 1 : 0;`, + }, + ], + }, ], }), @@ -233,15 +392,169 @@ if (x) { for (; 123;) {} declare const x: number; if (x) {} (x: bigint) => !x; - (x: T) => x ? 1 : 0; + (x: T) => (x) ? 1 : 0; + ![]["length"]; // doesn't count as array.length when computed + declare const a: any[] & { notLength: number }; if (a.notLength) {} + `, + errors: [ + { + messageId: 'conditionErrorNumber', + line: 2, + column: 8, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + // TODO: fix compare zero suggestion for bigint + output: `while (0n !== 0) {}`, + }, + { + // TODO: remove check NaN suggestion for bigint + messageId: 'conditionFixCompareNaN', + output: `while (!Number.isNaN(0n)) {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: `while (Boolean(0n)) {}`, + }, + ], + }, + { + messageId: 'conditionErrorNumber', + line: 3, + column: 16, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: ` for (; 123 !== 0;) {}`, + }, + { + messageId: 'conditionFixCompareNaN', + output: ` for (; !Number.isNaN(123);) {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` for (; Boolean(123);) {}`, + }, + ], + }, + { + messageId: 'conditionErrorNumber', + line: 4, + column: 38, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: ` declare const x: number; if (x !== 0) {}`, + }, + { + messageId: 'conditionFixCompareNaN', + output: ` declare const x: number; if (!Number.isNaN(x)) {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` declare const x: number; if (Boolean(x)) {}`, + }, + ], + }, + { + messageId: 'conditionErrorNumber', + line: 5, + column: 25, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + // TODO: fix compare zero suggestion for bigint + output: ` (x: bigint) => (x === 0);`, + }, + { + // TODO: remove check NaN suggestion for bigint + messageId: 'conditionFixCompareNaN', + output: ` (x: bigint) => (Number.isNaN(x));`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` (x: bigint) => (!Boolean(x));`, + }, + ], + }, + { + messageId: 'conditionErrorNumber', + line: 6, + column: 38, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: ` (x: T) => (x !== 0) ? 1 : 0;`, + }, + { + messageId: 'conditionFixCompareNaN', + output: ` (x: T) => (!Number.isNaN(x)) ? 1 : 0;`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` (x: T) => (Boolean(x)) ? 1 : 0;`, + }, + ], + }, + { + messageId: 'conditionErrorNumber', + line: 7, + column: 10, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: ` ([]["length"] === 0); // doesn't count as array.length when computed`, + }, + { + messageId: 'conditionFixCompareNaN', + output: ` (Number.isNaN([]["length"])); // doesn't count as array.length when computed`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` (!Boolean([]["length"])); // doesn't count as array.length when computed`, + }, + ], + }, + { + messageId: 'conditionErrorNumber', + line: 8, + column: 61, + suggestions: [ + { + messageId: 'conditionFixCompareZero', + output: ` declare const a: any[] & { notLength: number }; if (a.notLength !== 0) {}`, + }, + { + messageId: 'conditionFixCompareNaN', + output: ` declare const a: any[] & { notLength: number }; if (!Number.isNaN(a.notLength)) {}`, + }, + { + messageId: 'conditionFixCastBoolean', + output: ` declare const a: any[] & { notLength: number }; if (Boolean(a.notLength)) {}`, + }, + ], + }, + ], + }), + + // number (array.length) in boolean context + ...batchedSingleLineTests({ + options: [{ allowNumber: false }], + code: noFormat` + if (![].length) {} + (a: number[]) => a.length && "..." + (...a: T) => a.length || "empty"; `, errors: [ - { messageId: 'conditionErrorNumber', line: 2, column: 8 }, - { messageId: 'conditionErrorNumber', line: 3, column: 16 }, - { messageId: 'conditionErrorNumber', line: 4, column: 38 }, - { messageId: 'conditionErrorNumber', line: 5, column: 25 }, - { messageId: 'conditionErrorNumber', line: 6, column: 37 }, + { messageId: 'conditionErrorNumber', line: 2, column: 6 }, + { messageId: 'conditionErrorNumber', line: 3, column: 26 }, + { messageId: 'conditionErrorNumber', line: 4, column: 43 }, ], + output: noFormat` + if ([].length === 0) {} + (a: number[]) => (a.length > 0) && "..." + (...a: T) => (a.length > 0) || "empty"; + `, }), // mixed `string | number` value in boolean context @@ -268,9 +581,51 @@ if (x) { (x: T) => x ? 1 : 0; `, errors: [ - { messageId: 'conditionErrorNullableBoolean', line: 2, column: 38 }, - { messageId: 'conditionErrorNullableBoolean', line: 3, column: 27 }, - { messageId: 'conditionErrorNullableBoolean', line: 4, column: 57 }, + { + messageId: 'conditionErrorNullableBoolean', + line: 2, + column: 38, + suggestions: [ + { + messageId: 'conditionFixDefaultFalse', + output: `declare const x: boolean | null; if (x ?? false) {}`, + }, + { + messageId: 'conditionFixCompareTrue', + output: `declare const x: boolean | null; if (x === true) {}`, + }, + ], + }, + { + messageId: 'conditionErrorNullableBoolean', + line: 3, + column: 27, + suggestions: [ + { + messageId: 'conditionFixDefaultFalse', + output: ` (x?: boolean) => !(x ?? false);`, + }, + { + messageId: 'conditionFixCompareFalse', + output: ` (x?: boolean) => (x === false);`, + }, + ], + }, + { + messageId: 'conditionErrorNullableBoolean', + line: 4, + column: 57, + suggestions: [ + { + messageId: 'conditionFixDefaultFalse', + output: ` (x: T) => (x ?? false) ? 1 : 0;`, + }, + { + messageId: 'conditionFixCompareTrue', + output: ` (x: T) => (x === true) ? 1 : 0;`, + }, + ], + }, ], }), @@ -287,6 +642,11 @@ if (x) { { messageId: 'conditionErrorNullableObject', line: 3, column: 33 }, { messageId: 'conditionErrorNullableObject', line: 4, column: 52 }, ], + output: noFormat` + declare const x: object | null; if (x != null) {} + (x?: { a: number }) => (x == null); + (x: T) => (x != null) ? 1 : 0; + `, }), // nullable string in boolean context @@ -297,9 +657,66 @@ if (x) { (x: T) => x ? 1 : 0; `, errors: [ - { messageId: 'conditionErrorNullableString', line: 2, column: 37 }, - { messageId: 'conditionErrorNullableString', line: 3, column: 26 }, - { messageId: 'conditionErrorNullableString', line: 4, column: 56 }, + { + messageId: 'conditionErrorNullableString', + line: 2, + column: 37, + suggestions: [ + { + messageId: 'conditionFixCompareNullish', + output: 'declare const x: string | null; if (x != null) {}', + }, + { + messageId: 'conditionFixDefaultEmptyString', + output: 'declare const x: string | null; if (x ?? "") {}', + }, + { + messageId: 'conditionFixCastBoolean', + output: 'declare const x: string | null; if (Boolean(x)) {}', + }, + ], + }, + { + messageId: 'conditionErrorNullableString', + line: 3, + column: 26, + suggestions: [ + { + messageId: 'conditionFixCompareNullish', + output: ' (x?: string) => (x == null);', + }, + { + messageId: 'conditionFixDefaultEmptyString', + output: ' (x?: string) => !(x ?? "");', + }, + { + messageId: 'conditionFixCastBoolean', + output: ' (x?: string) => (!Boolean(x));', + }, + ], + }, + { + messageId: 'conditionErrorNullableString', + line: 4, + column: 56, + suggestions: [ + { + messageId: 'conditionFixCompareNullish', + output: + ' (x: T) => (x != null) ? 1 : 0;', + }, + { + messageId: 'conditionFixDefaultEmptyString', + output: + ' (x: T) => (x ?? "") ? 1 : 0;', + }, + { + messageId: 'conditionFixCastBoolean', + output: + ' (x: T) => (Boolean(x)) ? 1 : 0;', + }, + ], + }, ], }), @@ -311,9 +728,66 @@ if (x) { (x: T) => x ? 1 : 0; `, errors: [ - { messageId: 'conditionErrorNullableNumber', line: 2, column: 37 }, - { messageId: 'conditionErrorNullableNumber', line: 3, column: 26 }, - { messageId: 'conditionErrorNullableNumber', line: 4, column: 56 }, + { + messageId: 'conditionErrorNullableNumber', + line: 2, + column: 37, + suggestions: [ + { + messageId: 'conditionFixCompareNullish', + output: 'declare const x: number | null; if (x != null) {}', + }, + { + messageId: 'conditionFixDefaultZero', + output: 'declare const x: number | null; if (x ?? 0) {}', + }, + { + messageId: 'conditionFixCastBoolean', + output: 'declare const x: number | null; if (Boolean(x)) {}', + }, + ], + }, + { + messageId: 'conditionErrorNullableNumber', + line: 3, + column: 26, + suggestions: [ + { + messageId: 'conditionFixCompareNullish', + output: ' (x?: number) => (x == null);', + }, + { + messageId: 'conditionFixDefaultZero', + output: ' (x?: number) => !(x ?? 0);', + }, + { + messageId: 'conditionFixCastBoolean', + output: ' (x?: number) => (!Boolean(x));', + }, + ], + }, + { + messageId: 'conditionErrorNullableNumber', + line: 4, + column: 56, + suggestions: [ + { + messageId: 'conditionFixCompareNullish', + output: + ' (x: T) => (x != null) ? 1 : 0;', + }, + { + messageId: 'conditionFixDefaultZero', + output: + ' (x: T) => (x ?? 0) ? 1 : 0;', + }, + { + messageId: 'conditionFixCastBoolean', + output: + ' (x: T) => (Boolean(x)) ? 1 : 0;', + }, + ], + }, ], }), @@ -326,11 +800,43 @@ if (x) { (x: T) => x ? 1 : 0; `, errors: [ - { messageId: 'conditionErrorAny', line: 2, column: 5 }, - { messageId: 'conditionErrorAny', line: 3, column: 15 }, - { messageId: 'conditionErrorAny', line: 4, column: 34 }, + { + messageId: 'conditionErrorAny', + line: 2, + column: 5, + suggestions: [ + { + messageId: 'conditionFixCastBoolean', + output: 'if (Boolean(x)) {}', + }, + ], + }, + { + messageId: 'conditionErrorAny', + line: 3, + column: 15, + suggestions: [ + { + messageId: 'conditionFixCastBoolean', + output: ' x => !(Boolean(x));', + }, + ], + }, + { + messageId: 'conditionErrorAny', + line: 4, + column: 34, + suggestions: [ + { + messageId: 'conditionFixCastBoolean', + output: ' (x: T) => (Boolean(x)) ? 1 : 0;', + }, + ], + }, ], }), + + // noStrictNullCheck { code: ` declare const x: string[] | null; @@ -353,5 +859,27 @@ if (x) { tsconfigRootDir: path.join(rootPath, 'unstrict'), }, }, + + // automatic semicolon insertion test + { + options: [{ allowNullableObject: false }], + code: noFormat` + declare const obj: { x: number } | null; + !obj + obj || 0 + obj && 1 || 0 + `, + errors: [ + { messageId: 'conditionErrorNullableObject', line: 3, column: 10 }, + { messageId: 'conditionErrorNullableObject', line: 4, column: 9 }, + { messageId: 'conditionErrorNullableObject', line: 5, column: 9 }, + ], + output: noFormat` + declare const obj: { x: number } | null; + (obj == null) + ;(obj != null) || 0 + ;(obj != null) && 1 || 0 + `, + }, ], }); From cb2256168c67e0383083673a5afe77076de49da5 Mon Sep 17 00:00:00 2001 From: Zen <843968788@qq.com> Date: Tue, 9 Mar 2021 01:35:23 +0800 Subject: [PATCH 03/19] fix(eslint-plugin): [no-unnecessary-type-assertion] handle assignment (#3133) --- .../rules/no-unnecessary-type-assertion.ts | 19 +++++++++ packages/eslint-plugin/src/util/types.ts | 8 ++++ .../no-unnecessary-type-assertion.test.ts | 40 +++++++++++++++++++ 3 files changed, 67 insertions(+) diff --git a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts index 634d8b890ce..5ae12f5a33d 100644 --- a/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts +++ b/packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts @@ -135,7 +135,26 @@ export default util.createRule({ return { TSNonNullExpression(node): void { + if ( + node.parent?.type === AST_NODE_TYPES.AssignmentExpression && + node.parent?.operator === '=' && + node.parent.left === node + ) { + context.report({ + node, + messageId: 'contextuallyUnnecessary', + fix(fixer) { + return fixer.removeRange([ + node.expression.range[1], + node.range[1], + ]); + }, + }); + return; + } + const originalNode = parserServices.esTreeNodeToTSNodeMap.get(node); + const type = util.getConstrainedTypeAtLocation( checker, originalNode.expression, diff --git a/packages/eslint-plugin/src/util/types.ts b/packages/eslint-plugin/src/util/types.ts index d29349f812f..920ce66de02 100644 --- a/packages/eslint-plugin/src/util/types.ts +++ b/packages/eslint-plugin/src/util/types.ts @@ -11,6 +11,7 @@ import { isVariableDeclaration, unionTypeParts, isPropertyAssignment, + isBinaryExpression, } from 'tsutils'; import * as ts from 'typescript'; @@ -498,6 +499,13 @@ export function getContextualType( return checker.getContextualType(parent); } else if (isPropertyAssignment(parent) && isIdentifier(node)) { return checker.getContextualType(node); + } else if ( + isBinaryExpression(parent) && + parent.operatorToken.kind === ts.SyntaxKind.EqualsToken && + parent.right === node + ) { + // is RHS of assignment + return checker.getTypeAtLocation(parent.left); } else if ( ![ts.SyntaxKind.TemplateSpan, ts.SyntaxKind.JsxExpression].includes( parent.kind, diff --git a/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts b/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts index f5671dd5d6b..65d0874dd3a 100644 --- a/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts +++ b/packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts @@ -186,6 +186,22 @@ const c = [...a, ...b]; { code: "const a = { foo: 'foo' };", }, + { + code: ` +let a: number | undefined; +let b: number | undefined; +let c: number; +a = b; +c = b!; +a! -= 1; + `, + }, + { + code: ` +let a: { b?: string } | undefined; +a!.b = ''; + `, + }, ], invalid: [ @@ -451,5 +467,29 @@ function Test(props: { id?: string | number }) { ], filename: 'react.tsx', }, + { + code: ` +let x: number | undefined; +let y: number | undefined; +y = x!; +y! = 0; + `, + output: ` +let x: number | undefined; +let y: number | undefined; +y = x; +y = 0; + `, + errors: [ + { + messageId: 'contextuallyUnnecessary', + line: 4, + }, + { + messageId: 'contextuallyUnnecessary', + line: 5, + }, + ], + }, ], }); From dd25790a435edef78f6e972ab197b0bd0cfac0f4 Mon Sep 17 00:00:00 2001 From: James Henry Date: Mon, 8 Mar 2021 18:02:52 +0000 Subject: [PATCH 04/19] chore: publish v4.17.0 --- CHANGELOG.md | 16 ++++++++++++++++ lerna.json | 2 +- packages/eslint-plugin-internal/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-internal/package.json | 4 ++-- packages/eslint-plugin-tslint/CHANGELOG.md | 8 ++++++++ packages/eslint-plugin-tslint/package.json | 6 +++--- packages/eslint-plugin/CHANGELOG.md | 16 ++++++++++++++++ packages/eslint-plugin/package.json | 6 +++--- packages/experimental-utils/CHANGELOG.md | 8 ++++++++ packages/experimental-utils/package.json | 8 ++++---- packages/parser/CHANGELOG.md | 8 ++++++++ packages/parser/package.json | 10 +++++----- packages/scope-manager/CHANGELOG.md | 8 ++++++++ packages/scope-manager/package.json | 8 ++++---- packages/shared-fixtures/CHANGELOG.md | 8 ++++++++ packages/shared-fixtures/package.json | 2 +- packages/types/CHANGELOG.md | 8 ++++++++ packages/types/package.json | 2 +- packages/typescript-estree/CHANGELOG.md | 8 ++++++++ packages/typescript-estree/package.json | 8 ++++---- packages/visitor-keys/CHANGELOG.md | 8 ++++++++ packages/visitor-keys/package.json | 4 ++-- 22 files changed, 134 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b47e309990..3d173877642 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + + +### Bug Fixes + +* **eslint-plugin:** [no-unnecessary-type-assertion] handle assignment ([#3133](https://github.com/typescript-eslint/typescript-eslint/issues/3133)) ([cb22561](https://github.com/typescript-eslint/typescript-eslint/commit/cb2256168c67e0383083673a5afe77076de49da5)) + + +### Features + +* **eslint-plugin:** [strict-bool-expr] add fixes and suggestions ([#2847](https://github.com/typescript-eslint/typescript-eslint/issues/2847)) ([3f9e9a1](https://github.com/typescript-eslint/typescript-eslint/commit/3f9e9a1e9fc3e507bd01d1913ef642cd129de402)) + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) diff --git a/lerna.json b/lerna.json index df984d35e16..f760626ee5d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "4.16.1", + "version": "4.17.0", "npmClient": "yarn", "useWorkspaces": true, "stream": true diff --git a/packages/eslint-plugin-internal/CHANGELOG.md b/packages/eslint-plugin-internal/CHANGELOG.md index fbfe59d2652..5f6039b5089 100644 --- a/packages/eslint-plugin-internal/CHANGELOG.md +++ b/packages/eslint-plugin-internal/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-internal diff --git a/packages/eslint-plugin-internal/package.json b/packages/eslint-plugin-internal/package.json index 8d6cc10ab33..0c8f39247c1 100644 --- a/packages/eslint-plugin-internal/package.json +++ b/packages/eslint-plugin-internal/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-internal", - "version": "4.16.1", + "version": "4.17.0", "private": true, "main": "dist/index.js", "scripts": { @@ -14,7 +14,7 @@ }, "dependencies": { "@types/prettier": "*", - "@typescript-eslint/experimental-utils": "4.16.1", + "@typescript-eslint/experimental-utils": "4.17.0", "prettier": "*" } } diff --git a/packages/eslint-plugin-tslint/CHANGELOG.md b/packages/eslint-plugin-tslint/CHANGELOG.md index 423df767304..1180462bd2b 100644 --- a/packages/eslint-plugin-tslint/CHANGELOG.md +++ b/packages/eslint-plugin-tslint/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/eslint-plugin-tslint diff --git a/packages/eslint-plugin-tslint/package.json b/packages/eslint-plugin-tslint/package.json index 1deff124a26..6874c940ed4 100644 --- a/packages/eslint-plugin-tslint/package.json +++ b/packages/eslint-plugin-tslint/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin-tslint", - "version": "4.16.1", + "version": "4.17.0", "main": "dist/index.js", "typings": "src/index.ts", "description": "TSLint wrapper plugin for ESLint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.16.1", + "@typescript-eslint/experimental-utils": "4.17.0", "lodash": "^4.17.15" }, "peerDependencies": { @@ -48,6 +48,6 @@ }, "devDependencies": { "@types/lodash": "*", - "@typescript-eslint/parser": "4.16.1" + "@typescript-eslint/parser": "4.17.0" } } diff --git a/packages/eslint-plugin/CHANGELOG.md b/packages/eslint-plugin/CHANGELOG.md index 4b4fda7ee15..717d2a5f215 100644 --- a/packages/eslint-plugin/CHANGELOG.md +++ b/packages/eslint-plugin/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + + +### Bug Fixes + +* **eslint-plugin:** [no-unnecessary-type-assertion] handle assignment ([#3133](https://github.com/typescript-eslint/typescript-eslint/issues/3133)) ([cb22561](https://github.com/typescript-eslint/typescript-eslint/commit/cb2256168c67e0383083673a5afe77076de49da5)) + + +### Features + +* **eslint-plugin:** [strict-bool-expr] add fixes and suggestions ([#2847](https://github.com/typescript-eslint/typescript-eslint/issues/2847)) ([3f9e9a1](https://github.com/typescript-eslint/typescript-eslint/commit/3f9e9a1e9fc3e507bd01d1913ef642cd129de402)) + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/eslint-plugin diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 8391c2b2550..87cfd4ab800 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/eslint-plugin", - "version": "4.16.1", + "version": "4.17.0", "description": "TypeScript plugin for ESLint", "keywords": [ "eslint", @@ -42,8 +42,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/experimental-utils": "4.16.1", - "@typescript-eslint/scope-manager": "4.16.1", + "@typescript-eslint/experimental-utils": "4.17.0", + "@typescript-eslint/scope-manager": "4.17.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", diff --git a/packages/experimental-utils/CHANGELOG.md b/packages/experimental-utils/CHANGELOG.md index 2776535130f..cee45cb853b 100644 --- a/packages/experimental-utils/CHANGELOG.md +++ b/packages/experimental-utils/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/experimental-utils + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/experimental-utils diff --git a/packages/experimental-utils/package.json b/packages/experimental-utils/package.json index cb9baec6ed6..214b518e8eb 100644 --- a/packages/experimental-utils/package.json +++ b/packages/experimental-utils/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/experimental-utils", - "version": "4.16.1", + "version": "4.17.0", "description": "(Experimental) Utilities for working with TypeScript + ESLint together", "keywords": [ "eslint", @@ -40,9 +40,9 @@ }, "dependencies": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/scope-manager": "4.16.1", - "@typescript-eslint/types": "4.16.1", - "@typescript-eslint/typescript-estree": "4.16.1", + "@typescript-eslint/scope-manager": "4.17.0", + "@typescript-eslint/types": "4.17.0", + "@typescript-eslint/typescript-estree": "4.17.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" }, diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index fc98f137193..c28cec93ad1 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/parser + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/parser diff --git a/packages/parser/package.json b/packages/parser/package.json index 4f306dd88b1..c1d8e83cae9 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/parser", - "version": "4.16.1", + "version": "4.17.0", "description": "An ESLint custom parser which leverages TypeScript ESTree", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -44,14 +44,14 @@ "eslint": "^5.0.0 || ^6.0.0 || ^7.0.0" }, "dependencies": { - "@typescript-eslint/scope-manager": "4.16.1", - "@typescript-eslint/types": "4.16.1", - "@typescript-eslint/typescript-estree": "4.16.1", + "@typescript-eslint/scope-manager": "4.17.0", + "@typescript-eslint/types": "4.17.0", + "@typescript-eslint/typescript-estree": "4.17.0", "debug": "^4.1.1" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/experimental-utils": "4.16.1", + "@typescript-eslint/experimental-utils": "4.17.0", "glob": "*", "typescript": "*" }, diff --git a/packages/scope-manager/CHANGELOG.md b/packages/scope-manager/CHANGELOG.md index f3cfeed1d18..dceda0dbd9d 100644 --- a/packages/scope-manager/CHANGELOG.md +++ b/packages/scope-manager/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/scope-manager + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/scope-manager diff --git a/packages/scope-manager/package.json b/packages/scope-manager/package.json index c38f88ed26c..f3347a3f541 100644 --- a/packages/scope-manager/package.json +++ b/packages/scope-manager/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/scope-manager", - "version": "4.16.1", + "version": "4.17.0", "description": "TypeScript scope analyser for ESLint", "keywords": [ "eslint", @@ -39,12 +39,12 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.16.1", - "@typescript-eslint/visitor-keys": "4.16.1" + "@typescript-eslint/types": "4.17.0", + "@typescript-eslint/visitor-keys": "4.17.0" }, "devDependencies": { "@types/glob": "*", - "@typescript-eslint/typescript-estree": "4.16.1", + "@typescript-eslint/typescript-estree": "4.17.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/shared-fixtures/CHANGELOG.md b/packages/shared-fixtures/CHANGELOG.md index 04637206dde..499029da532 100644 --- a/packages/shared-fixtures/CHANGELOG.md +++ b/packages/shared-fixtures/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/shared-fixtures + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/shared-fixtures diff --git a/packages/shared-fixtures/package.json b/packages/shared-fixtures/package.json index f5558a30eb3..3a4897315d2 100644 --- a/packages/shared-fixtures/package.json +++ b/packages/shared-fixtures/package.json @@ -1,5 +1,5 @@ { "name": "@typescript-eslint/shared-fixtures", - "version": "4.16.1", + "version": "4.17.0", "private": true } diff --git a/packages/types/CHANGELOG.md b/packages/types/CHANGELOG.md index 627e088a3f6..2206d4d67a5 100644 --- a/packages/types/CHANGELOG.md +++ b/packages/types/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/types + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/types diff --git a/packages/types/package.json b/packages/types/package.json index 0d04bd8296f..c6fcd11037e 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/types", - "version": "4.16.1", + "version": "4.17.0", "description": "Types for the TypeScript-ESTree AST spec", "keywords": [ "eslint", diff --git a/packages/typescript-estree/CHANGELOG.md b/packages/typescript-estree/CHANGELOG.md index 5cee167088c..3df66ed1e9b 100644 --- a/packages/typescript-estree/CHANGELOG.md +++ b/packages/typescript-estree/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/typescript-estree + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) diff --git a/packages/typescript-estree/package.json b/packages/typescript-estree/package.json index 784d2b788a9..fa0db38da5d 100644 --- a/packages/typescript-estree/package.json +++ b/packages/typescript-estree/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/typescript-estree", - "version": "4.16.1", + "version": "4.17.0", "description": "A parser that converts TypeScript source code into an ESTree compatible form", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -41,8 +41,8 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.16.1", - "@typescript-eslint/visitor-keys": "4.16.1", + "@typescript-eslint/types": "4.17.0", + "@typescript-eslint/visitor-keys": "4.17.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", @@ -59,7 +59,7 @@ "@types/is-glob": "*", "@types/semver": "*", "@types/tmp": "*", - "@typescript-eslint/shared-fixtures": "4.16.1", + "@typescript-eslint/shared-fixtures": "4.17.0", "glob": "*", "jest-specific-snapshot": "*", "make-dir": "*", diff --git a/packages/visitor-keys/CHANGELOG.md b/packages/visitor-keys/CHANGELOG.md index e0ecce16f41..c3f97732be6 100644 --- a/packages/visitor-keys/CHANGELOG.md +++ b/packages/visitor-keys/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.17.0](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.1...v4.17.0) (2021-03-08) + +**Note:** Version bump only for package @typescript-eslint/visitor-keys + + + + + ## [4.16.1](https://github.com/typescript-eslint/typescript-eslint/compare/v4.16.0...v4.16.1) (2021-03-01) **Note:** Version bump only for package @typescript-eslint/visitor-keys diff --git a/packages/visitor-keys/package.json b/packages/visitor-keys/package.json index 4287d36b0c8..78f382dcbd7 100644 --- a/packages/visitor-keys/package.json +++ b/packages/visitor-keys/package.json @@ -1,6 +1,6 @@ { "name": "@typescript-eslint/visitor-keys", - "version": "4.16.1", + "version": "4.17.0", "description": "Visitor keys used to help traverse the TypeScript-ESTree AST", "keywords": [ "eslint", @@ -38,7 +38,7 @@ "typecheck": "tsc -p tsconfig.json --noEmit" }, "dependencies": { - "@typescript-eslint/types": "4.16.1", + "@typescript-eslint/types": "4.17.0", "eslint-visitor-keys": "^2.0.0" }, "devDependencies": { From d3086d8acc6092964d98747d782417225871cb0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E5=AD=90=20=28Maiko=20Tan=29?= Date: Tue, 9 Mar 2021 12:10:32 +0800 Subject: [PATCH 05/19] docs(eslint-plugin): [no-floating-promises] correct typo in 'allowAsStatement' (#3154) --- packages/eslint-plugin/docs/rules/no-floating-promises.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-plugin/docs/rules/no-floating-promises.md b/packages/eslint-plugin/docs/rules/no-floating-promises.md index bda8c26b785..86923bfad79 100644 --- a/packages/eslint-plugin/docs/rules/no-floating-promises.md +++ b/packages/eslint-plugin/docs/rules/no-floating-promises.md @@ -77,7 +77,7 @@ void returnsPromise(); void Promise.reject('value'); ``` -With this option set to `true`, and if you are using `no-void`, you should turn on the [`allowAsAStatement`](https://eslint.org/docs/rules/no-void#allowasstatement) option. +With this option set to `true`, and if you are using `no-void`, you should turn on the [`allowAsStatement`](https://eslint.org/docs/rules/no-void#allowasstatement) option. ### `ignoreIIFE` From d0dea1b03eb1806b30fd6696cadfcc47c17abb86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 04:44:47 +0000 Subject: [PATCH 06/19] chore: bump @types/node from 14.14.31 to 14.14.32 (#3158) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.31 to 14.14.32. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 815a73208c8..b0b73086881 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1933,9 +1933,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.27": - version "14.14.31" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.31.tgz#72286bd33d137aa0d152d47ec7c1762563d34055" - integrity sha512-vFHy/ezP5qI0rFgJ7aQnjDXwAMrG0KqqIH7tQG5PPv3BWBayOPIQNBjVc/P6hhdZfMx51REc6tfDNXHUio893g== + version "14.14.32" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.32.tgz#90c5c4a8d72bbbfe53033f122341343249183448" + integrity sha512-/Ctrftx/zp4m8JOujM5ZhwzlWLx22nbQJiVqz8/zE15gOeEW+uly3FSX4fGFpcfEvFzXcMCJwq9lGVWgyARXhg== "@types/normalize-package-data@^2.4.0": version "2.4.0" From 58e8bb3cd2dcacc8a0cf51b40d7083f2bfe37d28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 08:20:16 +0000 Subject: [PATCH 07/19] chore: bump tsutils from 3.20.0 to 3.21.0 (#3166) Bumps [tsutils](https://github.com/ajafff/tsutils) from 3.20.0 to 3.21.0. - [Release notes](https://github.com/ajafff/tsutils/releases) - [Changelog](https://github.com/ajafff/tsutils/blob/master/CHANGELOG.md) - [Commits](https://github.com/ajafff/tsutils/compare/v3.20.0...v3.21.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index b0b73086881..984edff2b99 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8608,9 +8608,9 @@ tsutils@^2.29.0: tslib "^1.8.1" tsutils@^3.17.1: - version "3.20.0" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.20.0.tgz#ea03ea45462e146b53d70ce0893de453ff24f698" - integrity sha512-RYbuQuvkhuqVeXweWT3tJLKOEJ/UUw9GjNEZGWdrLLlM+611o1gwLHBpxoFJKKl25fLprp2eVthtKs5JOrNeXg== + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== dependencies: tslib "^1.8.1" From f3f2b6560640de37e81dbf0e7aac4aaa56b9aa12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 08:49:54 +0000 Subject: [PATCH 08/19] chore: bump cspell from 5.3.4 to 5.3.7 (#3167) Bumps [cspell](https://github.com/streetsidesoftware/cspell) from 5.3.4 to 5.3.7. - [Release notes](https://github.com/streetsidesoftware/cspell/releases) - [Changelog](https://github.com/streetsidesoftware/cspell/blob/master/CHANGELOG.md) - [Commits](https://github.com/streetsidesoftware/cspell/compare/v5.3.4...v5.3.7) Signed-off-by: dependabot[bot] --- yarn.lock | 60 +++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/yarn.lock b/yarn.lock index 984edff2b99..0ff27eedd8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -501,10 +501,10 @@ "@cspell/dict-software-terms" "^1.0.26" "@cspell/dict-typescript" "^1.0.16" -"@cspell/cspell-types@^5.3.4": - version "5.3.4" - resolved "https://registry.yarnpkg.com/@cspell/cspell-types/-/cspell-types-5.3.4.tgz#20aafa6debdd58fa825ebf4159016f3f57106be2" - integrity sha512-dM5sblEPqgrCUc53FSzJxrObEqYzVg70iqGMcGrawXy3wk5BiiO7caXWaRuhe0Wy5ooytI5nJK3oRELS8A501g== +"@cspell/cspell-types@^5.3.7": + version "5.3.7" + resolved "https://registry.yarnpkg.com/@cspell/cspell-types/-/cspell-types-5.3.7.tgz#778042121e2b342693c22937e23072c0382c7351" + integrity sha512-3cJcxV8rJez2MLOGuCQEdMVzXUEzH6XsUr3EzO7IDCt6fK66YGTGFuDIHVya1H3xQ+EENv/o9mZh13LNBxikVg== "@cspell/dict-ada@^1.1.1": version "1.1.1" @@ -3177,59 +3177,59 @@ crypto-random-string@^2.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== -cspell-glob@^5.3.4: - version "5.3.4" - resolved "https://registry.yarnpkg.com/cspell-glob/-/cspell-glob-5.3.4.tgz#656188388467f8be7e115924e7b43ba85c234fa4" - integrity sha512-SrtfNUP7CqFstTzuRscGI5IFYu1j3ay5a9ioFTx2CoaFqp2BXqFpE8z9NE6Lao+7z7Fg4hiPgvsCd1gn3J/P8A== +cspell-glob@^5.3.7: + version "5.3.7" + resolved "https://registry.yarnpkg.com/cspell-glob/-/cspell-glob-5.3.7.tgz#0677b43f22c06921d24699529cfd70027b10433c" + integrity sha512-YoOiFEI0fhs2XU0F9Lrg5emKHR2tCrDabG/hVjhEDKYRSN9D7Zx+2hXKFmi0ssmW38XKIqpnmtW/dye1LHffjQ== dependencies: micromatch "^4.0.2" -cspell-io@^5.3.4: - version "5.3.4" - resolved "https://registry.yarnpkg.com/cspell-io/-/cspell-io-5.3.4.tgz#b468ae8d92de863a5aad5d6d4a542e4ebe63b63d" - integrity sha512-1IHuU8Y4zxGj/nyH6DawKwQevRNYiSjPqoLjqyJFeMtd3Nix0mVHf0UxotPiHhuZkuuMgQkxA4EeavGDS5jOng== +cspell-io@^5.3.7: + version "5.3.7" + resolved "https://registry.yarnpkg.com/cspell-io/-/cspell-io-5.3.7.tgz#07ad1e719b6f4f9274535502a425ba706b91cb60" + integrity sha512-uQZed/E+mBsAxH8rW9GqYL8IqaT1Ed4FJZnK4zjIWcY3KPpNnGAywY5XtvcfQSn59WIyjhztzle06z7wGHP8Jg== dependencies: iconv-lite "^0.6.2" iterable-to-stream "^1.0.1" -cspell-lib@^5.3.4: - version "5.3.4" - resolved "https://registry.yarnpkg.com/cspell-lib/-/cspell-lib-5.3.4.tgz#039b4ddd3bfbb24038ef362590ab2b3a2dc8c89c" - integrity sha512-uA35jAW3CAqJeRZhQdAmhDfoHVCK0kBQcXEAerWO1z4xDThE/JRAJEKMAXirVIQufOu9X2btjQZse9ubg0p7sQ== +cspell-lib@^5.3.7: + version "5.3.7" + resolved "https://registry.yarnpkg.com/cspell-lib/-/cspell-lib-5.3.7.tgz#ae1927b98449812cd90ada0cc18d172d86b38be6" + integrity sha512-jWHayjdQfpy4dhMAYfdyi33lW8X4ka/t7Bai9WNoRnhsNAzrAuMuo4FX6aiclGXpBLrnm2Por3foyPagcKd69Q== dependencies: "@cspell/cspell-bundled-dicts" "^5.3.4" - "@cspell/cspell-types" "^5.3.4" + "@cspell/cspell-types" "^5.3.7" comment-json "^4.1.0" configstore "^5.0.1" cosmiconfig "^7.0.0" - cspell-glob "^5.3.4" - cspell-io "^5.3.4" - cspell-trie-lib "^5.3.4" + cspell-glob "^5.3.7" + cspell-io "^5.3.7" + cspell-trie-lib "^5.3.7" fs-extra "^9.1.0" gensequence "^3.1.1" resolve-from "^5.0.0" resolve-global "^1.0.0" vscode-uri "^3.0.2" -cspell-trie-lib@^5.3.4: - version "5.3.4" - resolved "https://registry.yarnpkg.com/cspell-trie-lib/-/cspell-trie-lib-5.3.4.tgz#5e10424a265d6362810e2fd0ad64e4e214f46367" - integrity sha512-WaMGBIdbmOwle7pSmrOMQqfY4ndbNIGiQvpU0xuTWAzvcL/sCzgfqiDt7sI8Mr8vnSGnAphRn0xLlNqXzAgn1Q== +cspell-trie-lib@^5.3.7: + version "5.3.7" + resolved "https://registry.yarnpkg.com/cspell-trie-lib/-/cspell-trie-lib-5.3.7.tgz#8d13637e17e96fb5cf656baa57f67d8366830f75" + integrity sha512-gfm/EzYCgaCC8RvB1jAYxMDGqdmqupDALaEHExnOGJUe5ZUNEH8E7YWEsMemHOdjd9vgSFcGpecoFUFBfkKXXA== dependencies: fs-extra "^9.1.0" gensequence "^3.1.1" cspell@^5.2.4: - version "5.3.4" - resolved "https://registry.yarnpkg.com/cspell/-/cspell-5.3.4.tgz#1d79d3bde38a91adcda9fde4b2aa553746ff2f51" - integrity sha512-AXiZzeXXBVZIwRsD30bloqOaJEjTF3e/nzXCLHUq3Eyqiy1ySWMnOMm3OXQ1nI7nkjYpx5+Pdx7cDlH0wFrKYQ== + version "5.3.7" + resolved "https://registry.yarnpkg.com/cspell/-/cspell-5.3.7.tgz#00be25bc8bab89628021b49d1322033c4f00f720" + integrity sha512-KNs1i/4pBejBMu536atrVJFVdKg1nBF0BZy3GoVwIMCABxkx8KuGaE7uj2JUaHFjlp1s7ICw/p50eL/FL0HerA== dependencies: - "@cspell/cspell-types" "^5.3.4" + "@cspell/cspell-types" "^5.3.7" chalk "^4.1.0" commander "^7.1.0" comment-json "^4.1.0" - cspell-glob "^5.3.4" - cspell-lib "^5.3.4" + cspell-glob "^5.3.7" + cspell-lib "^5.3.7" fs-extra "^9.1.0" get-stdin "^8.0.0" glob "^7.1.6" From 901a7c90328bb0bd102a2b5fbba9c91141a1d37c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 22:04:58 +0100 Subject: [PATCH 09/19] chore: bump @types/prettier from 2.2.1 to 2.2.2 (#3159) Bumps [@types/prettier](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/prettier) from 2.2.1 to 2.2.2. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/prettier) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0ff27eedd8e..901fe93b5fd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1948,9 +1948,9 @@ integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== "@types/prettier@*", "@types/prettier@^2.0.0", "@types/prettier@^2.2.1": - version "2.2.1" - resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.1.tgz#374e31645d58cb18a07b3ecd8e9dede4deb2cccd" - integrity sha512-DxZZbyMAM9GWEzXL+BMZROWz9oo6A9EilwwOMET2UVu2uZTqMWS5S69KVtuVKaRjCUpcrOXRalet86/OpG4kqw== + version "2.2.2" + resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.2.2.tgz#e2280c89ddcbeef340099d6968d8c86ba155fdf6" + integrity sha512-i99hy7Ki19EqVOl77WplDrvgNugHnsSjECVR/wUrzw2TJXz1zlUfT2ngGckR6xN7yFYaijsMAqPkOLx9HgUqHg== "@types/rimraf@^3.0.0": version "3.0.0" From 648c3b594cdf01b676a6c40569f5ee435e9eb742 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 23:40:39 +0100 Subject: [PATCH 10/19] chore: bump markdownlint-cli from 0.26.0 to 0.27.1 (#3157) Bumps [markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) from 0.26.0 to 0.27.1. - [Release notes](https://github.com/igorshubovych/markdownlint-cli/releases) - [Commits](https://github.com/igorshubovych/markdownlint-cli/compare/v0.26.0...v0.27.1) Signed-off-by: dependabot[bot] --- package.json | 2 +- yarn.lock | 65 +++++++++++++++++++++++++++++----------------------- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index 65d383df6c6..3890f124c1b 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "lerna": "^3.22.1", "lint-staged": "^10.2.13", "make-dir": "^3.1.0", - "markdownlint-cli": "^0.26.0", + "markdownlint-cli": "^0.27.1", "prettier": "^2.2.1", "rimraf": "^3.0.2", "ts-jest": "^26.5.1", diff --git a/yarn.lock b/yarn.lock index 901fe93b5fd..69e8e121c37 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2883,12 +2883,12 @@ commander@^2.12.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== -commander@^6.2.0, commander@~6.2.1: +commander@^6.2.0: version "6.2.1" resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c" integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== -commander@^7.1.0: +commander@^7.1.0, commander@~7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/commander/-/commander-7.1.0.tgz#f2eaecf131f10e36e07d894698226e36ae0eb5ff" integrity sha512-pRxBna3MJe6HKnBGsDyMv8ETbptw3axEdYHoqNh7gu5oDcew8fs0xnivZGm06Ogk8zGAJ9VX+OPEr2GXEQK4dg== @@ -3618,10 +3618,10 @@ enquirer@^2.3.5, enquirer@^2.3.6: dependencies: ansi-colors "^4.1.1" -entities@~2.0.0: - version "2.0.3" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.3.tgz#5c487e5742ab93c15abb5da22759b8590ec03b7f" - integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ== +entities@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" + integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== env-paths@^2.2.0: version "2.2.0" @@ -5626,7 +5626,7 @@ js-tokens@^4.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-yaml@^3.13.1, js-yaml@~3.14.1: +js-yaml@^3.13.1: version "3.14.1" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.1.tgz#dae812fdb3825fa306609a8717383c50c36a0537" integrity sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== @@ -5634,6 +5634,13 @@ js-yaml@^3.13.1, js-yaml@~3.14.1: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.0.0.tgz#f426bc0ff4b4051926cd588c71113183409a121f" + integrity sha512-pqon0s+4ScYUvX30wxQi3PogGFAlUyH0awepWvwkj4jD4v+ova3RiYw8bmA6x2rDrEaj8i/oWKoRxpVNW+Re8Q== + dependencies: + argparse "^2.0.1" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -6161,48 +6168,48 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" -markdown-it@12.0.2: - version "12.0.2" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.0.2.tgz#4401beae8df8aa2221fc6565a7188e60a06ef0ed" - integrity sha512-4Lkvjbv2kK+moL9TbeV+6/NHx+1Q+R/NIdUlFlkqkkzUcTod4uiyTJRiBidKR9qXSdkNFkgv+AELY8KN9vSgVA== +markdown-it@12.0.4: + version "12.0.4" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.0.4.tgz#eec8247d296327eac3ba9746bdeec9cfcc751e33" + integrity sha512-34RwOXZT8kyuOJy25oJNJoulO8L0bTHYWXcdZBYZqFnjIy3NgjeoM3FmPXIOFQ26/lSHYMr8oc62B6adxXcb3Q== dependencies: argparse "^2.0.1" - entities "~2.0.0" + entities "~2.1.0" linkify-it "^3.0.1" mdurl "^1.0.1" uc.micro "^1.0.5" -markdownlint-cli@^0.26.0: - version "0.26.0" - resolved "https://registry.yarnpkg.com/markdownlint-cli/-/markdownlint-cli-0.26.0.tgz#cd89e3e39a049303ec125c8aa291da4f3325df29" - integrity sha512-biLfeGNZG9nw0yJbtFBzRlew2/P5w7JSseKwolSox3zejs7dLpGvPgqbC+iqJnqqGWcWLtXaXh8bBEKWmfl10A== +markdownlint-cli@^0.27.1: + version "0.27.1" + resolved "https://registry.yarnpkg.com/markdownlint-cli/-/markdownlint-cli-0.27.1.tgz#8fa095eea94936b6dea891f9db7f269c60e6d6fa" + integrity sha512-p1VV6aSbGrDlpUWzHizAnSNEQAweVR3qUI/AIUubxW7BGPXziSXkIED+uRtSohUlRS/jmqp3Wi4es5j6fIrdeQ== dependencies: - commander "~6.2.1" + commander "~7.1.0" deep-extend "~0.6.0" get-stdin "~8.0.0" glob "~7.1.6" ignore "~5.1.8" - js-yaml "~3.14.1" + js-yaml "^4.0.0" jsonc-parser "~3.0.0" lodash.differencewith "~4.5.0" lodash.flatten "~4.4.0" - markdownlint "~0.22.0" - markdownlint-rule-helpers "~0.13.0" + markdownlint "~0.23.1" + markdownlint-rule-helpers "~0.14.0" minimatch "~3.0.4" minimist "~1.2.5" rc "~1.2.8" -markdownlint-rule-helpers@~0.13.0: - version "0.13.0" - resolved "https://registry.yarnpkg.com/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.13.0.tgz#7cc6553bc7f8c4c8a43cf66fb2a3a652124f46f9" - integrity sha512-rRY0itbcHG4e+ntz0bbY3AIceSJMKS0TafEMgEtKVHRZ54/JUSy6/4ypCL618RlJvYRej+xMLxX5nkJqIeTZaQ== +markdownlint-rule-helpers@~0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.14.0.tgz#4d0e1ae320e85559d8cbed1490934855791627bb" + integrity sha512-vRTPqSU4JK8vVXmjICHSBhwXUvbfh/VJo+j7hvxqe15tLJyomv3FLgFdFgb8kpj0Fe8SsJa/TZUAXv7/sN+N7A== -markdownlint@~0.22.0: - version "0.22.0" - resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.22.0.tgz#4ed95b61c17ae9f4dfca6a01f038c744846c0a72" - integrity sha512-J4B+iMc12pOdp/wfYi03W2qfAfEyiZzq3qvQh/8vOMNU8vXYY6Jg440EY7dWTBCqROhb1i4nAn3BTByJ5kdx1w== +markdownlint@~0.23.1: + version "0.23.1" + resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.23.1.tgz#98292b5d340d01e9c113f3d7fb3b2ccf89628dc2" + integrity sha512-iOEwhDfNmq2IJlaA8mzEkHYUi/Hwoa6Ss+HO5jkwUR6wQ4quFr0WzSx+Z9rsWZKUaPbyirIdL1zGmJRkWawr4Q== dependencies: - markdown-it "12.0.2" + markdown-it "12.0.4" marked@^2.0.0: version "2.0.1" From 946ee3b68823a48fad2cb7b99589e56a68fb11e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Mar 2021 22:53:09 +0000 Subject: [PATCH 11/19] chore: bump husky from 5.1.2 to 5.1.3 (#3155) Bumps [husky](https://github.com/typicode/husky) from 5.1.2 to 5.1.3. - [Release notes](https://github.com/typicode/husky/releases) - [Commits](https://github.com/typicode/husky/compare/v5.1.2...v5.1.3) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 69e8e121c37..fff52573313 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4707,9 +4707,9 @@ humanize-ms@^1.2.1: ms "^2.0.0" husky@^5.0.9: - version "5.1.2" - resolved "https://registry.yarnpkg.com/husky/-/husky-5.1.2.tgz#dc6a1f68640455d8d98c28875e073087f86c5081" - integrity sha512-lilaRYeDXcAOj8DuRnN9IxUyEMVbYg9rK7yVNkPB5V4hCvxIUxpMeiv9K2h77CE0HzjCnk1Br0oWe1IghXngDQ== + version "5.1.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-5.1.3.tgz#1a0645a4fe3ffc006c4d0d8bd0bcb4c98787cc9d" + integrity sha512-fbNJ+Gz5wx2LIBtMweJNY1D7Uc8p1XERi5KNRMccwfQA+rXlxWNSdUxswo0gT8XqxywTIw7Ywm/F4v/O35RdMg== iconv-lite@0.4.24, iconv-lite@^0.4.24: version "0.4.24" From 663f6db0f36751a9f5009ac8c340a6f3b5211a0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:57:20 -0700 Subject: [PATCH 12/19] chore: bump @babel/parser from 7.13.4 to 7.13.10 (#3165) Bumps [@babel/parser](https://github.com/babel/babel/tree/HEAD/packages/babel-parser) from 7.13.4 to 7.13.10. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.13.10/packages/babel-parser) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index fff52573313..e5a4eec0590 100644 --- a/yarn.lock +++ b/yarn.lock @@ -172,9 +172,9 @@ js-tokens "^4.0.0" "@babel/parser@^7.1.0", "@babel/parser@^7.12.13", "@babel/parser@^7.13.0", "@babel/parser@^7.13.4": - version "7.13.4" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.4.tgz#340211b0da94a351a6f10e63671fa727333d13ab" - integrity sha512-uvoOulWHhI+0+1f9L4BoozY7U5cIkZ9PgJqvb041d6vypgUmtVPG4vmGm4pSggjl8BELzvHyUeJSUyEMY6b+qA== + version "7.13.10" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.13.10.tgz#8f8f9bf7b3afa3eabd061f7a5bcdf4fec3c48409" + integrity sha512-0s7Mlrw9uTWkYua7xWr99Wpk2bnGa0ANleKfksYAES8LpWH4gW1OUr42vqKNf0us5UQNfru2wPqMqRITzq/SIQ== "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" From 5a189cae7d90956ed539fdb9ec6aa2f2441c71b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:57:34 -0700 Subject: [PATCH 13/19] chore: bump @types/marked from 1.2.2 to 2.0.0 (#3168) Bumps [@types/marked](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/marked) from 1.2.2 to 2.0.0. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/marked) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3890f124c1b..899495949d4 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@types/jest": "^26.0.20", "@types/jest-specific-snapshot": "^0.5.5", "@types/lodash": "^4.14.149", - "@types/marked": "^1.1.0", + "@types/marked": "^2.0.0", "@types/node": "^14.14.27", "@types/prettier": "^2.2.1", "@types/rimraf": "^3.0.0", diff --git a/yarn.lock b/yarn.lock index e5a4eec0590..7b3d853403a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1917,10 +1917,10 @@ resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.168.tgz#fe24632e79b7ade3f132891afff86caa5e5ce008" integrity sha512-oVfRvqHV/V6D1yifJbVRU3TMp8OT6o6BG+U9MkwuJ3U8/CsDHvalRpsxBqivn71ztOFZBTfJMvETbqHiaNSj7Q== -"@types/marked@*", "@types/marked@^1.1.0": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@types/marked/-/marked-1.2.2.tgz#1f858a0e690247ecf3b2eef576f98f86e8d960d4" - integrity sha512-wLfw1hnuuDYrFz97IzJja0pdVsC0oedtS4QsKH1/inyW9qkLQbXgMUqEQT0MVtUBx3twjWeInUfjQbhBVLECXw== +"@types/marked@*", "@types/marked@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@types/marked/-/marked-2.0.0.tgz#9319de90410be0ba43d5cad0ede2c26e57edb9eb" + integrity sha512-kSOVa3R6HJvFdd3UIbTYvrSBTPHjXhNErh7/8oSCKOwqdOkk4Oj8N77n+f6dsgd1jW3j3SU5EhnmRxPhNKOmtQ== "@types/minimatch@*": version "3.0.3" From 0a36006eba0ed1c959c2bf991042118ef216e6f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:57:53 -0700 Subject: [PATCH 14/19] chore: bump ts-jest from 26.5.2 to 26.5.3 (#3170) Bumps [ts-jest](https://github.com/kulshekhar/ts-jest) from 26.5.2 to 26.5.3. - [Release notes](https://github.com/kulshekhar/ts-jest/releases) - [Changelog](https://github.com/kulshekhar/ts-jest/blob/master/CHANGELOG.md) - [Commits](https://github.com/kulshekhar/ts-jest/compare/v26.5.2...v26.5.3) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7b3d853403a..8f76d04e5a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1894,7 +1894,7 @@ dependencies: "@types/jest" "*" -"@types/jest@*", "@types/jest@26.x", "@types/jest@^26.0.20": +"@types/jest@*", "@types/jest@^26.0.20": version "26.0.20" resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.20.tgz#cd2f2702ecf69e86b586e1f5223a60e454056307" integrity sha512-9zi2Y+5USJRxd0FsahERhBwlcvFh6D2GLQnY2FH2BzK8J9s9omvNHIbvABwIluXa0fD8XVKMLTO0aOEuUfACAA== @@ -8545,11 +8545,10 @@ trim-off-newlines@^1.0.0: integrity sha1-n5up2e+odkw4dpi8v+sshI8RrbM= ts-jest@^26.5.1: - version "26.5.2" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.2.tgz#5281d6b44c2f94f71205728a389edc3d7995b0c4" - integrity sha512-bwyJ2zJieSugf7RB+o8fgkMeoMVMM2KPDE0UklRLuACxjwJsOrZNo6chrcScmK33YavPSwhARffy8dZx5LJdUQ== + version "26.5.3" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.3.tgz#a6ee00ba547be3b09877550df40a1465d0295554" + integrity sha512-nBiiFGNvtujdLryU7MiMQh1iPmnZ/QvOskBbD2kURiI1MwqvxlxNnaAB/z9TbslMqCsSbu5BXvSSQPc5tvHGeA== dependencies: - "@types/jest" "26.x" bs-logger "0.x" buffer-from "1.x" fast-json-stable-stringify "2.x" @@ -9121,10 +9120,10 @@ yaml@^1.10.0: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== -yargs-parser@20.x: - version "20.2.5" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.5.tgz#5d37729146d3f894f39fc94b6796f5b239513186" - integrity sha512-jYRGS3zWy20NtDtK2kBgo/TlAoy5YUuhD9/LZ7z7W4j1Fdw2cqD0xEEclf8fxc8xjD6X5Qr+qQQwCEsP8iRiYg== +yargs-parser@20.x, yargs-parser@^20.2.2: + version "20.2.6" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.6.tgz#69f920addf61aafc0b8b89002f5d66e28f2d8b20" + integrity sha512-AP1+fQIWSM/sMiET8fyayjx/J+JmTPt2Mr0FkrgqB4todtfa53sOsrSAcIrJRD5XS20bKUwaDIuMkWKCEiQLKA== yargs-parser@^15.0.1: version "15.0.1" @@ -9142,11 +9141,6 @@ yargs-parser@^18.1.2, yargs-parser@^18.1.3: camelcase "^5.0.0" decamelize "^1.2.0" -yargs-parser@^20.2.2: - version "20.2.6" - resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.6.tgz#69f920addf61aafc0b8b89002f5d66e28f2d8b20" - integrity sha512-AP1+fQIWSM/sMiET8fyayjx/J+JmTPt2Mr0FkrgqB4todtfa53sOsrSAcIrJRD5XS20bKUwaDIuMkWKCEiQLKA== - yargs@^14.2.2: version "14.2.3" resolved "https://registry.yarnpkg.com/yargs/-/yargs-14.2.3.tgz#1a1c3edced1afb2a2fea33604bc6d1d8d688a414" From d9e7916e9c5897d81f01a4ccf1db96bcd39a0f38 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 00:58:35 -0700 Subject: [PATCH 15/19] chore: bump @types/node from 14.14.32 to 14.14.34 (#3184) Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 14.14.32 to 14.14.34. - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8f76d04e5a9..fe60fd9f01c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1933,9 +1933,9 @@ integrity sha1-aaI6OtKcrwCX8G7aWbNh7i8GOfY= "@types/node@*", "@types/node@>= 8", "@types/node@^14.14.27": - version "14.14.32" - resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.32.tgz#90c5c4a8d72bbbfe53033f122341343249183448" - integrity sha512-/Ctrftx/zp4m8JOujM5ZhwzlWLx22nbQJiVqz8/zE15gOeEW+uly3FSX4fGFpcfEvFzXcMCJwq9lGVWgyARXhg== + version "14.14.34" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.34.tgz#07935194fc049069a1c56c0c274265abeddf88da" + integrity sha512-dBPaxocOK6UVyvhbnpFIj2W+S+1cBTkHQbFQfeeJhoKFbzYcVUGHvddeWPSucKATb3F0+pgDq0i6ghEaZjsugA== "@types/normalize-package-data@^2.4.0": version "2.4.0" From a1486736d8ef3555832ddfb27fd0980368b363f5 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Mon, 15 Mar 2021 09:59:51 +0200 Subject: [PATCH 16/19] fix(eslint-plugin): [no-extran-class] allowWithDecorator should ignore other errors (#3160) --- .../src/rules/no-extraneous-class.ts | 4 +-- .../tests/rules/no-extraneous-class.test.ts | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/rules/no-extraneous-class.ts b/packages/eslint-plugin/src/rules/no-extraneous-class.ts index 996dd0ea71c..e57ee5546a3 100644 --- a/packages/eslint-plugin/src/rules/no-extraneous-class.ts +++ b/packages/eslint-plugin/src/rules/no-extraneous-class.ts @@ -79,13 +79,13 @@ export default util.createRule({ | TSESTree.ClassExpression | undefined; - if (!parent || parent.superClass) { + if (!parent || parent.superClass || isAllowWithDecorator(parent)) { return; } const reportNode = 'id' in parent && parent.id ? parent.id : parent; if (node.body.length === 0) { - if (allowEmpty || isAllowWithDecorator(parent)) { + if (allowEmpty) { return; } diff --git a/packages/eslint-plugin/tests/rules/no-extraneous-class.test.ts b/packages/eslint-plugin/tests/rules/no-extraneous-class.test.ts index 2bb96f196ef..44d32490a10 100644 --- a/packages/eslint-plugin/tests/rules/no-extraneous-class.test.ts +++ b/packages/eslint-plugin/tests/rules/no-extraneous-class.test.ts @@ -76,6 +76,19 @@ class Foo {} `, options: [{ allowWithDecorator: true }], }, + { + code: ` +@FooDecorator +class Foo { + constructor(foo: Foo) { + foo.subscribe(a => { + console.log(a); + }); + } +} + `, + options: [{ allowWithDecorator: true }], + }, ], invalid: [ @@ -150,5 +163,23 @@ class Foo {} }, ], }, + { + code: ` +@FooDecorator +class Foo { + constructor(foo: Foo) { + foo.subscribe(a => { + console.log(a); + }); + } +} + `, + options: [{ allowWithDecorator: false }], + errors: [ + { + messageId: 'onlyConstructor', + }, + ], + }, ], }); From 08b058a7a6db3b59c28753bb322717e1fee44d1f Mon Sep 17 00:00:00 2001 From: JounQin Date: Mon, 15 Mar 2021 16:09:02 +0800 Subject: [PATCH 17/19] feat(eslint-plugin): add package type declaration (#3164) --- packages/eslint-plugin/index.d.ts | 4 ++++ packages/eslint-plugin/package.json | 2 ++ packages/eslint-plugin/tsconfig.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 packages/eslint-plugin/index.d.ts diff --git a/packages/eslint-plugin/index.d.ts b/packages/eslint-plugin/index.d.ts new file mode 100644 index 00000000000..8092cabcc4b --- /dev/null +++ b/packages/eslint-plugin/index.d.ts @@ -0,0 +1,4 @@ +import { TSESLint } from '@typescript-eslint/experimental-utils'; + +export const rules: Record>; +export const configs: Record; diff --git a/packages/eslint-plugin/package.json b/packages/eslint-plugin/package.json index 87cfd4ab800..911d8e7772b 100644 --- a/packages/eslint-plugin/package.json +++ b/packages/eslint-plugin/package.json @@ -14,6 +14,7 @@ "files": [ "dist", "docs", + "index.d.ts", "package.json", "README.md", "LICENSE" @@ -28,6 +29,7 @@ }, "license": "MIT", "main": "dist/index.js", + "types": "index.d.ts", "scripts": { "build": "tsc -b tsconfig.build.json", "check:docs": "jest tests/docs.test.ts --runTestsByPath --silent --runInBand", diff --git a/packages/eslint-plugin/tsconfig.json b/packages/eslint-plugin/tsconfig.json index a0cdad04869..c7e9c4ecb2b 100644 --- a/packages/eslint-plugin/tsconfig.json +++ b/packages/eslint-plugin/tsconfig.json @@ -4,7 +4,7 @@ "composite": false, "rootDir": "." }, - "include": ["src", "typings", "tests", "tools"], + "include": ["src", "typings", "tests", "tools", "index.d.ts"], "references": [ { "path": "../experimental-utils/tsconfig.build.json" }, { "path": "../parser/tsconfig.build.json" }, From 1a96426c7a8d60ef5d04a89578cf664a82905ce9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 01:09:36 -0700 Subject: [PATCH 18/19] chore: bump eslint-plugin-jest from 24.1.5 to 24.2.1 (#3172) Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 24.1.5 to 24.2.1. - [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases) - [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/main/CHANGELOG.md) - [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v24.1.5...v24.2.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Armano --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index fe60fd9f01c..4d15d230e25 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3759,9 +3759,9 @@ eslint-plugin-import@^2.22.0: tsconfig-paths "^3.9.0" eslint-plugin-jest@^24.1.3: - version "24.1.5" - resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.1.5.tgz#1e866a9f0deac587d0a3d5d7cefe99815a580de2" - integrity sha512-FIP3lwC8EzEG+rOs1y96cOJmMVpdFNreoDJv29B5vIupVssRi8zrSY3QadogT0K3h1Y8TMxJ6ZSAzYUmFCp2hg== + version "24.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.2.1.tgz#7e84f16a3ca6589b86be9732a93d71367a4ed627" + integrity sha512-s24ve8WUu3DLVidvlSzaqlOpTZre9lTkZTAO+a7X0WMtj8HraWTiTEkW3pbDT1xVxqEHMWSv+Kx7MyqR50nhBw== dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" From 55e1fbaca985b500cad1cc9ec25717b18cf5a17b Mon Sep 17 00:00:00 2001 From: Anton Kalmanovich Date: Mon, 15 Mar 2021 10:13:03 +0200 Subject: [PATCH 19/19] fix(eslint-plugin): [explicit-module-boundary-types] fixes #2864 related to functions in nested object properties (#3178) --- .../src/util/explicitReturnTypeUtils.ts | 6 ++-- .../explicit-function-return-type.test.ts | 28 +++++++++++++++++++ .../explicit-module-boundary-types.test.ts | 28 +++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts index cd2f0b11826..c05d6c6dab3 100644 --- a/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts +++ b/packages/eslint-plugin/src/util/explicitReturnTypeUtils.ts @@ -52,11 +52,12 @@ function isConstructorArgument( } /** - * Checks if a node belongs to: + * Checks if a node is a property or a nested property of a typed object: * ``` * const x: Foo = { prop: () => {} } * const x = { prop: () => {} } as Foo * const x = { prop: () => {} } + * const x: Foo = { bar: { prop: () => {} } } * ``` */ function isPropertyOfObjectWithType( @@ -82,7 +83,8 @@ function isPropertyOfObjectWithType( isTypeAssertion(parent) || isClassPropertyWithTypeAnnotation(parent) || isVariableDeclaratorWithTypeAnnotation(parent) || - isFunctionArgument(parent) + isFunctionArgument(parent) || + isPropertyOfObjectWithType(parent) ); } diff --git a/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts b/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts index 6ce8210822b..4faf3fa18b7 100644 --- a/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts @@ -156,6 +156,34 @@ const x = { code: ` const x: Foo = { foo: () => {}, +}; + `, + options: [{ allowTypedFunctionExpressions: true }], + }, + // https://github.com/typescript-eslint/typescript-eslint/issues/2864 + { + filename: 'test.ts', + code: ` +const x = { + foo: { bar: () => {} }, +} as Foo; + `, + options: [{ allowTypedFunctionExpressions: true }], + }, + { + filename: 'test.ts', + code: ` +const x = { + foo: { bar: () => {} }, +}; + `, + options: [{ allowTypedFunctionExpressions: true }], + }, + { + filename: 'test.ts', + code: ` +const x: Foo = { + foo: { bar: () => {} }, }; `, options: [{ allowTypedFunctionExpressions: true }], diff --git a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts index 3652ebc876a..e05f4f09230 100644 --- a/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts +++ b/packages/eslint-plugin/tests/rules/explicit-module-boundary-types.test.ts @@ -181,6 +181,34 @@ export const x = { code: ` export const x: Foo = { foo: () => {}, +}; + `, + options: [{ allowTypedFunctionExpressions: true }], + }, + // https://github.com/typescript-eslint/typescript-eslint/issues/2864 + { + filename: 'test.ts', + code: ` +export const x = { + foo: { bar: () => {} }, +} as Foo; + `, + options: [{ allowTypedFunctionExpressions: true }], + }, + { + filename: 'test.ts', + code: ` +export const x = { + foo: { bar: () => {} }, +}; + `, + options: [{ allowTypedFunctionExpressions: true }], + }, + { + filename: 'test.ts', + code: ` +export const x: Foo = { + foo: { bar: () => {} }, }; `, options: [{ allowTypedFunctionExpressions: true }],