{"action":"created","issue":{"url":"https://api.github.com/repos/eslint/eslint/issues/2487","labels_url":"https://api.github.com/repos/eslint/eslint/issues/2487/labels{/name}","comments_url":"https://api.github.com/repos/eslint/eslint/issues/2487/comments","events_url":"https://api.github.com/repos/eslint/eslint/issues/2487/events","html_url":"https://github.com/eslint/eslint/issues/2487","id":75007433,"number":2487,"title":"Error: Shareable config call stack overflow in sub-directories ","user":{"login":"gyandeeps","id":5554486,"avatar_url":"https://avatars.githubusercontent.com/u/5554486?v=3","gravatar_id":"","url":"https://api.github.com/users/gyandeeps","html_url":"https://github.com/gyandeeps","followers_url":"https://api.github.com/users/gyandeeps/followers","following_url":"https://api.github.com/users/gyandeeps/following{/other_user}","gists_url":"https://api.github.com/users/gyandeeps/gists{/gist_id}","starred_url":"https://api.github.com/users/gyandeeps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gyandeeps/subscriptions","organizations_url":"https://api.github.com/users/gyandeeps/orgs","repos_url":"https://api.github.com/users/gyandeeps/repos","events_url":"https://api.github.com/users/gyandeeps/events{/privacy}","received_events_url":"https://api.github.com/users/gyandeeps/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/eslint/eslint/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/eslint/eslint/labels/core","name":"core","color":"c7def8"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-05-10T21:34:58Z","updated_at":"2015-05-13T22:13:15Z","closed_at":"2015-05-13T16:30:51Z","body":"I just created my shareable config and tried to use it on my personal project  and it gave a stack overflow error.\r\n\r\nNode js: 0.12.2\r\neslint: 0.21.0\r\nparser: default\r\n\r\nHere is the my project tree\r\n\r\n```\r\nBase folder -> package.json\r\n               .eslintrc\r\n               lib -> app.js\r\n                      launcher.js\r\n                      util -> file.js\r\n                              svn.js \r\n```\r\n\r\n`.eslintrc` file:\r\n\r\n```js\r\n{\r\n    \"env\": {\r\n        \"node\": true,\r\n        \"browser\": true,\r\n        \"mocha\": true\r\n    },\r\n    \"extends\": \"eslint-config-gyandeep\",\r\n    \"rules\": {\r\n        \"strict\":2\r\n    },\r\n    \"globals\": {\r\n        \"$\": true\r\n    }\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```sh\r\nc:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:115\r\n                throw e;\r\n                      ^\r\nRangeError: Maximum call stack size exceeded\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\n\r\n<repeat this statement many times > \r\n\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: eslint-config-gyandeep\r\nReferenced from: c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\.eslintrc\r\n    at inspect (util.js:127:3)\r\n    at Console.exports.format (util.js:27:20)\r\n    at Console.warn (console.js:63:34)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:89:25)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:109:44)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:109:44)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:109:44)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:109:44)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:109:44)\r\n    at loadConfig (c:\\Users\\GS025879\\Documents\\webstrom\\launcher\\node_modules\\eslint\\lib\\config.js:109:44)\r\n```\r\n\r\n**Imp:** This error only happens under sub-directory scenario. If run eslint on a directory which doesnt have sub-directories then it runs fine.\r\n\r\nHere is my take on why this is happening:\r\nBy default `node` `require` caches all the modules. So what happens is that during the first run ie for files inside `lib` folder it scans the config files and its extensions. As me do the merge on the `config` object, it basically overwrites the require's chache for the extend module as objects are passed by reference. \r\nSo when `eslint` process the internal directory (in here the `util` directory) it again runs the config which when uses the extend require actually has an extend in its object which points to itself.\r\n\r\nThis is where we get the extended configuration module and save it to the config object:\r\nhttps://github.com/eslint/eslint/blob/master/lib/config.js#L86\r\n\r\nThis is where we merge the config and save it back to the config object: https://github.com/eslint/eslint/blob/master/lib/config.js#L105"},"comment":{"url":"https://api.github.com/repos/eslint/eslint/issues/comments/101833773","html_url":"https://github.com/eslint/eslint/issues/2487#issuecomment-101833773","issue_url":"https://api.github.com/repos/eslint/eslint/issues/2487","id":101833773,"user":{"login":"jonathanKingston","id":338988,"avatar_url":"https://avatars.githubusercontent.com/u/338988?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanKingston","html_url":"https://github.com/jonathanKingston","followers_url":"https://api.github.com/users/jonathanKingston/followers","following_url":"https://api.github.com/users/jonathanKingston/following{/other_user}","gists_url":"https://api.github.com/users/jonathanKingston/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanKingston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanKingston/subscriptions","organizations_url":"https://api.github.com/users/jonathanKingston/orgs","repos_url":"https://api.github.com/users/jonathanKingston/repos","events_url":"https://api.github.com/users/jonathanKingston/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanKingston/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T22:13:15Z","updated_at":"2015-05-13T22:13:15Z","body":":+1:  thank you so much @gyandeeps "}}