@activescott/eslint-config 中文文档教程

发布于 3年前 浏览 14 更新于 3年前

@activescott/eslint-config

npm 版本构建状态

这是 @activescott 的 ESLint 的可共享配置。 默认值针对 TypeScript 进行了优化。 它确实也美化了其他文件,包括 JavaScript、Markdown 等。

将来可能会向此包中添加多个配置,如 https://eslint.org/docs/developer-guide/shareable-configs#sharing-multiple-configs 中所述

Usage

第 1 步:将以下依赖项添加到您的项目中:

npm install --save-dev @activescott/eslint-config @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier prettier

第 2 步:输入以下内容以在根目录中创建一个 .eslintrc.yaml 文件正确的内容:

printf "extends:\n  - \"@activescott/eslint-config\"\n" > .eslintrc.yaml
printf "semi: false\n" > .prettierrc
printf "node_modules/\n/dist/\n/.next/\n.nyc_output/\ncoverage/\n" | tee .eslintignore .prettierignore

第 3 步(可选):将以下脚本添加到 package.json

{
  "scripts": {
    "eslint": "./node_modules/.bin/eslint . --ext ts,tsx,js,jsx",
    "lint": "./node_modules/.bin/prettier -l \"{,!(node_modules)/**/}*.{ts,tsx,md,yml,json,html}\" && npm run eslint",
    "lint-fix": "./node_modules/.bin/prettier --write \"{,!(node_modules)/**/}*.{ts,tsx,md,yml,json,html}\" && npm run eslint --fix"
  }
}

请参阅 https://eslint.org/docs/user-guide/configuring更多信息。

Notes

React

使用 React 时,从 eslint-plugin-react 包中添加 plugin:react/recommended

extends:
  - ...
  - "plugin:react/recommended"

Local Testing

您还可以在发布之前通过全局链接您的模块在您的计算机上测试您的可共享配置。 输入:

npm link

然后,在您想要使用可共享配置的项目中,输入:

npm link @activescott/eslint-config

Release Process (Deploying to NPM) ????

We use semantic-release发布 semver 兼容版本。 该项目部署到多个 npm 分发标签。 以下每个分支都对应于以下 npm 分发标签:

branchnpm distribution tag
masterlatest
betabeta

要触发发布,请使用 Angular Commit Message Conventions 在上述分支之一上。

@activescott/eslint-config

npm versionBuild Status

This is @activescott's sharable config for ESLint. The default is optimized for TypeScript. It does prettify other files too including JavaScript, Markdown, etc.

Multiple config may be added to this package in the future as described at https://eslint.org/docs/developer-guide/shareable-configs#sharing-multiple-configs

Usage

Step 1: Add the following dependencies to your project:

npm install --save-dev @activescott/eslint-config @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier prettier

Step 2: Enter the following to create a .eslintrc.yaml file in the root with the right content:

printf "extends:\n  - \"@activescott/eslint-config\"\n" > .eslintrc.yaml
printf "semi: false\n" > .prettierrc
printf "node_modules/\n/dist/\n/.next/\n.nyc_output/\ncoverage/\n" | tee .eslintignore .prettierignore

Step 3 (optional): Add the following scripts to package.json:

{
  "scripts": {
    "eslint": "./node_modules/.bin/eslint . --ext ts,tsx,js,jsx",
    "lint": "./node_modules/.bin/prettier -l \"{,!(node_modules)/**/}*.{ts,tsx,md,yml,json,html}\" && npm run eslint",
    "lint-fix": "./node_modules/.bin/prettier --write \"{,!(node_modules)/**/}*.{ts,tsx,md,yml,json,html}\" && npm run eslint --fix"
  }
}

See https://eslint.org/docs/user-guide/configuring for more information.

Notes

React

When using React add plugin:react/recommended from package eslint-plugin-react:

extends:
  - ...
  - "plugin:react/recommended"

Local Testing

You can also test your shareable config on your computer before publishing by linking your module globally. Type:

npm link

Then, in your project that wants to use your shareable config, type:

npm link @activescott/eslint-config

Release Process (Deploying to NPM) ????

We use semantic-release to consistently release semver-compatible versions. This project deploys to multiple npm distribution tags. Each of the below branches correspond to the following npm distribution tags:

branchnpm distribution tag
masterlatest
betabeta

To trigger a release use a Conventional Commit following Angular Commit Message Conventions on one of the above branches.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文