Intellij idea prettier与Intellij Idea和NPM的集成

Intellij idea prettier与Intellij Idea和NPM的集成,intellij-idea,eslint,tslint,prettier,stylelint,Intellij Idea,Eslint,Tslint,Prettier,Stylelint,我想要实现的目标 Intellij-通过红色下划线显示错误 通过NPM验证格式化 通过保存自动格式化 将printWidth覆盖为140 与stylelint、tslint和文件监视程序集成 我所做的 stylelint.config.js const regex = { pascal: "[A-Z][a-z]+[a-zA-Z]*", camel: "[a-z]+[a-zA-Z]*" }; const componentElementModifier = `\\.${regex.pas

我想要实现的目标

  • Intellij-通过红色下划线显示错误
  • 通过NPM验证格式化
  • 通过保存自动格式化
  • 将printWidth覆盖为140
  • 与stylelint、tslint和文件监视程序集成
  • 我所做的

    stylelint.config.js

    const regex = {
      pascal: "[A-Z][a-z]+[a-zA-Z]*",
      camel: "[a-z]+[a-zA-Z]*"
    };
    
    const componentElementModifier = `\\.${regex.pascal}(__${regex.camel}(_${regex.camel})?)?`;
    const componentModifier = `\\.${regex.pascal}_${regex.camel}`;
    const bemMix = `\\.${regex.pascal}__${regex.pascal}`;
    
    module.exports = {
      plugins: ["stylelint-prettier", "stylelint-selector-bem-pattern"],
      extends: ["stylelint-prettier/recommended"],
      rules: {
        "prettier/prettier": true,
        "plugin/selector-bem-pattern": {
          componentName: regex.pascal,
          implicitComponents: true,
          componentSelectors: {
            initial: `^(${componentElementModifier})$|^(${bemMix})$|^(${componentModifier})$`
          }
        }
      }
    };
    
    tslint.json

    {
      "extends": [
        "tslint:latest",
        "tslint-react",
        "tslint-plugin-prettier",
        "tslint-config-prettier"
      ],
      "rules": {
        "object-literal-sort-keys": false,
        "prettier": true,
        "no-default-export": true
      },
      "linterOptions": {
        "exclude": ["**/*.less.d.ts"]
      }
    }
    
    Intellij Idea-文件监视程序配置

    Intellij Idea-TSlint配置

    Intellij Idea-类型脚本配置

    packge.json-stylelint config+runner

    我的问题是什么

  • 如何将printWidth 140添加到所有配置
  • 如何将prittier配置共享到tslint和stylelint中
  • 如何使其与package.json和file watcher中的运行程序一起工作
  • 如何将printWidth 140添加到所有配置

    我建议把它放在你的电脑里

    如何将prittier配置共享到tslint和stylelint中

    如果需要,tslint将使用您的更漂亮的配置进行linting/autofixes。同样的道理也适用于中国

    如何使其与package.json和file watcher中的运行程序一起工作

    我不知道我是否了解你。。。我建议删除更漂亮的文件查看器,只使用tslint和stylelint格式化代码。如果希望修复保存时的代码样式问题和/或将npm脚本添加到将运行
    tslint--fix
    stylelint--fix
    命令的
    package.json
    ,则可以将它们配置为文件监视程序