@ cabify/eslint- config
TS和JS的ESLint配置, Cabify方式.
安装
npm i -D @cabify/eslint-config eslint prettier
或者说
yarn add --dev @cabify/eslint-config eslint prettier
使用量
- 创建一个
.eslint.config.js在工程根处的文件 :
import recommended from '@cabify/eslint-config';
/* Define an object for local configuration.
/ You can add your custom configuration and override existing rules here before exporting it.
const localConfig = {};
export default [...recommended, localConfig];
*/
export default [...recommended];
- 将线性任务添加到您的
package.json数字 :
...
"scripts": {
...
"lint:fix": "eslint ./ --fix",
"lint": "eslint ./",
...
}
- 添加一个
.globalIgnores在你身边eslint.config.js以避免检查不想要的文件 :
// https://eslint.org/docs/latest/use/configure/configuration-files#globally-ignoring-files-with-ignores
const globalIgnores = {
ignores: [
'dist',
'node_modules/*',
'storybook-static/*',
'test/*',
'build',
'scripts',
'webpack',
],
};
export default [...recommended, globalIgnores];
格式化
重新推荐的配置不包括格式化规则,因为使用Prettier二进制会更快,带来更多的好处.
要格式化您的应用程序 a 中的文件, 并检查它们是否正确格式化, 您可以在您的应用程序中添加以下脚本 package.json 文件 :
...
"scripts": {
...
"format": "prettier --write .",
"format:check": "prettier --check .",
...
}
类型脚本的设置
const localConfigs = {
languageOptions: {
parserOptions: {
project: './tsconfig.json',
ecmaVersion: 2020,
},
},
settings: {
'import/resolver': {
typescript: {
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
project: '<root>/tsconfig.json',
},
},
},
};
export default [...recommended, localConfigs];
- 添加一个
./tsconfig.eslint.json到您的项目根部. 注意:重要的是,你tsconfig.eslint.json文件包含 同样的文件,你要去涂入, 否则它会失败 并让林入如此缓慢.
{
"extends": "./tsconfig.json",
"include": ["src/**/*", "test/**/*"] // remember to import also your test files if you want to lint them
}
关于技术服务项目业绩的说明
还有一个已知的问题可能会影响与TS合作的项目的起伏时间. 如果你注意到你的
消磨时间是无法接受的, 有很多工作来改进它, 但它意味着禁用
一些规则。 如果你能活着没有他们, 就做这些改变你的 .eslintrc 配置 :
{
...
// remove the "project" field (if you don't have any other parserOptions you can remove the full section)
"parserOptions": {},
"rules": {
// this rules depend on project field, so they must be disabled to make linting much faster
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/prefer-includes": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/prefer-string-starts-ends-with": "off",
"@typescript-eslint/require-await": "off",
"@typescript-eslint/unbound-method": "off"
}
}
发布新版本
- 更新 变化 具有新特性, 断开更改等
- 检查你英寸
main分支和一切是最新的. - 运行
yarn publish:<major|minor|patch>或者说yarn publish:canary为金丝雀版本. - 运行
git push && git push --tags - 请检查access-date=中的日期值 (帮助) 上次推后触发的所有测试动作均为QQ.
- 转到 创建新发行,选择先前所推动的标签并写入标题.
- 请检查date=中的日期值 (帮助) Npm 发布动作已成功完成 .
- 检查 npm 包网页,该版本已在
latest标签.
这将触发 Github 的工作流程, 它最终会发布到 npm .
贡献者
感谢这些伟大的人emoji 密钥:
本项目遵循 全部贡献者 规格。 任何捐款都欢迎!