{"_id":"@chaos-kit/eslint-config-format-vue","_rev":"1-7b8fec42e3f7599f5818353fc2f1660b","name":"@chaos-kit/eslint-config-format-vue","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@chaos-kit/eslint-config-format-vue","version":"0.0.1","keywords":["eslint","eslintplugin","eslint-plugin","typescript"],"descriptioin":"souche vue next fomatter","main":"index.js","peerDependencies":{"babel-eslint":"^10.1.0","eslint":"^7.13.0","prettier":"^2.1.2","typescript":"^4.0.5"},"publishConfig":{"registry":"http://registry.npmjs.org/","access":"public"},"dependencies":{"@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","eslint-config-prettier":"^6.15.0","eslint-plugin-prettier":"^3.1.4","eslint-plugin-prettier-vue":"^2.1.1","eslint-plugin-typescript":"^0.14.0","eslint-plugin-vue":"^7.1.0","typescript":"^4.0.5","vue-eslint-parser":"^7.1.1"},"prettier":{"singleQuote":true},"gitHead":"99b6d279f9ea27ffa01ea5fcaabde80cd4ba6caf","description":"> eslint config for personal project with vue3 + ts","_id":"@chaos-kit/eslint-config-format-vue@0.0.1","dist":{"shasum":"ed66bbf1cb9f00a4110efdf4124b605ecb0e8f4c","integrity":"sha512-1ZXhtC4V05JapKQIeQPu6/+3HFC41fjKQWjstnlEneEN0vMARhAznc99fgo1mMcBwV1fTFmVWZz6Yo6fPRCaVA==","tarball":"https://registry.npmjs.org/@chaos-kit/eslint-config-format-vue/-/eslint-config-format-vue-0.0.1.tgz","fileCount":4,"unpackedSize":12369,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrLygCRA9TVsSAnZWagAATs4QAIGJvsBbMJhYEcgZzKas\nDYOm8lKacarC8viIpXZ5jgJPkOlH92ePA8XOgfCIhgVqnlQD0U4qsrixCj67\nnNP1OptrL1YT32XpwpWsI6FDueKDjzENJ147BGcVZtUmQNPLrzxqLQbR6lHb\nJLjFrZ/rb3xDKUz9o2XFjrJTTbSxnqzahTMh6ims9f/O+1YI+LRGpQ1w3wyI\nIJKLqVfW98laUcbWCpU9eb1kEvdmJxDm/7Tw7GBSATLSyxf3vV3JVkYZU03i\n9C/pl4AsTL+RH+uIWk2DXzBWeITf2Ks2rLPk2D/uJfUbJ6RkvW6CLk9DLFG+\ncWZuxGFQqpV0f+ocB8E9vGefpB+E1uRx067eu2nR2tCYr4h8e85bBBYz68j/\nV9JBwY4I2wtc19qwVT2Wul45aGrNYF4iEE8dXlizLy3M5qlpb/l89p2cJgZz\nNu13kqg+pZMHrU16FpCvKQ9sxh0z0yeGmkavAP6Yw+/PzpmLsp2RXq1hzypX\n5C+rVSkwtL4/SckFIX3BHKgZ2v2SBIqOVu/UtWKNRE5BVeFpJKN1C8U+KCWV\nynKJpGKHvYrZBpGTWdhLcIFK/RE0keDfY+6LX0Ur9zNns7ly42VhXvHYUZuC\nrXmk6qTLNLEDRIcviGPJpNzvmM0EEwh9xmrxr0fOMdtd29ndJcuqLUKkerO1\nomdJ\r\n=9mh2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCzHzIH4thhMuUQdnn2I6THoSD2Hv1Usrt9KdATKw1DngIhAI7PyZ3ymeQuRH092a7eylADFAcYlpXszIjV3ny6F804"}]},"_npmUser":{"name":"jeiizou","email":"997282173@qq.com"},"directories":{},"maintainers":[{"name":"jeiizou","email":"997282173@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eslint-config-format-vue_0.0.1_1621933216385_0.6502283073232398"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-25T09:00:16.058Z","0.0.1":"2021-05-25T09:00:16.517Z","modified":"2022-04-04T22:31:06.040Z"},"maintainers":[{"name":"jeiizou","email":"997282173@qq.com"}],"description":"> eslint config for personal project with vue3 + ts","keywords":["eslint","eslintplugin","eslint-plugin","typescript"],"readme":"# @chaos-kit/eslint-config-format-vue\n\n> eslint config for personal project with vue3 + ts\n\n## Usage\n\ninstall:\n\n```sh\nyarn add -D @chaos-kit/eslint-config-formate-vue\n```\n\nusage:\n\n```json\n//  package.json\n{\n  ...\n  \"eslintConfig\": {\n    \"root\": true,\n    \"extends\": \"@chaos-kit/format-vue\"\n  },\n}\n```\n\n## Rules\n\nall plugins:\n\n- [eslint:recommended](http://eslint.cn/docs/rules/)\n- [vue/vue3-essential](https://eslint.vuejs.org/rules/)\n- [@typescript-eslint/recommended](https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin)\n- [prettier/@typescript-eslint, prettier/vue, prettier](https://github.com/prettier/eslint-config-prettier/blob/master/README.md)\n- [prettier option](https://prettier.io/docs/en/options.html)\n\n\n### Custom Rule Explain\n\n#### Error\n\n1. `no-async-promise-executor`: 禁止使用异步函数作为 Promise executor\n2. `no-empty`: 禁止空块语句, 如果需要使用, 则应该添加注释\n3. `no-debugger`: 禁止生产环境下的`debugger`\n4. `no-extra-boolean-cast`: 禁止不必要的布尔转换\n5. `no-func-assign`: 禁止对`function`声明的重新赋值\n6. `no-inner-declarations` 禁止在嵌套的语句块中出现变量或 function 声明, const/let 除外\n7. `no-prototype-builtins`: 禁止直接使用 Object.prototypes 的内置属性\n8.  `no-extra-parens`: 禁止不必要的括号\n9.  `require-atomic-updates`: 禁止由于 await 或 yield的使用而可能导致出现竞态条件的赋值\n10. `use-isnan`: 要求调用 isNaN()检查 NaN\n11. `class-methods-use-this`: 强制类方法使用 this\n12. `default-case`: 要求switch必须含有default\n13. `eqeqeq`: 使用强等判断\n14. `dot-location`: 要求点操作符和属性放在同一行\n15. `guard-for-in`: 强制需要约束 for-in\n16. `no-alert`: 禁止 alert、confirm 和 prompt\n\n```js\n/*eslint guard-for-in: \"error\"*/\nfor (key in foo) {\n    if (Object.prototype.hasOwnProperty.call(foo, key)) {\n        doSomething(key);\n    }\n}\n\nfor (key in foo) {\n    if ({}.hasOwnProperty.call(foo, key)) {\n        doSomething(key);\n    }\n}\n```\n\n19. `no-fallthrough`: 禁止 case 语句落空\n20. `no-global-assign`: 禁止对原生对象或只读的全局对象进行赋值\n21. `no-with`: 禁止使用`with`\n22. `no-delete-var`: 禁止删除变量\n23. `no-undef`: 禁止使用未声明的变量\n24. `block-scoped-var`: 禁止在作用域外调用变量\n25. `no-var`: 禁止使用var\n26. `prefer-const`: 能用const的地方必须使用const\n\n#### Warn\n\n1. `no-console`: 生产环境下`console`警告\n2. `no-sparse-arrays`:稀疏数组警告\n3. `no-unreachable`: return 后的不可达代码警告 \n4. `no-empty-function`: 空函数警告\n5. `no-await-in-loop`:  不禁止循环异步\n6. `prefer-rest-params`: 推荐使用剩余参数而不是argument\n7. `prefer-template`: 推荐使用模板字符串而不是字符串拼接\n8. `no-extra-parens`: 禁止不必要的括号\n9. `no-template-curly-in-string`: 模板字符串引用警告\n\n\n### vue3 rule\n\n1. `vue/no-deprecated-destroyed-lifecycle`: 不使用不推荐的生命周期\n\n```js\nexport default {\n  /* ✓ GOOD */\n  beforeMount () {},\n  mounted () {},\n  beforeUnmount () {},\n  unmounted () {},\n\n  /* ✗ BAD */\n  beforeDestroy () {},\n  destroyed () {}\n}\n```\n\n2. 不推荐使用`$listeners`, `$scopedSlots`, `$on`, `$off`, `$once`\n3. `vue/no-deprecated-filter`: 不推荐使用filter语法\n\n```vue\n<template>\n  <!-- ✓ GOOD -->\n  {{ filter(msg) }}\n  {{ filter(msg, '€') }}\n  {{ filterB(filterA(msg)) }}\n  <div v-bind:id=\"filter(msg)\"></div>\n  <div v-bind:id=\"filter(msg, '€')\"></div>\n  <div v-bind:id=\"filterB(filterA(msg))\"></div>\n\n  <!-- ✗ BAD -->\n  {{ msg | filter }}\n  {{ msg | filter('€') }}\n  {{ msg | filterA | filterB }}\n  <div v-bind:id=\"msg | filter\"></div>\n  <div v-bind:id=\"msg | filter('€')\"></div>\n  <div v-bind:id=\"msg | filterA | filterB\"></div>\n</template>\n```\n\n4. `vue/no-deprecated-functional-template`: 不推荐使用`functional template`\n5. `vue/no-deprecated-props-default-this`: 不推荐在prop中使用this\n\n```vue\n<script>\nexport default {\n  props: {\n    a: String,\n    b: {\n      default () {\n        /* ✗ BAD */\n        return this.a\n      }\n    }\n  }\n}\n</script>\n```\n\n6. `vue/no-deprecated-slot-attribute`: 使用推荐的slot语法\n\n```vue\n<template>\n  <ListComponent>\n    <!-- ✓ GOOD -->\n    <template v-slot:name>\n      {{ props.title }}\n    </template>\n  </ListComponent>\n  <ListComponent>\n    <!-- ✗ BAD -->\n    <template slot=\"name\">\n      {{ props.title }}\n    </template>\n  </ListComponent>\n</template>\n```\n\n7. `vue/no-deprecated-v-bind-sync`: 禁用`sync`绑定\n\n```vue\n<template>\n  <!-- ✓ GOOD -->\n  <MyComponent v-bind:propName=\"foo\"/>\n  <MyComponent :propName=\"foo\"/>\n\n\n  <!-- ✗ BAD -->\n  <MyComponent v-bind:propName.sync=\"foo\"/>\n  <MyComponent v-bind:[dynamiArg].sync=\"foo\"/>\n  <MyComponent v-bind.sync=\"foo\"/>\n  <MyComponent :propName.sync=\"foo\"/>\n</template>\n```\n\n8. `vue/no-deprecated-v-on-native-modifier`: 禁用`native`\n9. `vue/no-lifecycle-after-await`: 禁止在`await`之后写生命周期\n\n```vue\n<script>\nimport { onMounted } from 'vue'\nexport default {\n  async setup() {\n    /* ✓ GOOD */\n    onMounted(() => { /* ... */ })\n\n    await doSomething()\n\n    /* ✗ BAD */\n    onMounted(() => { /* ... */ })\n  }\n}\n</script>\n```\n\n10. `vue/no-ref-as-operand`: 禁止直接操作ref值\n\n```vue\n<script>\nimport { ref } from 'vue'\n\nexport default {\n  setup () {\n    const count = ref(0)\n    const ok = ref(true)\n\n    /* ✓ GOOD */\n    count.value++\n    count.value + 1\n    1 + count.value\n    var msg = ok.value ? 'yes' : 'no'\n\n    /* ✗ BAD */\n    count++\n    count + 1\n    1 + count\n    var msg = ok ? 'yes' : 'no'\n\n    return {\n      count\n    }\n  }\n}\n</script>\n```\n\n10. `vue/no-setup-props-destructure`: 禁止解构`prop`\n\n```vue\n<script>\nexport default {\n  /* ✓ GOOD */\n  setup(props) {\n    watch(() => {\n      console.log(props.count)\n    })\n\n    return () => {\n      return h('div', props.count)\n    }\n  }\n}\n</script>\n```\n\n11. `vue/no-watch-after-await`: 禁止在`await`之后`watch`\n12. `vue/require-slots-as-functions`: 强制以`function`方式调用`$slots`\n\n```vue\n<script>\nexport default {\n  render(h) {\n    /* ✓ GOOD */\n    var children = this.$slots.default()\n    var children = this.$slots.default && this.$slots.default()\n\n    /* ✗ BAD */\n    var children = [...this.$slots.default]\n    var children = this.$slots.default.filter(test)\n  }\n}\n</script>\n```\n\n### Rule for Typescript\n\nrecommand read:\n\n- [《六》Typescript 最佳实践](https://mp.weixin.qq.com/s/Fi7RINtu71NuXM3GUmbiQQ)\n\n\n1. `@typescript-eslint/adjacent-overload-signatures`\n\n```ts\n/* ✗ BAD */\ndeclare namespace Foo {\n  export function foo(s: string): void;\n  export function foo(n: number): void;\n  export function bar(): void;\n  export function foo(sn: string | number): void;\n}\n\n/* ✓ GOOD */\ndeclare namespace Foo {\n  export function foo(s: string): void;\n  export function foo(n: number): void;\n  export function foo(sn: string | number): void;\n  export function bar(): void;\n}\n```\n\n2. `@typescript-eslint/await-thenable`: 必须`await`一个`thenable`\n3. `@typescript-eslint/explicit-module-boundary-types`: 在导出函数和类的公共类方法上要求显式的返回值和参数类型\n4. `@typescript-eslint/no-empty-interface`: 禁止空的接口声明\n5. `@typescript-eslint/no-explicit-any`: 允许any, 但不推荐, 如何不使用any参考[[译] 理解TypeScript 中 any 和 unknown](https://zhuanlan.zhihu.com/p/104296850)\n6. `@typescript-eslint/no-for-in-array`: 禁止使用`for-in`遍历数组\n7. `@typescript-eslint/no-this-alias`: 禁止重命名`this`\n","readmeFilename":"README.md"}