mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-11 08:27:27 +00:00
This is a stop-gap for v19. See #16767 for groundwork for v20. Enable one rule, to verify `unitTestEndpoints` is not used except in unit tests. Follows: #16605 See-also: #16767 Test-bot: skip
49 lines
No EOL
1.2 KiB
JavaScript
49 lines
No EOL
1.2 KiB
JavaScript
/*
|
|
* Keyman is copyright (C) SIL Global. MIT License.
|
|
*
|
|
* Created by mcdurdin on 2026-10-09
|
|
*
|
|
* Enforce restrictions on use of unitTestEndpoints -- only for use in
|
|
* unit tests
|
|
*/
|
|
|
|
// import { RuleDefinition } from "@eslint/core";
|
|
|
|
module.exports = /*: RuleDefinition*/ {
|
|
meta: {
|
|
type: "problem",
|
|
docs: {
|
|
description: "Do not use unitTestEndpoints except in unit tests",
|
|
},
|
|
schema: [], // no options
|
|
},
|
|
create: function (context) {
|
|
return {
|
|
// callback functions
|
|
"Identifier[name=/^unitTestEndpoints$/]"(node) {
|
|
if(node.parent?.type == 'PropertyDefinition' || node.parent?.type == 'VariableDeclarator') {
|
|
// These are valid places to have endpoints
|
|
} else if(node.parent?.type == 'MemberExpression') {
|
|
context.report({
|
|
node,
|
|
message: 'Use of `unitTestEndpoints` outside unit tests.',
|
|
});
|
|
|
|
} else {
|
|
context.report({
|
|
node,
|
|
message: 'Unexpected `unitTestEndpoints` -- context is unclear',
|
|
});
|
|
}
|
|
}
|
|
};
|
|
},
|
|
};
|
|
|
|
// const plugin = {
|
|
// rules: {
|
|
// "prohibit-unitTestEndpoints": rule
|
|
// }
|
|
// };
|
|
|
|
// module.exports = plugin;
|