简体   繁体   English

如何设置 eslint 忽略来自 scss 文件的 @import

[英]How to set eslint to ignore @import from scss files

In React project, I am running linter on js and scss files.在 React 项目中,我在 js 和 scss 文件上运行 linter。 In scss files, I have used @import statement but lint gives me following error在 scss 文件中,我使用了 @import 语句,但 lint 给了我以下错误

Parsing error: Unexpected keyword 'import'
@import './../shared/variables.scss';

I want linter to ignore these @import lines.我希望 linter 忽略这些 @import 行。

Do I need to add any rule in in eslintrc file?我需要在 eslintrc 文件中添加任何规则吗? Currently I am having following import rules in config:目前我在配置中有以下导入规则:

'import/no-unresolved': 0,
'import/no-dynamic-require': 0,
'import/no-extraneous-dependencies': 0

Is there any comment line for scss files to ignore specific line, like we have it for js files? scss 文件是否有任何注释行可以忽略特定行,就像我们为 js 文件设置的那样? eg // eslint-disable-next-line eg // eslint-disable-next-line

I have gone through a lot of online sources and added babel-eslint parser as well and also passed parserOptions too but nothing is working.我浏览了很多在线资源并添加了 babel-eslint 解析器,也通过了 parserOptions 但没有任何效果。

According to https://github.com/eslint/eslint/issues/12752#issuecomment-571561845 :根据https://github.com/eslint/eslint/issues/12752#issuecomment-571561845

Looks like the cause is eslint 'src/**' command.看起来原因是 eslint 'src/**' 命令。 You are linting other files than JavaScript.您正在检查 JavaScript 以外的其他文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM