printer-notifications/node_modules/eslint-plugin-svelte/lib/rules/no-inner-declarations.js
2023-11-13 16:10:04 -05:00

36 lines
1.4 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("../utils");
const eslint_core_1 = require("../utils/eslint-core");
const coreRule = (0, eslint_core_1.getCoreRule)('no-inner-declarations');
exports.default = (0, utils_1.createRule)('no-inner-declarations', {
meta: {
docs: {
description: 'disallow variable or `function` declarations in nested blocks',
category: 'Extension Rules',
recommended: true,
extensionRule: 'no-inner-declarations'
},
fixable: coreRule.meta.fixable,
schema: coreRule.meta.schema,
messages: coreRule.meta.messages,
type: coreRule.meta.type
},
create(context) {
return (0, eslint_core_1.defineWrapperListener)(coreRule, context, {
createListenerProxy(coreListener) {
return (0, eslint_core_1.buildProxyListener)(coreListener, (node) => {
return (0, eslint_core_1.getProxyNode)(node, {
get parent() {
if (node.parent?.type === 'SvelteScriptElement') {
return node.parent.parent;
}
return node.parent;
}
});
});
}
});
}
});