Skip to content

Commit

Permalink
feat: disable global-require
Browse files Browse the repository at this point in the history
There is a lot of valid cases to use inline requires.
I'm disabling this because I'm constantly disabling it in projects.
  • Loading branch information
satazor committed Apr 22, 2018
1 parent c6baa4e commit 8bbea74
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 12 deletions.
3 changes: 0 additions & 3 deletions addons/es6-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ module.exports = {
// Rule to control usage of strict mode directives
// comment: code inside es6 modules is under strict mode by default, so it's not necessary
'strict': [2, 'never'],
// Enforce require() on top-level module scope
// comment: since we are using es6 modules, one will be using import instead of require but we still allow using inline require
'global-require': 0,
// Rule to warn the use of import when the es6-modules addon is activated.
// comment: This should be a warning instead of an error because there are still cases when we must use require.
'prefer-import/prefer-import-over-require': 1,
Expand Down
1 change: 0 additions & 1 deletion addons/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = {
}, {
'files': testFilePatterns,
'rules': {
'global-require': 0,
'prefer-import/prefer-import-over-require': 0,
},
}],
Expand Down
2 changes: 1 addition & 1 deletion rules/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
// Require return statements after callbacks
'callback-return': 0,
// Require require() calls to be placed at top-level module scope
'global-require': 1,
'global-require': 0,
// Enforces error handling in callbacks
'handle-callback-err': 1,
// Disallow require calls to be mixed with regular variable declarations
Expand Down
6 changes: 0 additions & 6 deletions test/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -874,12 +874,6 @@ Array [

exports[`should pass on fixtures/rules/node/node.js 1`] = `
Array [
Object {
"column": 21,
"line": 20,
"rule": "global-require",
"severity": 1,
},
Object {
"column": 5,
"line": 27,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/rules/node/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const fs = require('fs');

// `global-require` - require require() calls to be placed at top-level module scope
// ---------------------------------------------------------------------
// Disencouraged
// Not active
(function () {
const someDep = require('some-dep');
})();
Expand Down

0 comments on commit 8bbea74

Please sign in to comment.