问题描述
在 VS Code 中使用 ESLint/Prettier 和 AirBNB JS 风格指南。试图覆盖样式指南中的规则,以便它们发出警告而不是不编译,并且它们不会覆盖。我阅读了有关 hierarchy 的 ESLint 内容,并根据我的文件结构(同一目录中的 package.json 和 .eslintrc.json),应该覆盖 eslint 文件。可能是问题的一件事是我没有 .prettierrc 文件?我需要一个吗?
我尝试过的一些事情:
- 将 "root":"true" 添加到 .eslintrc.json
- 将 .eslintrc.json 移动到我的文件所在的确切目录中(就在 components 文件夹内)
- 将 .eslintrc.json 的“扩展”位移动到文件末尾而不是开头
- 使用“覆盖”而不是“规则”
- 在覆盖中使用“警告”和“关闭”以及 1 和 0
import os
import glob
import cmd
def _append_slash_if_dir(p):
if p and os.path.isdir(p) and p[-1] != os.sep:
return p + os.sep
else:
return p
class MyShell(cmd.Cmd):
prompt = "> "
def do_quit(self,line):
return True
def do_load(self,line):
print("load " + line)
def complete_load(self,text,line,begidx,endidx):
before_arg = line.rfind(" ",begidx)
if before_arg == -1:
return # arg not found
fixed = line[before_arg+1:begidx] # fixed portion of the arg
arg = line[before_arg+1:endidx]
pattern = arg + '*'
completions = []
for path in glob.glob(pattern):
path = _append_slash_if_dir(path)
completions.append(path.replace(fixed,"",1))
return completions
MyShell().cmdloop()
这是我现在在 package.json 中的 devDependencies:
{
"env": {
"browser": true,"es2021": true
},"root": "true","extends": ["plugin:react/recommended","prettier","airbnb"],"parserOptions": {
"ecmaFeatures": {
"jsx": true
},"ecmaVersion": 12,"sourceType": "module"
},"plugins": ["react"],"rules": {
"react/prop-types": "off","react/self-closing-comp": "warn","no-param-reassign": 0,"no-unused-vars": "warn"
}
}
有什么想法吗?在论坛上尝试了几乎所有似乎相关的东西,但没有运气。我这里的配置有问题吗? no-params-reassign 确实给我带来了最大的麻烦。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)