@typescript-eslint/eslint-plugin
Advanced tools
Comparing version 8.16.1-alpha.1 to 8.16.1-alpha.2
@@ -120,16 +120,37 @@ "use strict"; | ||
} | ||
const fixableExpressions = node.expressions | ||
.filter(expression => isLiteral(expression) || | ||
isTemplateLiteral(expression) || | ||
(0, util_1.isUndefinedIdentifier)(expression) || | ||
isInfinityIdentifier(expression) || | ||
isNaNIdentifier(expression)) | ||
const fixableExpressionsReversed = node.expressions | ||
.map((expression, index) => ({ | ||
expression, | ||
nextQuasi: node.quasis[index + 1], | ||
prevQuasi: node.quasis[index], | ||
})) | ||
.filter(({ expression, nextQuasi }) => { | ||
if ((0, util_1.isUndefinedIdentifier)(expression) || | ||
isInfinityIdentifier(expression) || | ||
isNaNIdentifier(expression)) { | ||
return true; | ||
} | ||
if (isLiteral(expression)) { | ||
// allow trailing whitespace literal | ||
if (startsWithNewLine(nextQuasi.value.raw)) { | ||
return !(typeof expression.value === 'string' && | ||
isWhitespace(expression.value)); | ||
} | ||
return true; | ||
} | ||
if (isTemplateLiteral(expression)) { | ||
// allow trailing whitespace literal | ||
if (startsWithNewLine(nextQuasi.value.raw)) { | ||
return !(expression.quasis.length === 1 && | ||
isWhitespace(expression.quasis[0].value.raw)); | ||
} | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.reverse(); | ||
let nextCharacterIsOpeningCurlyBrace = false; | ||
for (const expression of fixableExpressions) { | ||
for (const { expression, nextQuasi, prevQuasi, } of fixableExpressionsReversed) { | ||
const fixers = []; | ||
const index = node.expressions.indexOf(expression); | ||
const prevQuasi = node.quasis[index]; | ||
const nextQuasi = node.quasis[index + 1]; | ||
if (nextQuasi.value.raw.length !== 0) { | ||
if (nextQuasi.value.raw !== '') { | ||
nextCharacterIsOpeningCurlyBrace = | ||
@@ -228,2 +249,16 @@ nextQuasi.value.raw.startsWith('{'); | ||
}); | ||
function isWhitespace(x) { | ||
// allow empty string too since we went to allow | ||
// ` ${''} | ||
// `; | ||
// | ||
// in addition to | ||
// `${' '} | ||
// `; | ||
// | ||
return /^\s*$/.test(x); | ||
} | ||
function startsWithNewLine(x) { | ||
return x.startsWith('\n') || x.startsWith('\r\n'); | ||
} | ||
//# sourceMappingURL=no-unnecessary-template-expression.js.map |
{ | ||
"name": "@typescript-eslint/eslint-plugin", | ||
"version": "8.16.1-alpha.1", | ||
"version": "8.16.1-alpha.2", | ||
"description": "TypeScript plugin for ESLint", | ||
@@ -64,6 +64,6 @@ "files": [ | ||
"@eslint-community/regexpp": "^4.10.0", | ||
"@typescript-eslint/scope-manager": "8.16.1-alpha.1", | ||
"@typescript-eslint/type-utils": "8.16.1-alpha.1", | ||
"@typescript-eslint/utils": "8.16.1-alpha.1", | ||
"@typescript-eslint/visitor-keys": "8.16.1-alpha.1", | ||
"@typescript-eslint/scope-manager": "8.16.1-alpha.2", | ||
"@typescript-eslint/type-utils": "8.16.1-alpha.2", | ||
"@typescript-eslint/utils": "8.16.1-alpha.2", | ||
"@typescript-eslint/visitor-keys": "8.16.1-alpha.2", | ||
"graphemer": "^1.4.0", | ||
@@ -79,4 +79,4 @@ "ignore": "^5.3.1", | ||
"@types/natural-compare": "*", | ||
"@typescript-eslint/rule-schema-to-typescript-types": "8.16.1-alpha.1", | ||
"@typescript-eslint/rule-tester": "8.16.1-alpha.1", | ||
"@typescript-eslint/rule-schema-to-typescript-types": "8.16.1-alpha.2", | ||
"@typescript-eslint/rule-tester": "8.16.1-alpha.2", | ||
"ajv": "^6.12.6", | ||
@@ -83,0 +83,0 @@ "cross-env": "^7.0.3", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2758702
31775
+ Added@typescript-eslint/scope-manager@8.16.1-alpha.2(transitive)
+ Added@typescript-eslint/type-utils@8.16.1-alpha.2(transitive)
+ Added@typescript-eslint/types@8.16.1-alpha.2(transitive)
+ Added@typescript-eslint/typescript-estree@8.16.1-alpha.2(transitive)
+ Added@typescript-eslint/utils@8.16.1-alpha.2(transitive)
+ Added@typescript-eslint/visitor-keys@8.16.1-alpha.2(transitive)
- Removed@typescript-eslint/scope-manager@8.16.1-alpha.1(transitive)
- Removed@typescript-eslint/type-utils@8.16.1-alpha.1(transitive)
- Removed@typescript-eslint/types@8.16.1-alpha.1(transitive)
- Removed@typescript-eslint/typescript-estree@8.16.1-alpha.1(transitive)
- Removed@typescript-eslint/utils@8.16.1-alpha.1(transitive)
- Removed@typescript-eslint/visitor-keys@8.16.1-alpha.1(transitive)