Skip to content

Commit

Permalink
feat: update versions, support typescript@6 and prettier@3
Browse files Browse the repository at this point in the history
  • Loading branch information
xcatliu committed Jul 28, 2023
1 parent 66810e7 commit ce3ff00
Show file tree
Hide file tree
Showing 48 changed files with 1,390 additions and 1,115 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// 默认值已经包含了大多数文件类型了,故不需要再特殊配制
// "eslint.probe": ["javascript", "javascriptreact", "typescript", "typescriptreact", "html", "vue", "markdown"],
"editor.codeActionsOnSave": {
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,6 @@ module.exports = {
},
rules: {
// Customize your rules
//
// Please keep this rule off because it requiresTypeChecking
// https://github.com/vuejs/vue-eslint-parser/issues/104
// https://github.com/typescript-eslint/typescript-eslint/pull/5318
'@typescript-eslint/prefer-optional-chain': 'off',
},
};
```
Expand Down
5 changes: 0 additions & 5 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,6 @@ module.exports = {
},
rules: {
// Customize your rules
//
// Please keep this rule off because it requiresTypeChecking
// https://github.com/vuejs/vue-eslint-parser/issues/104
// https://github.com/typescript-eslint/typescript-eslint/pull/5318
'@typescript-eslint/prefer-optional-chain': 'off',
},
};
```
Expand Down
18 changes: 9 additions & 9 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* zoubingwu <[email protected]>
*
* 依赖版本:
* eslint ^8.38.0
* @babel/core ^7.21.4
* @babel/eslint-parser ^7.21.3
* @babel/preset-react ^7.18.6
* eslint-plugin-react ^7.32.2
* vue-eslint-parser ^9.1.1
* eslint-plugin-vue ^9.11.0
* @typescript-eslint/parser ^5.59.0
* @typescript-eslint/eslint-plugin ^5.59.0
* eslint ^8.45.0
* @babel/core ^7.22.9
* @babel/eslint-parser ^7.22.9
* @babel/preset-react ^7.22.5
* eslint-plugin-react ^7.33.0
* vue-eslint-parser ^9.3.1
* eslint-plugin-vue ^9.15.1
* @typescript-eslint/parser ^6.2.0
* @typescript-eslint/eslint-plugin ^6.2.0
*
* 此文件是由脚本 scripts/build.ts 自动生成
*/
Expand Down
11 changes: 10 additions & 1 deletion config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,5 +667,14 @@
"强制实施 defaultProps 声明按字母顺序排序": "Enforce defaultProps declarations alphabetical sorting",
"在 `<template>` 中的每个数组元素后强制添加换行符": "Enforce line breaks after each array element in `<template>`",
"要求或禁止组件定义中的填充行": "require or disallow padding lines in component definition",
"禁止将枚举值与非枚举值进行比较": "Disallow comparing an enum value with a non-enum value"
"禁止将枚举值与非枚举值进行比较": "Disallow comparing an enum value with a non-enum value",
"限制单文件组件块中的最大行数": "enforce maximum number of lines in Vue SFC blocks",
"禁止特定的组件名称": "disallow specific component names",
"禁止在根元素上使用 v-if 指令": "disallow `v-if` directives on root element",
"强制使用 defineOptions 而不是默认导出": "enforce use of `defineOptions` instead of default export.",
"需要特定的宏变量名称": "require a certain macro variable name",
"要求 ref 和 shallowRef 函数需要强制类型化": "require `ref` and `shallowRef` functions to be strongly typed",
"强制执行有效的 defineOptions 编译器宏": "enforce valid `defineOptions` compiler macro",
"需要 ts 支持": "需要 ts 支持",
"可以防止错误的使用 defineOptions": "可以防止错误的使用 defineOptions"
}
2 changes: 1 addition & 1 deletion config/rules/react.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
"description": "禁止使用已废弃的 api",
"reason": "",
"badExample": "<mark class=\"eslint-error\" data-tip=\"React.render is deprecated since React 0.14.0, use ReactDOM.render instead&lt;br/&gt;&lt;span class='eslint-error-rule-id'&gt;eslint(react/no-deprecated)&lt;/span&gt;\">React<span class=\"token punctuation\">.</span><span class=\"token function\">render</span></mark><span class=\"token punctuation\">(</span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span><span class=\"token class-name\">Foo</span></span> <span class=\"token punctuation\">/></span></span><span class=\"token punctuation\">,</span> app<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">class</span> <span class=\"token class-name\">Foo</span> <span class=\"token keyword\">extends</span> <span class=\"token class-name\">React<span class=\"token punctuation\">.</span>Component</span> <span class=\"token punctuation\">{</span>\n <span class=\"token function\"><mark class=\"eslint-error\" data-tip=\"componentWillMount is deprecated since React 16.9.0, use UNSAFE_componentWillMount instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillmount. Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.&lt;br/&gt;&lt;span class='eslint-error-rule-id'&gt;eslint(react/no-deprecated)&lt;/span&gt;\">componentWillMount</mark></span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>\n <span class=\"token function\"><mark class=\"eslint-error\" data-tip=\"componentWillReceiveProps is deprecated since React 16.9.0, use UNSAFE_componentWillReceiveProps instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops. Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.&lt;br/&gt;&lt;span class='eslint-error-rule-id'&gt;eslint(react/no-deprecated)&lt;/span&gt;\">componentWillReceiveProps</mark></span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>\n <span class=\"token function\"><mark class=\"eslint-error\" data-tip=\"componentWillUpdate is deprecated since React 16.9.0, use UNSAFE_componentWillUpdate instead, see https://reactjs.org/docs/react-component.html#unsafe_componentwillupdate. Use https://github.com/reactjs/react-codemod#rename-unsafe-lifecycles to automatically update your components.&lt;br/&gt;&lt;span class='eslint-error-rule-id'&gt;eslint(react/no-deprecated)&lt;/span&gt;\">componentWillUpdate</mark></span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span>",
"goodExample": "ReactDOM<span class=\"token punctuation\">.</span><span class=\"token function\">render</span><span class=\"token punctuation\">(</span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span><span class=\"token class-name\">Foo</span></span> <span class=\"token punctuation\">/></span></span><span class=\"token punctuation\">,</span> app<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token keyword\">class</span> <span class=\"token class-name\">Foo</span> <span class=\"token keyword\">extends</span> <span class=\"token class-name\">React<span class=\"token punctuation\">.</span>Component</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>",
"goodExample": "<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> createRoot <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'react-dom/client'</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> container <span class=\"token operator\">=</span> document<span class=\"token punctuation\">.</span><span class=\"token function\">getElementById</span><span class=\"token punctuation\">(</span><span class=\"token string\">'app'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> root <span class=\"token operator\">=</span> <span class=\"token function\">createRoot</span><span class=\"token punctuation\">(</span>container<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// createRoot(container!) if you use TypeScript</span>\nroot<span class=\"token punctuation\">.</span><span class=\"token function\">render</span><span class=\"token punctuation\">(</span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span><span class=\"token class-name\">App</span></span> <span class=\"token attr-name\">tab</span><span class=\"token attr-value\"><span class=\"token punctuation\">=</span><span class=\"token punctuation\">\"</span>home<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>",
"fixable": false,
"extendsBaseRule": "",
"requiresTypeChecking": false
Expand Down
34 changes: 17 additions & 17 deletions config/rules/typescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,21 @@
"reason": "",
"badExample": "<span class=\"token keyword\">class</span> <span class=\"token class-name\">Foo1</span> <span class=\"token punctuation\">{</span>\n <span class=\"token keyword\">public</span> <span class=\"token keyword\">get</span> <span class=\"token function\"><mark class=\"eslint-error\" data-tip=\"Literals should be exposed using readonly fields.&lt;br/&gt;&lt;span class='eslint-error-rule-id'&gt;eslint(@typescript-eslint/class-literal-property-style)&lt;/span&gt;\">bar</mark></span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n <span class=\"token keyword\">return</span> <span class=\"token number\">1</span><span class=\"token punctuation\">;</span>\n <span class=\"token punctuation\">}</span>\n<span class=\"token punctuation\">}</span>",
"goodExample": "<span class=\"token keyword\">class</span> <span class=\"token class-name\">Foo2</span> <span class=\"token punctuation\">{</span>\n <span class=\"token keyword\">public</span> <span class=\"token keyword\">readonly</span> bar <span class=\"token operator\">=</span> <span class=\"token number\">1</span><span class=\"token punctuation\">;</span>\n<span class=\"token punctuation\">}</span>",
"fixable": true,
"fixable": false,
"extendsBaseRule": "",
"requiresTypeChecking": false
},
"@typescript-eslint/class-methods-use-this": {
"name": "@typescript-eslint/class-methods-use-this",
"value": "off",
"description": "在类的非静态方法中,必须存在对 this 的引用",
"reason": "",
"badExample": "",
"goodExample": "",
"fixable": true,
"extendsBaseRule": "class-methods-use-this",
"requiresTypeChecking": false
},
"@typescript-eslint/consistent-generic-constructors": {
"name": "@typescript-eslint/consistent-generic-constructors",
"value": "off",
Expand Down Expand Up @@ -701,17 +712,6 @@
"extendsBaseRule": "no-throw-literal",
"requiresTypeChecking": true
},
"@typescript-eslint/no-type-alias": {
"name": "@typescript-eslint/no-type-alias",
"value": "off",
"description": "禁止使用类型别名",
"reason": "",
"badExample": "",
"goodExample": "",
"fixable": false,
"extendsBaseRule": "",
"requiresTypeChecking": false
},
"@typescript-eslint/no-unnecessary-boolean-literal-compare": {
"name": "@typescript-eslint/no-unnecessary-boolean-literal-compare",
"value": "off",
Expand Down Expand Up @@ -1044,14 +1044,14 @@
},
"@typescript-eslint/prefer-optional-chain": {
"name": "@typescript-eslint/prefer-optional-chain",
"value": "error",
"value": "off",
"description": "使用 optional chaining 替代 &&",
"reason": "",
"badExample": "<span class=\"token keyword\">let</span> foo1<span class=\"token punctuation\">:</span> <span class=\"token builtin\">any</span><span class=\"token punctuation\">;</span>\n<span class=\"token builtin\">console</span><span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><mark class=\"eslint-error\" data-tip=\"Prefer using an optional chain expression instead, as it&amp;apos;s more concise and easier to read.&lt;br/&gt;&lt;span class='eslint-error-rule-id'&gt;eslint(@typescript-eslint/prefer-optional-chain)&lt;/span&gt;\">foo1 <span class=\"token operator\">&amp;&amp;</span> foo1<span class=\"token punctuation\">.</span>a <span class=\"token operator\">&amp;&amp;</span> foo1<span class=\"token punctuation\">.</span>a<span class=\"token punctuation\">.</span>b <span class=\"token operator\">&amp;&amp;</span> foo1<span class=\"token punctuation\">.</span>a<span class=\"token punctuation\">.</span>b<span class=\"token punctuation\">.</span>c</mark><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>",
"goodExample": "<span class=\"token keyword\">let</span> foo2<span class=\"token punctuation\">:</span> <span class=\"token builtin\">any</span><span class=\"token punctuation\">;</span>\n<span class=\"token builtin\">console</span><span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>foo2<span class=\"token operator\">?</span><span class=\"token punctuation\">.</span>a<span class=\"token operator\">?</span><span class=\"token punctuation\">.</span>b<span class=\"token operator\">?</span><span class=\"token punctuation\">.</span>c<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>",
"fixable": false,
"badExample": "",
"goodExample": "",
"fixable": true,
"extendsBaseRule": "",
"requiresTypeChecking": false
"requiresTypeChecking": true
},
"@typescript-eslint/prefer-readonly": {
"name": "@typescript-eslint/prefer-readonly",
Expand Down
Loading

0 comments on commit ce3ff00

Please sign in to comment.