-
安装
@davincihealthcare/eslint-plugin-davinci作为 dev 依赖的软件包如果你在用的话
eslint >= 9.0.0,您还需要安装以下软件包作为依赖性:@eslint/js@eslint/eslintrc
-
扩展 Eslint 配置文件中的插件
.eslintrc.jsmodule.exports = { extends: [ 'plugin:@davincihealthcare/davinci/recommended', ], }
eslint.config.js
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [{
ignores: ["dist", "**/tsconfig.json"],
}, ...compat.extends("plugin:@davincihealthcare/davinci/recommended")];
-
如果你在用的话
Turbo单曲 :-
安装
eslint-config-turbo作为 dev 依赖 -
扩展
eslint-config-turbo配置中的插件 :.eslintrc.js( module.exports = { extends: [ 'plugin:@davincihealthcare/davinci/recommended', 'eslint-config-turbo' ], } );eslint.config.jsimport path from "node:path"; import { fileURLToPath } from "node:url"; import js from "@eslint/js"; import { FlatCompat } from "@eslint/eslintrc"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname, recommendedConfig: js.configs.recommended, allConfig: js.configs.all }); export default [{ ignores: ["dist", "**/tsconfig.json"], }, ...compat.extends("plugin:@davincihealthcare/davinci/recommended", "eslint-config-turbo")];
-
-
在你身边
package.json文件中,您应该添加脚本来进行林入检查和/或尽可能自动修正林入错误- 丝林 < 9.0.0
package.json{ ... "scripts": { ... "eslint-check": "eslint -c .eslintrc.js --ext \".js,.ts\" ." "eslint-fix": "eslint --fix -c .eslintrc.js --ext \".js,.ts\" ." ... } ... }
- eslint >= 9.0.0
`package.json`
```
{
...
"scripts": {
...
"eslint-check": "eslint ."
"eslint-fix": "eslint --fix ."
...
}
...
}
```
规则
级别 base, (中文(简体) ), recommended 财务报告和审定财务报表 vue 相会相会.
| 规则 | 说明 | base 编号 : recommended | vue |
|---|---|---|---|
no-native-date | 不使用本地语言 Date 对象,使用豪华 DateTime | 关 | 错误 |
no-router-push | 不使用 router.push编号 :resolve,使用时 useRouterUtils | 错误 | 错误 |
no-unsafe-url-params | 不使用不安全的 URL 参数, 使用 useRouterUtils | 错误 | 错误 |
prefer-lookup-map | 偏好在 A 之上检查对象 switch 只将常数映射到结果 | 警告( e) | 警告( e) |
simple-array-type | 使用 Type[] 用于单一类型的简单数组 | 关 | 关 |
tuple-array-type | 使用 [Type] 以定义拖曳 | 关 | 关 |