js-slang
Version:
Javascript-based implementations of Source, written in Typescript
26 lines • 1.04 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.NoFunctionDeclarationWithoutIdentifierError = void 0;
const errors_1 = require("../../errors");
class NoFunctionDeclarationWithoutIdentifierError extends errors_1.RuleError {
explain() {
return `The 'function' keyword needs to be followed by a name.`;
}
elaborate() {
return 'Function declarations without a name are similar to function expressions, which are banned.';
}
}
exports.NoFunctionDeclarationWithoutIdentifierError = NoFunctionDeclarationWithoutIdentifierError;
const noFunctionDeclarationWithoutIdentifier = {
name: 'no-function-declaration-without-identifier',
checkers: {
FunctionDeclaration(node) {
if (node.id === null) {
return [new NoFunctionDeclarationWithoutIdentifierError(node)];
}
return [];
}
}
};
exports.default = noFunctionDeclarationWithoutIdentifier;
//# sourceMappingURL=noFunctionDeclarationWithoutIdentifier.js.map
;