Skip to content

Commit 84023e4

Browse files
committed
feat: added in no-restricted-syntax to ensure that top level function declarations are just function declarations rather than arrow function or variable assignments
1 parent a1a007a commit 84023e4

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/configs/eslint.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,21 @@ const config = [
149149
message: 'Use `globalThis` instead',
150150
},
151151
],
152+
'no-restricted-syntax': [
153+
'error',
154+
{
155+
selector:
156+
'Program > VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="ArrowFunctionExpression"]',
157+
message:
158+
'Top-level functions must be declarations: `function foo() {}`',
159+
},
160+
{
161+
selector:
162+
'Program > VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="FunctionExpression"]',
163+
message:
164+
'Top-level functions must be declarations: `function foo() {}`',
165+
},
166+
],
152167
'prefer-rest-params': 0,
153168
'require-yield': 0,
154169
eqeqeq: ['error', 'smart'],

0 commit comments

Comments
 (0)