Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-10-09 17:38:29 +00:00
parent 5d6442e87d
commit 026e833827
36 changed files with 1972 additions and 643 deletions

View file

@ -117,19 +117,17 @@ exports.default = (0, util_1.createRule)({
evaluatedLength.value === evaluatedString.value.length);
}
/**
* Check if a given node is a negative index expression
*
* E.g. `s.slice(- <expr>)`, `s.substring(s.length - <expr>)`
*
* @param node The node to check.
* @param expectedIndexedNode The node which is expected as the receiver of index expression.
* Returns true if `node` is `-substring.length` or
* `parentString.length - substring.length`
*/
function isNegativeIndexExpression(node, expectedIndexedNode) {
function isLengthAheadOfEnd(node, substring, parentString) {
return ((node.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
node.operator === '-') ||
node.operator === '-' &&
isLengthExpression(node.argument, substring)) ||
(node.type === utils_1.AST_NODE_TYPES.BinaryExpression &&
node.operator === '-' &&
isLengthExpression(node.left, expectedIndexedNode)));
isLengthExpression(node.left, parentString) &&
isLengthExpression(node.right, substring)));
}
/**
* Check if a given node is the expression of the last index.
@ -405,14 +403,34 @@ exports.default = (0, util_1.createRule)({
if (!isEqualityComparison(parentNode) || !isStringType(node.object)) {
return;
}
const isEndsWith = (callNode.arguments.length === 1 ||
(callNode.arguments.length === 2 &&
isLengthExpression(callNode.arguments[1], node.object))) &&
isNegativeIndexExpression(callNode.arguments[0], node.object);
const isStartsWith = !isEndsWith &&
callNode.arguments.length === 2 &&
let isEndsWith = false;
let isStartsWith = false;
if (callNode.arguments.length === 1) {
if (
// foo.slice(-bar.length) === bar
// foo.slice(foo.length - bar.length) === bar
isLengthAheadOfEnd(callNode.arguments[0], parentNode.right, node.object)) {
isEndsWith = true;
}
}
else if (callNode.arguments.length === 2) {
if (
// foo.slice(0, bar.length) === bar
isNumber(callNode.arguments[0], 0) &&
!isNegativeIndexExpression(callNode.arguments[1], node.object);
isLengthExpression(callNode.arguments[1], parentNode.right)) {
isStartsWith = true;
}
else if (
// foo.slice(foo.length - bar.length, foo.length) === bar
// foo.slice(foo.length - bar.length, 0) === bar
// foo.slice(-bar.length, foo.length) === bar
// foo.slice(-bar.length, 0) === bar
(isLengthExpression(callNode.arguments[1], node.object) ||
isNumber(callNode.arguments[1], 0)) &&
isLengthAheadOfEnd(callNode.arguments[0], parentNode.right, node.object)) {
isEndsWith = true;
}
}
if (!isStartsWith && !isEndsWith) {
return;
}

File diff suppressed because one or more lines are too long

View file

@ -76,7 +76,7 @@ declare function acceptsBoolean(arg: boolean): void;
acceptsBoolean(foo != null && foo.bar);
// ❌ typechecks UNSUCCESSFULLY as the expression returns `boolean | undefined`
acceptsBoolean(foo != null && foo.bar);
acceptsBoolean(foo?.bar);
```
This style of code isn't super common - which means having this option set to `true` _should_ be safe in most codebases. However we default it to `false` due to its unsafe nature. We have provided this option for convenience because it increases the autofix cases covered by the rule. If you set option to `true` the onus is entirely on you and your team to ensure that each fix is correct and safe and that it does not break the build.

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/eslint-plugin",
"version": "6.7.3",
"version": "6.7.5",
"description": "TypeScript plugin for ESLint",
"files": [
"dist",
@ -57,10 +57,10 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.5.1",
"@typescript-eslint/scope-manager": "6.7.3",
"@typescript-eslint/type-utils": "6.7.3",
"@typescript-eslint/utils": "6.7.3",
"@typescript-eslint/visitor-keys": "6.7.3",
"@typescript-eslint/scope-manager": "6.7.5",
"@typescript-eslint/type-utils": "6.7.5",
"@typescript-eslint/utils": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.5",
"debug": "^4.3.4",
"graphemer": "^1.4.0",
"ignore": "^5.2.4",
@ -73,8 +73,8 @@
"@types/marked": "*",
"@types/natural-compare": "*",
"@types/prettier": "*",
"@typescript-eslint/rule-schema-to-typescript-types": "6.7.3",
"@typescript-eslint/rule-tester": "6.7.3",
"@typescript-eslint/rule-schema-to-typescript-types": "6.7.5",
"@typescript-eslint/rule-tester": "6.7.5",
"ajv": "^6.12.6",
"chalk": "^5.3.0",
"cross-fetch": "*",
@ -103,5 +103,5 @@
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/parser",
"version": "6.7.3",
"version": "6.7.5",
"description": "An ESLint custom parser which leverages TypeScript ESTree",
"files": [
"dist",
@ -51,10 +51,10 @@
"eslint": "^7.0.0 || ^8.0.0"
},
"dependencies": {
"@typescript-eslint/scope-manager": "6.7.3",
"@typescript-eslint/types": "6.7.3",
"@typescript-eslint/typescript-estree": "6.7.3",
"@typescript-eslint/visitor-keys": "6.7.3",
"@typescript-eslint/scope-manager": "6.7.5",
"@typescript-eslint/types": "6.7.5",
"@typescript-eslint/typescript-estree": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.5",
"debug": "^4.3.4"
},
"devDependencies": {
@ -82,5 +82,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/scope-manager",
"version": "6.7.3",
"version": "6.7.5",
"description": "TypeScript scope analyser for ESLint",
"files": [
"dist",
@ -44,12 +44,12 @@
"typecheck": "nx typecheck"
},
"dependencies": {
"@typescript-eslint/types": "6.7.3",
"@typescript-eslint/visitor-keys": "6.7.3"
"@typescript-eslint/types": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.5"
},
"devDependencies": {
"@types/glob": "*",
"@typescript-eslint/typescript-estree": "6.7.3",
"@typescript-eslint/typescript-estree": "6.7.5",
"glob": "*",
"jest-specific-snapshot": "*",
"make-dir": "*",
@ -67,5 +67,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/type-utils",
"version": "6.7.3",
"version": "6.7.5",
"description": "Type utilities for working with TypeScript + ESLint together",
"files": [
"dist",
@ -45,13 +45,13 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@typescript-eslint/typescript-estree": "6.7.3",
"@typescript-eslint/utils": "6.7.3",
"@typescript-eslint/typescript-estree": "6.7.5",
"@typescript-eslint/utils": "6.7.5",
"debug": "^4.3.4",
"ts-api-utils": "^1.0.1"
},
"devDependencies": {
"@typescript-eslint/parser": "6.7.3",
"@typescript-eslint/parser": "6.7.5",
"ajv": "^6.10.0",
"downlevel-dts": "*",
"jest": "29.7.0",
@ -78,5 +78,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/types",
"version": "6.7.3",
"version": "6.7.5",
"description": "Types for the TypeScript-ESTree AST spec",
"files": [
"dist",
@ -90,5 +90,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/typescript-estree",
"version": "6.7.3",
"version": "6.7.5",
"description": "A parser that converts TypeScript source code into an ESTree compatible form",
"files": [
"dist",
@ -52,8 +52,8 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@typescript-eslint/types": "6.7.3",
"@typescript-eslint/visitor-keys": "6.7.3",
"@typescript-eslint/types": "6.7.5",
"@typescript-eslint/visitor-keys": "6.7.5",
"debug": "^4.3.4",
"globby": "^11.1.0",
"is-glob": "^4.0.3",
@ -88,5 +88,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/utils",
"version": "6.7.3",
"version": "6.7.5",
"description": "Utilities for working with TypeScript + ESLint together",
"files": [
"dist",
@ -68,16 +68,16 @@
"@eslint-community/eslint-utils": "^4.4.0",
"@types/json-schema": "^7.0.12",
"@types/semver": "^7.5.0",
"@typescript-eslint/scope-manager": "6.7.3",
"@typescript-eslint/types": "6.7.3",
"@typescript-eslint/typescript-estree": "6.7.3",
"@typescript-eslint/scope-manager": "6.7.5",
"@typescript-eslint/types": "6.7.5",
"@typescript-eslint/typescript-estree": "6.7.5",
"semver": "^7.5.4"
},
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0"
},
"devDependencies": {
"@typescript-eslint/parser": "6.7.3",
"@typescript-eslint/parser": "6.7.5",
"downlevel-dts": "*",
"jest": "29.7.0",
"prettier": "^2.8.4",
@ -95,5 +95,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}

View file

@ -1,6 +1,6 @@
{
"name": "@typescript-eslint/visitor-keys",
"version": "6.7.3",
"version": "6.7.5",
"description": "Visitor keys used to help traverse the TypeScript-ESTree AST",
"files": [
"dist",
@ -45,7 +45,7 @@
"typecheck": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@typescript-eslint/types": "6.7.3",
"@typescript-eslint/types": "6.7.5",
"eslint-visitor-keys": "^3.4.1"
},
"devDependencies": {
@ -67,5 +67,5 @@
]
}
},
"gitHead": "91a3e0c85a8fb2001ad808362b437df0b90cce04"
"gitHead": "36aecb6a836eb01307c35b42ca60f5a78496c339"
}