Add "variables" option to `no-use-before-define` rule
See original GitHub issue- ESLint Version: 3.5.0
I want no-use-before-define
to check for classes or functions that are used before they are defined. But I do not want to check for variables that are used before they are defined.
Right now there exist two options, which modify whether functions and classes are checked. For example, I can disable these two checks:
"no-use-before-define": [2, { "functions": false, "classes": false }]
But I cannot disable checking if variables are used before they are defined. I propose adding a “variables” option to address this:
"no-use-before-define": [2, { "variables": false }]
There is already a precedent for an option like this, in the “blocks” option to the padded-blocks
rule. It’s used like this:
"padded-blocks": [2, { "blocks": "never", "switches": "never", "classes": "never" }]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:11
- Comments:25 (18 by maintainers)
Top Results From Across the Web
no-use-before-define - ESLint - Pluggable JavaScript Linter
Rule Details. This rule will warn when it encounters a reference to an identifier that has not yet been declared. Examples of incorrect...
Read more >ESLint no-use-before-define - javascript - Stack Overflow
This flag determines whether or not the rule checks variable declarations in upper scopes. ... eslint-disable-next-line no-use-before-define.
Read more >typescript-eslint/no-use-before-define.md at main - GitHub
This rule extends the base eslint/no-use-before-define rule. It adds support for type , interface and enum declarations. Options. This rule adds the following ......
Read more >no-use-before-define - TypeScript ESLint
Disallow the use of variables before they are defined. Examples. This rule extends the base eslint/no-use-before-define rule. It adds support for ...
Read more >How to fix Definition for rule typescript-eslint no-use-before ...
For my .eslintrc.js file I have the following rules set up: ... '@typescript-eslint/no-use-before-declare': ['error', { functions: true, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In
standard
, we would like to prevent clearly incorrect use-before-define cases like the following:While still allowing cases that may be correct if the program executes in the right order:
There are just too many false positives for us when the latter example is disallowed.
PR up at https://github.com/eslint/eslint/issues/7948