[英]Integration of prettier with Intellij Idea and NPM
我想要达到的目标
我做了什么
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 - 文件观察器配置
packge.json - stylelint 配置 + 跑步者
我的问题
如何将 printWidth 140 添加到所有配置?
我建议在你的.prettierrc 中设置它
如何将更漂亮的配置共享到 tslint 和 stylelint?
如果您进行了相应的配置, tslint 将使用您更漂亮的配置进行 linting/自动修复。 stylelint也是如此
如何使它与 package.json 中的 runners 和文件观察器一起使用
不确定我是否关注你...我建议删除 Prettier 文件观察器,只使用 tslint 和 stylelint 来格式化你的代码。 如果您想在Save和/或将 npm 脚本添加到将运行tslint --fix
和stylelint --fix
命令的package.json
中修复代码样式问题,您可以将它们配置为文件观察器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.