在你的项目根目录下创建 .eslintrc.js,根据不同情况,将代码复制到文件中:
创建 .prettierrc
文件
{
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100,
"proseWrap": "never"
}
npm install --save-dev eslint babel-eslint @diamondyuan/eslint-config-javascript
module.exports = {
extends: ["@diamondyuan/javascript"]
};
npm install --save-dev eslint-config-prettier prettier eslint-plugin-prettier
yarn add --dev eslint-config-prettier prettier eslint-plugin-prettier
module.exports = {
extends: ["@diamondyuan/react-javascript", "prettier"],
plugins: ["prettier"],
rules: {
"prettier/prettier": "error"
}
};
npm install --save-dev eslint babel-eslint eslint-plugin-react eslint-plugin-react-hooks @diamondyuan/eslint-config-react
module.exports = {
extends: ["@diamondyuan/react"]
};
npm install --save-dev eslint-config-prettier prettier eslint-plugin-prettier
yarn add --dev eslint-config-prettier prettier eslint-plugin-prettier
module.exports = {
extends: ["@diamondyuan/react", "prettier", "prettier/react"],
plugins: ["prettier"],
rules: {
"prettier/prettier": "error"
}
};
npm install --save-dev eslint babel-eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin @diamondyuan/eslint-config-typescript
module.exports = {
extends: ["@diamondyuan/typescript"]
};
npm install --save-dev eslint-config-prettier prettier eslint-plugin-prettier
yarn add --dev eslint-config-prettier prettier eslint-plugin-prettier
module.exports = {
extends: [
"@diamondyuan/typescript",
"prettier",
"prettier/@typescript-eslint"
],
plugins: ["prettier"],
rules: {
"prettier/prettier": "error"
}
};
npm install --save-dev eslint typescript babel-eslint eslint-plugin-react eslint-plugin-react-hooks @typescript-eslint/parser @typescript-eslint/eslint-plugin @diamondyuan/eslint-config-react-typescript
module.exports = {
extends: ["@diamondyuan/react-typescript"]
};
npm install --save-dev eslint-config-prettier prettier eslint-plugin-prettier
yarn add --dev eslint-config-prettier prettier eslint-plugin-prettier
module.exports = {
extends: [
"@diamondyuan/react-typescript",
"prettier",
"prettier/@typescript-eslint",
"prettier/react"
],
plugins: ["prettier"],
rules: {
"prettier/prettier": "error"
}
};