global-require should allow `require` statements as properties in object literals
See original GitHub issueeslint version:
^1.4.1
rule config:
"global-require": 1
Assuming I have a folder structure like this
/ app
/ validators
- validate-string.js
- validate-number.js
- index.js
And /app/validators/index.js
// index.js
module.exports = {
string: require('./validate-string'), // this violates global-require rule
number: require('./validate-number')
};
It does not make sense to me that this is a violation.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Working with objects - JavaScript - MDN Web Docs - Mozilla
The same way, JavaScript objects can have properties, ... object literal in parentheses if the object appears where a statement is expected, ...
Read more >Self-references in object literals / initializers - Stack Overflow
The return statement both creates the replacement property foo.c and returns its value. It would be possible to use get c() { return...
Read more >Rules - ESLint - Pluggable JavaScript Linter
The "extends": "eslint:recommended" property in a configuration file enables this rule ... Require grouped accessor pairs in object literals and classes.
Read more >List of available rules - ESLint - Pluggable JavaScript linter
disallow calling global object properties as functions. no-prototype-builtins ... require return statements to either always or never specify values.
Read more >tslint-eslint-rules - npm Package Health Analysis | Snyk
You can connect your project's repository to Snyk to stay up to date on security ... enforce spacing between keys and values in...
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
@jamestalmage you can always create your own rule to do this. The fact is, once you add in enough exceptions then the rule is no longer doing what it was intended to do, and that’s when people get confused. That’s why we allow custom rules - you don’t have to convince us, just write a rule that does exactly what you want.
Agree. This rule was created to make sure that all
require
statements are clearly marked at the top of the file. If you don’t follow that pattern - just turn off this rule.