# eslint-config-win **Repository Path**: winjs-dev/eslint-config-win ## Basic Information - **Project Name**: eslint-config-win - **Description**: No description available - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-17 - **Last Updated**: 2022-01-17 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # eslint-config-win 此规则适用于 JavaScript/Vue 项目的 ESLint 配置规范。 **目前已支持 Vue 3.0,需要指定 extends 配置vue3** ## 安装 ```bash yarn add @winner-fed/eslint-config-win -D ``` ## 依赖版本 ```bash eslint ^7.32.0 babel-eslint ^10.1.0 vue-eslint-parser ^7.11.0 eslint-plugin-vue ^7.20.0 ``` *Tips*:如果项目中没有安装此依赖包或者版本不一致,请安装或者升级。 ## 用法 - 在你的项目的根目录下创建一个 `.eslintrc.js` 文件,并将以下内容复制进去: ```js module.exports = { extends: [ '@winner-fed/win', ], env: { // 你的环境变量(包含多个预定义的全局变量) // // browser: true, // node: true, // mocha: true, // jest: true, // jquery: true }, globals: { // 你的全局变量(设置为 false 表示它不允许被重新赋值) // // myGlobal: false }, rules: { // 自定义你的规则 } }; ``` - 项目目录下的 `package.json` 添加检测指令,举个例子 ```diff { ... "scripts": { + "lint:es": "eslint \"src/**/*.{vue,js,jsx}\" --fix", } ... } ``` ### Vue ```bash npm install --save-dev eslint babel-eslint vue-eslint-parser eslint-plugin-vue @winner-fed/eslint-config-win ``` 在你的项目的根目录下创建一个 `.eslintrc.js` 文件,并将以下内容复制进去: ```js module.exports = { extends: [ '@winner-fed/win', // 这里是针对 vue2 的配置 '@winner-fed/win/vue', // 如果是 vue3 的项目工程,则推荐下面配置 // '@winner-fed/win/vue3', ], env: { // 你的环境变量(包含多个预定义的全局变量) // // browser: true, // node: true, // mocha: true, // jest: true, // jquery: true }, globals: { // 你的全局变量(设置为 false 表示它不允许被重新赋值) // // myGlobal: false }, rules: { // 自定义你的规则 } }; ``` ## Vue3 新增规则 | rule | 规则描述 | | ------------------------------------------------------------ | ---------------------------------------------------- | | [vue/custom-event-name-casing ](https://eslint.vuejs.org/rules/custom-event-name-casing.html) | 自定义事件名必须用 kebab-case 风格 | | [vue/no-arrow-functions-in-watch](https://eslint.vuejs.org/rules/no-arrow-functions-in-watch.html) | watch 中禁止使用箭头函数 | | [vue/no-custom-modifiers-on-v-model](https://eslint.vuejs.org/rules/no-custom-modifiers-on-v-model.html) | 禁止自定义的 v-modal 修饰语 | | [vue/no-deprecated-data-object-declaration ](https://eslint.vuejs.org/rules/no-deprecated-data-object-declaration.html) | 禁止在 data 中使用已废弃的对象定义 | | [vue/no-deprecated-destroyed-lifecycle](https://eslint.vuejs.org/rules/no-deprecated-destroyed-lifecycle.html) | 禁止使用已废弃的 destroyed 和 beforeDestroy 生命周期 | | [vue/no-deprecated-dollar-listeners-api](https://eslint.vuejs.org/rules/no-deprecated-dollar-listeners-api.html) | 禁止使用已废弃的 $listeners | | [vue/no-deprecated-dollar-scopedslots-api ](https://eslint.vuejs.org/rules/no-deprecated-dollar-scopedslots-api.html) | 禁止使用已废弃的 $scopedSlots | | [vue/no-deprecated-events-api ](https://eslint.vuejs.org/rules/no-deprecated-events-api.html) | 禁止使用已废弃的 events 接口 | | [vue/no-deprecated-filter ](https://eslint.vuejs.org/rules/no-deprecated-filter.html) | 禁止使用已废弃的 filters 语法 | | [vue/no-deprecated-functional-template](https://eslint.vuejs.org/rules/no-deprecated-functional-template.html) | 禁止使用已废弃的 functional 模版 | | [vue/no-deprecated-html-element-is](https://eslint.vuejs.org/rules/no-deprecated-html-element-is.html) | 禁止使用已废弃的 is 属性 | | [vue/no-deprecated-inline-template](https://eslint.vuejs.org/rules/no-deprecated-inline-template.html) | 禁止使用已废弃的 inline-template 属性 | | [vue/no-deprecated-props-default-this ](https://eslint.vuejs.org/rules/no-deprecated-props-default-this.html) | 禁止使用已废弃的 this | | [vue/no-deprecated-v-bind-sync](https://eslint.vuejs.org/rules/no-deprecated-v-bind-sync.html) | 禁止在 v-bind 指令中使用已废弃的 .sync 修饰符 | | [vue/no-deprecated-v-on-native-modifier](https://eslint.vuejs.org/rules/no-deprecated-v-on-native-modifier.html) | 禁止使用已废弃的 .native 修饰符 | | [vue/no-deprecated-v-on-number-modifiers ](https://eslint.vuejs.org/rules/no-deprecated-v-on-number-modifiers.html) | 禁止使用已废弃的数字修饰符 | | [vue/no-deprecated-vue-config-keycodes](https://eslint.vuejs.org/rules/no-deprecated-vue-config-keycodes.html) | 禁止使用已废弃的 Vue.config.keyCodes | | [vue/no-dupe-v-else-if ](https://eslint.vuejs.org/rules/no-dupe-v-else-if.html) | 禁止在 v-if 和 v-else-if 中出现重复的测试表达式 | | [vue/no-duplicate-attr-inheritance](https://eslint.vuejs.org/rules/no-duplicate-attr-inheritance.html) | 使用 v-bind="$attrs" 时 inheritAttrs 必须是 false | | [vue/no-empty-component-block](https://eslint.vuejs.org/rules/no-empty-component-block.html) | 禁止 `