admin管理员组文章数量:1026062
I have two projects that share mon files from the mon folder.
Now, I am trying to setup eslint so I can lint both the project folder and the mon folder.
Folder structure is like this:
MyProjectFolder
.eslintrc.js
-
src
CommonFolder
-
src
I am trying to add an "override: [ files: ["src/**/*.js", "../CommonFolder/src/**/*.js"] }]
" to eslint with relative path, but eslint is telling me that it is an invalid override path.
So, does anyone know how I can add CommonFolder into .eslintrc.js file?
I have two projects that share mon files from the mon folder.
Now, I am trying to setup eslint so I can lint both the project folder and the mon folder.
Folder structure is like this:
MyProjectFolder
.eslintrc.js
-
src
CommonFolder
-
src
I am trying to add an "override: [ files: ["src/**/*.js", "../CommonFolder/src/**/*.js"] }]
" to eslint with relative path, but eslint is telling me that it is an invalid override path.
So, does anyone know how I can add CommonFolder into .eslintrc.js file?
Share Improve this question asked Nov 29, 2022 at 0:35 perun_the_mightyperun_the_mighty 1211 silver badge5 bronze badges3 Answers
Reset to default 1If using VS-Code, you can add both directories to the ESLint working directory settings in the VS-Code Workspace Extensions settings.
cmd + shift + p / ctrl + shift + p
type workspace setting!
Select ESLint from the Extensions menu.
Look for the working directory configuration and open it in JSON format.
Include a directory path.
{ "eslint.workingDirectories": [ "path1/", "path2/" ] }
you cant visit this link https://medium./devityoself/monorepo-eslint-vscode-6f5982c8404d
I hope this is helpful.
The .eslintrc*
file should work as expected on its own, but if you're using VS Code, it may not behave. The eslint.workingDirectories
setting is what you probably want.
Just adding the folder path may not work. Consider using mode
:
"eslint.workingDirectories": [{ "mode": "auto" }]
According to the docs: https://marketplace.visualstudio./items?itemName=dbaeumer.vscode-eslint#settings-options
[{ "mode": "auto" }]
(@since 2.0.0): instructs ESLint to infer a working directory based on the location of package.json, .eslintignore and .eslintrc* files. This might work in many cases but can lead to unexpected results as well.
I solved this by moving the .eslinrc.js config file to the parent folder which consists of both CommonFolder and ProjectFolder, and gave it a property of root: true
.
If builder doesn't find a config file in it's root folder, it will begin searching parent folders until it finds a config file with root option set to true.
This way, both my projects can use only one eslint config file, even if they use different build files.
I have two projects that share mon files from the mon folder.
Now, I am trying to setup eslint so I can lint both the project folder and the mon folder.
Folder structure is like this:
MyProjectFolder
.eslintrc.js
-
src
CommonFolder
-
src
I am trying to add an "override: [ files: ["src/**/*.js", "../CommonFolder/src/**/*.js"] }]
" to eslint with relative path, but eslint is telling me that it is an invalid override path.
So, does anyone know how I can add CommonFolder into .eslintrc.js file?
I have two projects that share mon files from the mon folder.
Now, I am trying to setup eslint so I can lint both the project folder and the mon folder.
Folder structure is like this:
MyProjectFolder
.eslintrc.js
-
src
CommonFolder
-
src
I am trying to add an "override: [ files: ["src/**/*.js", "../CommonFolder/src/**/*.js"] }]
" to eslint with relative path, but eslint is telling me that it is an invalid override path.
So, does anyone know how I can add CommonFolder into .eslintrc.js file?
Share Improve this question asked Nov 29, 2022 at 0:35 perun_the_mightyperun_the_mighty 1211 silver badge5 bronze badges3 Answers
Reset to default 1If using VS-Code, you can add both directories to the ESLint working directory settings in the VS-Code Workspace Extensions settings.
cmd + shift + p / ctrl + shift + p
type workspace setting!
Select ESLint from the Extensions menu.
Look for the working directory configuration and open it in JSON format.
Include a directory path.
{ "eslint.workingDirectories": [ "path1/", "path2/" ] }
you cant visit this link https://medium./devityoself/monorepo-eslint-vscode-6f5982c8404d
I hope this is helpful.
The .eslintrc*
file should work as expected on its own, but if you're using VS Code, it may not behave. The eslint.workingDirectories
setting is what you probably want.
Just adding the folder path may not work. Consider using mode
:
"eslint.workingDirectories": [{ "mode": "auto" }]
According to the docs: https://marketplace.visualstudio./items?itemName=dbaeumer.vscode-eslint#settings-options
[{ "mode": "auto" }]
(@since 2.0.0): instructs ESLint to infer a working directory based on the location of package.json, .eslintignore and .eslintrc* files. This might work in many cases but can lead to unexpected results as well.
I solved this by moving the .eslinrc.js config file to the parent folder which consists of both CommonFolder and ProjectFolder, and gave it a property of root: true
.
If builder doesn't find a config file in it's root folder, it will begin searching parent folders until it finds a config file with root option set to true.
This way, both my projects can use only one eslint config file, even if they use different build files.
版权声明:本文标题:javascript - How to include a folder for linting that is not in root folder of eslintrc file? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745634030a2160333.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论