-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathno-inner-declarations.ts
41 lines (39 loc) · 1008 Bytes
/
no-inner-declarations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { createRule } from '../utils';
import {
buildProxyListener,
defineWrapperListener,
getCoreRule,
getProxyNode
} from '../utils/eslint-core';
const coreRule = getCoreRule('no-inner-declarations');
export default createRule('no-inner-declarations', {
meta: {
...coreRule.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 defineWrapperListener(coreRule, context, {
createListenerProxy(coreListener) {
return buildProxyListener(coreListener, (node) => {
return getProxyNode(node, {
get parent() {
if (node.parent?.type === 'SvelteScriptElement') {
return node.parent.parent;
}
return node.parent;
}
});
});
}
});
}
});