@4-us-4-others/eslint-config 中文文档教程

发布于 3年前 浏览 19 项目主页 更新于 3年前

4 us & 4 others ESLint + Prettier Configuration

Abstract

这些是我们对 ESLintPrettier 的共享设置。 这个 ESLint 配置检查和格式化我们的代码,使其遵循我们共享的风格指南。 它使用 ESLint 来检查和修复 Javascript,并使用 Prettier 来修复问题并很好地格式化我们的代码。 ???

Installation

安装包:

yarn add @4-us-4-others/eslint-config --dev

@4-us-4-others/eslint-config 需要您处理它的 peerDependencies。 安装每个 peerDependencies 包的正确版本,它们在以下命令中列出:

npx install-peerdeps --dev @4-us-4-others/eslint-config

ESLint Configuration

现在将 @4-us-4-others/eslint-config 添加到您的 .eslintrc.js

// .eslintrc.js
module.exports = {
    extends: '@4-us-4-others/eslint-config',
}

Prettier Configuration

这是您可以在应用中使用或扩展 @4-us-4-others/eslint-config Prettier 配置的方式:

// .prettierrc.js
module.exports = require('@4-us-4-others/eslint-config/.prettierrc.js')

// or to override specific options
module.exports = {
    ...require('@4-us-4-others/eslint-config/.prettierrc.js'),
    semi: true,
}

Development

# first, make sure your working tree is clean by committing all your work
# ⚠️ note: you will need to run the following commands with `npm` instead of `yarn`, because yarn 1.x has issues generating the npm registry tokens needed for logging into npm and publishing packages

# preview
npm run publish:preview

# publish to npm
npm run publish
# we use the package "np" to handle publishing to npm
# np will run an interactive publishing tool to guide you through publishing
# np docs: https://github.com/sindresorhus/np

Notes

4 us & 4 others ESLint + Prettier Configuration

Abstract

These are our shared settings for ESLint and Prettier. This ESLint configuration lints and formats our code so it follows our shared style guide. It uses ESLint to lint and fix Javascript, and Prettier to fix issues and format our code nicely. ????

Installation

Install the package with:

yarn add @4-us-4-others/eslint-config --dev

@4-us-4-others/eslint-config requires you to take care of it's peerDependencies. Install the correct version of each peerDependencies package, which are listed with the following command:

npx install-peerdeps --dev @4-us-4-others/eslint-config

ESLint Configuration

Now add @4-us-4-others/eslint-config to your .eslintrc.js:

// .eslintrc.js
module.exports = {
    extends: '@4-us-4-others/eslint-config',
}

Prettier Configuration

This is how you can use or extend the @4-us-4-others/eslint-config Prettier config in your app:

// .prettierrc.js
module.exports = require('@4-us-4-others/eslint-config/.prettierrc.js')

// or to override specific options
module.exports = {
    ...require('@4-us-4-others/eslint-config/.prettierrc.js'),
    semi: true,
}

Development

# first, make sure your working tree is clean by committing all your work
# ⚠️ note: you will need to run the following commands with `npm` instead of `yarn`, because yarn 1.x has issues generating the npm registry tokens needed for logging into npm and publishing packages

# preview
npm run publish:preview

# publish to npm
npm run publish
# we use the package "np" to handle publishing to npm
# np will run an interactive publishing tool to guide you through publishing
# np docs: https://github.com/sindresorhus/np

Notes

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