@typescript-eslint/eslint-plugin
Advanced tools
Comparing version 1.10.3-alpha.7 to 1.10.3-alpha.8
@@ -27,2 +27,5 @@ "use strict"; | ||
properties: { | ||
allowAny: { | ||
type: 'boolean', | ||
}, | ||
allowedPromiseNames: { | ||
@@ -53,2 +56,3 @@ type: 'array', | ||
{ | ||
allowAny: false, | ||
allowedPromiseNames: [], | ||
@@ -61,3 +65,3 @@ checkArrowFunctions: true, | ||
], | ||
create(context, [{ allowedPromiseNames, checkArrowFunctions, checkFunctionDeclarations, checkFunctionExpressions, checkMethodDeclarations, },]) { | ||
create(context, [{ allowAny, allowedPromiseNames, checkArrowFunctions, checkFunctionDeclarations, checkFunctionExpressions, checkMethodDeclarations, },]) { | ||
const allAllowedPromiseNames = new Set([ | ||
@@ -78,3 +82,3 @@ 'Promise', | ||
const returnType = checker.getReturnTypeOfSignature(signatures[0]); | ||
if (!util.containsTypeByName(returnType, allAllowedPromiseNames)) { | ||
if (!util.containsTypeByName(returnType, allowAny, allAllowedPromiseNames)) { | ||
return; | ||
@@ -81,0 +85,0 @@ } |
@@ -13,5 +13,5 @@ "use strict"; | ||
*/ | ||
function containsTypeByName(type, allowedNames) { | ||
function containsTypeByName(type, allowAny, allowedNames) { | ||
if (isTypeFlagSet(type, typescript_1.default.TypeFlags.Any | typescript_1.default.TypeFlags.Unknown)) { | ||
return true; | ||
return !allowAny; | ||
} | ||
@@ -26,7 +26,7 @@ if (tsutils_1.isTypeReference(type)) { | ||
if (tsutils_1.isUnionOrIntersectionType(type)) { | ||
return type.types.some(t => containsTypeByName(t, allowedNames)); | ||
return type.types.some(t => containsTypeByName(t, allowAny, allowedNames)); | ||
} | ||
const bases = type.getBaseTypes(); | ||
return (typeof bases !== 'undefined' && | ||
bases.some(t => containsTypeByName(t, allowedNames))); | ||
bases.some(t => containsTypeByName(t, allowAny, allowedNames))); | ||
} | ||
@@ -33,0 +33,0 @@ exports.containsTypeByName = containsTypeByName; |
@@ -39,2 +39,3 @@ # Functions that return promises must be async (promise-function-async) | ||
- `allowAny` to indicate that `any` or `unknown` shouldn't be considered Promises (`false` by default). | ||
- `allowedPromiseNames` to indicate any extra names of classes or interfaces to be considered Promises when returned. | ||
@@ -54,2 +55,3 @@ | ||
{ | ||
"allowAny": true, | ||
"allowedPromiseNames": ["Thenable"], | ||
@@ -56,0 +58,0 @@ "checkArrowFunctions": true, |
{ | ||
"name": "@typescript-eslint/eslint-plugin", | ||
"version": "1.10.3-alpha.7+48548ea", | ||
"version": "1.10.3-alpha.8+9a387b0", | ||
"description": "TypeScript plugin for ESLint", | ||
@@ -44,3 +44,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@typescript-eslint/experimental-utils": "1.10.3-alpha.7+48548ea", | ||
"@typescript-eslint/experimental-utils": "1.10.3-alpha.8+9a387b0", | ||
"eslint-utils": "^1.3.1", | ||
@@ -60,3 +60,3 @@ "functional-red-black-tree": "^1.0.1", | ||
}, | ||
"gitHead": "48548eaa9212fd8139a60e42040434fbb32edca9" | ||
"gitHead": "9a387b03e5f8b7d2ca9c0e373387c17a1a20b4a0" | ||
} |
Sorry, the diff of this file is not supported yet
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
799215
8911