@1password/front-end-style 中文文档教程
1Password Front-End Style
此软件包包含使用 Prettier、ESLint 和 Stylelint 的 1Password 前端代码样式的配置。
Usage
安装后,您需要配置您的项目以使用这些样式:
Prettier
添加到您的 package.json
文件:
"prettier": "@1password/front-end-style/prettierrc.json"
ESLint
创建一个 eslintrc.yml
文件:
---
extends:
- "@1password/front-end-style/eslintrc.yml"
Stylelint
添加到您的 package.json
文件:
"stylelint": {
"extends": "@1password/front-end-style/stylelintrc.yml"
}
SVG Lint
还包含一个基本的 SVG linting 工具,用于检查不必要的换行符和标签。
使用 svglint [directory]
运行
IDE Extensions
您还应该安装相关的 IDE 扩展,这样您就可以在编写代码时发现问题(有时会自动修复)。
Prettier
- https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
- https://atom.io/packages/prettier-atom
ESLint
- https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
- https://atom.io/packages/eslint
Stylelint
- https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint
- https://atom.io/packages/linter-stylelint
Versioning Expectations
我们将在更新包版本号时使用语义版本控制。 以下用于区分版本标识符。
格式:major
.minor
.patch
major
:任何breaking更改- Example:
- Adding a package with new rules
- Upgrading errors (warn to error)
major
version bump of any NPM dependencies inpackage.json
- Example:
次要
:影响包功能的任何非破坏性更改- Example:
- Downgrading errors (error to warn)
minor
version bump of any NPM dependencies inpackage.json
, but nomajor
version bump
- Example:
补丁
:任何不影响包功能的更改- Example:
- Changing code comments
- Changing the error message of a custom rule
- Only
patch
version bumps of NPM dependencies inpackage.json
- Updating
yarn.lock
- Example:
1Password Front-End Style
This package contains config for 1Password front-end code style using Prettier, ESLint, and Stylelint.
Usage
After installing, you'll need to configure your project to use these styles:
Prettier
Add to your package.json
file:
"prettier": "@1password/front-end-style/prettierrc.json"
ESLint
Create an eslintrc.yml
file:
---
extends:
- "@1password/front-end-style/eslintrc.yml"
Stylelint
Add to your package.json
file:
"stylelint": {
"extends": "@1password/front-end-style/stylelintrc.yml"
}
SVG Lint
A basic SVG linting tool is included as well, which checks for unnecessary line breaks and tags.
Run with svglint [directory]
IDE Extensions
You should also install the related IDE extensions so you can see issues (and sometimes get them auto-fixed) as you code.
Prettier
- https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
- https://atom.io/packages/prettier-atom
ESLint
- https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
- https://atom.io/packages/eslint
Stylelint
- https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint
- https://atom.io/packages/linter-stylelint
Versioning Expectations
We'll be using semantic versioning when updating the package version number. The following is used to differentiate between the version identifiers.
Format: major
.minor
.patch
major
: Any breaking change- Example:
- Adding a package with new rules
- Upgrading errors (warn to error)
major
version bump of any NPM dependencies inpackage.json
- Example:
minor
: Any non-breaking change affecting the functionality of the package- Example:
- Downgrading errors (error to warn)
minor
version bump of any NPM dependencies inpackage.json
, but nomajor
version bump
- Example:
patch
: Any change not affecting the functionality of the package- Example:
- Changing code comments
- Changing the error message of a custom rule
- Only
patch
version bumps of NPM dependencies inpackage.json
- Updating
yarn.lock
- Example: