简体   繁体   English

如何将 Prettier 集成到可共享的 ESLint 配置中?

[英]How to integrate Prettier into a shareable ESLint configuration?

One can create shareable ESLint configs to use in multiple projects.可以创建可共享的 ESLint 配置以在多个项目中使用。 It is also possible to integrate Prettier settings into an ESLint config like so:也可以将 Prettier 设置集成到 ESLint 配置中,如下所示:

[...]

rules: {
'prettier/prettier': [
  'error',
  {
    printWidth: 120,
    tabWidth: 2,
    useTabs: false,
    semi: false,
    singleQuote: true,
  },
],

[...]

However, when I do this with my shared config I can't get it to work.但是,当我使用我的共享配置执行此操作时,我无法让它工作。 When I run eslint --fix it just does nothing at all.当我运行eslint --fix时,它什么都不做。 How can I integrate ESLint and Prettier somewhere and then just extend my local ESLint with that configuration so I don't have to configure the exact same thing in 20 different repositories?我如何在某个地方集成 ESLint 和 Prettier,然后只使用该配置扩展我的本地 ESLint,这样我就不必在 20 个不同的存储库中配置完全相同的东西?

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

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