Registry / testing / eslint-plugin-no-function-declare-after-return

eslint-plugin-no-function-declare-after-return

JSON →
library1.1.0jsnpmunverified

An ESLint plugin that enforces a code style rule disallowing function declarations after a return statement within the same scope. Version 1.1.0 is the latest stable release, with auto-fix support added in this version. The plugin is mature, actively maintained, and has no known security issues. It differs from ESLint's built-in no-unreachable rule by focusing specifically on hoisted function declarations after return, which are syntactically valid but harm readability. The plugin is lightweight with zero runtime dependencies besides ESLint.

npm install eslint-plugin-no-function-declare-after-return
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NO-F
E
eslint-plugin-no-function-declare-after-return
testingjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
// In .eslintrc: { "plugins": ["no-function-declare-after-return"], "rules": { "no-function-declare-after-return/no-function-declare-after-return": "error" } }
// Incorrect: { "rules": { "no-function-declare-after-return": "error" } } (omits plugin name prefix)
The rule is namespaced under the plugin name, unlike built-in rules. Always use 'no-function-declare-after-return/no-function-declare-after-return'.
flat config (ESLint 9+)
import noFunctionDeclareAfterReturn from 'eslint-plugin-no-function-declare-after-return'; export default [noFunctionDeclareAfterReturn.configs.recommended];
// Incorrect: using .eslintrc style with flat config or importing incorrectly
For ESLint 9+ flat config, import the plugin and spread its config. The recommended config includes the rule.
CommonJS require
const plugin = require('eslint-plugin-no-function-declare-after-return'); // In .eslintrc: plugins: ["no-function-declare-after-return"], rules: { ... }
// Incorrect: const plugin = require('eslint-plugin-no-function-declare-after-return/no-function-declare-after-return');
Require the plugin package, not the rule file. The plugin object is exported as a default.

Configures ESLint to disallow function declarations after return, with a failing example.

// .eslintrc.js module.exports = { plugins: ['no-function-declare-after-return'], rules: { 'no-function-declare-after-return/no-function-declare-after-return': 'error', }, }; // Example file that will fail: function foo() { return 1; function bar() { return 2; } }
Debug
Known issues
gotchaThis rule enforces a stylistic preference; it does not prevent runtime errors because function declarations are hoisted.
fix
Use ESLint's 'no-unreachable' rule to catch truly unreachable code.
affects: >=0.0.0
breakingVersion 1.0.0 was the initial release; rules and plugin name may mismatch in early versions.
fix
Upgrade to >=1.0.0 and use the rule as described in the README.
affects: <1.0.0
deprecatedThe package name 'no-function-declare-after-return' used in install instructions may be mistaken for the plugin name; the plugin is imported as 'eslint-plugin-no-function-declare-after-return'.
fix
Always use 'no-function-declare-after-return' as the plugin name in .eslintrc, but the npm package name is the same.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'no-function-declare-after-return': Unable to load rule 'no-function-declare-after-return/no-function-declare-after-return'
The rule name is incorrectly spelled or the plugin isn't installed.
fix
npm install --save-dev eslint-plugin-no-function-declare-after-return and ensure the rule name is 'no-function-declare-after-return/no-function-declare-after-return'.
ESLint: Configuration for rule 'no-function-declare-after-return' is unknown
Used rule name without plugin prefix in flat config or missing plugin declaration.
fix
Add 'no-function-declare-after-return' to the plugins array and prefix the rule: 'no-function-declare-after-return/no-function-declare-after-return'.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-no-function-declare-after-return — npm install eslint-plugin-no-function-declare-after-return · libregistry