@adaliszk/eslint-config-typescript 中文文档教程
Typescript ESLint 元包
这个包包含一个 eslint 配置,它扩展了推荐的和标准的配置,但覆盖了一些 规则:
缩进设置为 4 个空格,以便通过在注意行之间留出更多空间来提高可读性,并具有 包装前的空间更少,因此强制使用更清晰的代码
大括号预计将采用 Allman 风格,通过将语句和声明与 逻辑
在导入和顶级块之间需要两个空行,类似于 PEP8
可推断类型删除被禁用,因为许多类型反射库依赖于声明类型甚至 否则可以推断。
强制在多行语句上使用逗号以获得更好的 git 历史
此外,该配置定义了 node_modules
、temp
和 dist
文件夹的忽略模式。
Provides
@typescript-eslint/eslint-plugin
@typescript-eslint/parser
eslint-config-standard
+ (eslint-plugin-import
,eslint-plugin-promise
,eslint-plugin-n
)eslint
Usage
- Install:
yarn add -D @adaliszk/eslint-config-typescript
- Add an
.eslintrc.yml
with the content of:
extends:
- "@adaliszk/typescript"
或者为了避免混乱,将其放入您的 package.json
:
"eslintConfig": {
"extemds": [
"@adaliszk/typescript"
]
}
Caveats
- When using node module based workspaces, you must include this package as a no-hoist so that eslint would find the configuration correctly.
Versioning
因为这是一个元包,版本控制反映了它提供的主要包,在本例中为 eslint
。 然而,只有 Major 和 Minor 版本保持同步,Patch 用于 bump meta-package。
Typescript ESLint Meta Package
This package contains an eslint configuration that extends the recommended and the standard configs, but overwrites some rules:
Indentation is set to 4 spaces for better readability by having more space between the attention lines, and having less space before wrapping thus forcing a cleaner code
Curly braces are expected to be Allman style for better readability by separating statements and declarations from logic
Two empty lines are required between imports and top level blocks, similar to PEP8
Inferrable type removals are disabled because many type reflection libraries depends on having the types declared even if otherwise it could be inferred.
Force using comas on multi-line statements for better git history
Furthermore, the config defines ignore pattern for node_modules
, temp
, and dist
folders.
Provides
@typescript-eslint/eslint-plugin
@typescript-eslint/parser
eslint-config-standard
+ (eslint-plugin-import
,eslint-plugin-promise
,eslint-plugin-n
)eslint
Usage
- Install:
yarn add -D @adaliszk/eslint-config-typescript
- Add an
.eslintrc.yml
with the content of:
extends:
- "@adaliszk/typescript"
or to avoid clutter, put it into your package.json
:
"eslintConfig": {
"extemds": [
"@adaliszk/typescript"
]
}
Caveats
- When using node module based workspaces, you must include this package as a no-hoist so that eslint would find the configuration correctly.
Versioning
Since this is a meta-package, the versioning reflect its main provided package, in this case eslint
. However, only the Major and Minor versions are kept in sync, and the Patch is used to bump the meta-package.