This repository has been archived on 2024-09-09 . You can view files and clone it, but cannot push or open issues or pull requests.
37f98d9b5e
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
"use strict";
|
|||
/*---------------------------------------------------------------------------------------------
|
|||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|||
*--------------------------------------------------------------------------------------------*/
|
|||
const experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|||
module.exports = new class ApiProviderNaming {
|
|||
constructor() {
|
|||
this.meta = {
|
|||
messages: {
|
|||
noToken: 'Function lacks a cancellation token, preferable as last argument',
|
|||
}
|
|||
};
|
|||
}
|
|||
create(context) {
|
|||
return {
|
|||
['TSInterfaceDeclaration[id.name=/.+Provider/] TSMethodSignature[key.name=/^(provide|resolve).+/]']: (node) => {
|
|||
let found = false;
|
|||
for (let param of node.params) {
|
|||
if (param.type === experimental_utils_1.AST_NODE_TYPES.Identifier) {
|
|||
found = found || param.name === 'token';
|
|||
}
|
|||
}
|
|||
if (!found) {
|
|||
context.report({
|
|||
node,
|
|||
messageId: 'noToken'
|
|||
});
|
|||
}
|
|||
}
|
|||
};
|
|||
}
|
|||
};
|