diff --git a/package-lock.json b/package-lock.json index 26d4f59..0d4c73f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@matrixai/lint", - "version": "0.4.8", + "version": "0.4.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@matrixai/lint", - "version": "0.4.8", + "version": "0.4.9", "license": "Apache-2.0", "dependencies": { "@eslint/compat": "^1.2.5", diff --git a/package.json b/package.json index 5f59c23..05e2609 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@matrixai/lint", - "version": "0.4.8", + "version": "0.4.9", "author": "Roger Qiu", "description": "Org wide custom eslint rules", "license": "Apache-2.0", diff --git a/src/configs/eslint.ts b/src/configs/eslint.ts index 50a90f5..ee8d38c 100644 --- a/src/configs/eslint.ts +++ b/src/configs/eslint.ts @@ -149,6 +149,21 @@ const config = [ message: 'Use `globalThis` instead', }, ], + 'no-restricted-syntax': [ + 'error', + { + selector: + 'Program > VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="ArrowFunctionExpression"]', + message: + 'Top-level functions must be declarations: `function foo() {}`', + }, + { + selector: + 'Program > VariableDeclaration[kind="const"] > VariableDeclarator[id.type="Identifier"][init.type="FunctionExpression"]', + message: + 'Top-level functions must be declarations: `function foo() {}`', + }, + ], 'prefer-rest-params': 0, 'require-yield': 0, eqeqeq: ['error', 'smart'],