Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested .eslintrc files in Visual Studio Code

I have a file structure which looks like this:

-- folder1
-- folder2
-- folder3
-- client
  |-- **
  |-- .eslintrc (1)
-- .eslintrc (2)

The ESLint plugin in vscode only detects the (2) .eslintrc. I have set the working directory to `"./client". Can anyone tell me what am I doing wrong? The (1) eslintrc file is supposed to add extra rules for client code.

like image 807
ankit_m Avatar asked Aug 14 '17 06:08

ankit_m


1 Answers

Add "root": true to your .eslintrc in your client directory.

From similar question and its answer: https://stackoverflow.com/a/37490224/1766230

You can add root: true to the top of any config to stop ESLint from searching parent folders for config files. So you should update your .eslintrc and add top level property "root": true.

From the docs: https://eslint.org/docs/user-guide/configuring#using-configuration-files-1

ESLint will automatically look for them in the directory of the file to be linted, and in successive parent directories all the way up to the root directory of the filesystem (unless root: true is specified). This option is useful when you want different configurations for different parts of a project or when you want others to be able to use ESLint directly without needing to remember to pass in the configuration file.

like image 51
Luke Avatar answered Nov 11 '22 09:11

Luke