UNPKG

eslint-plugin-obsidian

Version:

ESLint rules for Obsidian

53 lines 1.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Clazz = void 0; const decorator_1 = require("./decorator"); const assertions_1 = require("../utils/assertions"); const ast_1 = require("../utils/ast"); const method_1 = require("./method"); class Clazz { constructor(node) { this.node = node; (0, assertions_1.assertDefined)(this.node); } get isGraph() { return this.isDecoratedWithIgnoreCase('Graph'); } isDecoratedWithIgnoreCase(decoratorName) { return this.decoratorNames.some(name => name.toLowerCase() === decoratorName.toLowerCase()); } requireMethodParameter(methodName, parameterName) { return this.requireMethod(methodName).requireParameter(parameterName); } requireMethod(name) { return this.findMethod(name); } findMethod(name) { return this.getMethods().find(method => method.name === name); } get decoratorNames() { return this.decorators.map((decorator) => { return decorator.expression.callee.name; }) || []; } get decorators() { var _a; return ((_a = this.node.decorators) !== null && _a !== void 0 ? _a : []).map((decorator) => { return new decorator_1.Decorator(decorator); }); } get body() { return this.node.body.body; } getDecoratedMethodsIgnoreCase(decoratorName) { return this.getMethods() .filter(method => method.isDecoratedWithIgnoreCase(decoratorName)); } getMethods() { return this.body .filter(ast_1.isMethodDefinition) .map((node) => new method_1.Method(node)); } } exports.Clazz = Clazz; //# sourceMappingURL=class.js.map