-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
86 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
import jest from "eslint-plugin-jest"; | ||
|
||
/* | ||
* 因为无法在 eslint 的配置里获取 jest 的配置,所以没法像 ts 那样直接用。 | ||
* 建议将此扩展写在 overrides 里,仅对测试文件生效: | ||
* { | ||
* overrides: [{ | ||
* files: require("./jest.config").testMatch, | ||
* extends: ["@kaciras/jest"], | ||
* }], | ||
* } | ||
/** | ||
* 因为无法在 eslint 的配置里获取 jest 的配置,所以没法自动配置 files。 | ||
* 建议手动设置 files 属性,仅对测试文件生效: | ||
* | ||
* 我想用 overrides ESLint 似乎没有提供在配置文件里获取 cwd 参数的方法。 | ||
* @example | ||
* import jest from "@kaciras/eslint-config-jest"; | ||
* import { testMatch } from "./jest.config.js"; | ||
* | ||
* export default [{ ...jest, files: testMatch }] | ||
*/ | ||
export default { | ||
...jest.configs["flat/recommended"], | ||
name: "kaciras/jest", | ||
rules: { | ||
...jest.configs["flat/recommended"].rules, | ||
...jest.configs["flat/style"].rules, | ||
|
||
// 生命周期钩子当然要写在最前面啊。 | ||
"jest/prefer-hooks-on-top": 2, | ||
export default [ | ||
jest.configs["flat/recommended"], | ||
jest.configs["flat/style"], | ||
{ | ||
name: "kaciras/jest", | ||
rules: { | ||
// 生命周期钩子当然要写在最前面啊。 | ||
"jest/prefer-hooks-on-top": 2, | ||
|
||
// 无法识别第三方库的断言,添加 assertFunctionNames 也很麻烦。 | ||
"jest/expect-expect": 0, | ||
// 无法识别第三方库的断言,添加 assertFunctionNames 也很麻烦。 | ||
"jest/expect-expect": 0, | ||
|
||
// 有些库还在用回调式的 API,强行转异步不好看。 | ||
"jest/no-done-callback": 0, | ||
// 有些库还在用回调式的 API,强行转异步不好看。 | ||
"jest/no-done-callback": 0, | ||
|
||
// Prefer sugar functions. | ||
"jest/prefer-mock-promise-shorthand": 2, | ||
}, | ||
}; | ||
// Prefer sugar functions. | ||
"jest/prefer-mock-promise-shorthand": 2, | ||
}, | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
import reactRecommended from "eslint-plugin-react/configs/recommended.js"; | ||
import jsxRuntime from "eslint-plugin-react/configs/jsx-runtime.js"; | ||
|
||
/* | ||
* 该配置仅适用于 React 17+ 并使用 React Hooks 的项目。 | ||
*/ | ||
export default [ | ||
reactRecommended, | ||
jsxRuntime, | ||
{ | ||
name: "kaciras/react", | ||
settings: { | ||
react: { | ||
version: "detect", | ||
}, | ||
// Designed for projects that use React 17+ with Hooks. | ||
export default [reactRecommended, jsxRuntime, { | ||
name: "kaciras/react", | ||
settings: { | ||
react: { | ||
version: "detect", | ||
}, | ||
rules: { | ||
// 写太快可能没注意这个,加上该规则以便用 ESLint 批量改。 | ||
"react/jsx-curly-brace-presence": [2, { | ||
props: "never", | ||
children: "never", | ||
}], | ||
}, | ||
rules: { | ||
// 写太快可能没注意这个,加上该规则以便用 ESLint 批量改。 | ||
"react/jsx-curly-brace-presence": [2, { | ||
props: "never", | ||
children: "never", | ||
}], | ||
|
||
// 都是动态页面的时代了,默认的 submit 基本用不到,还容易漏。 | ||
"react/button-has-type": 2, | ||
}, | ||
/* | ||
* If you forget this of a button inside a form, | ||
* click it will refresh the page unexpectedly. | ||
*/ | ||
"react/button-has-type": 2, | ||
}, | ||
]; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import pluginVue from "eslint-plugin-vue"; | ||
|
||
// 里面已经设置了 parser: "vue-eslint-parser" | ||
/** | ||
* Used for Vue SFC without typescript, already includes `files: ["**\/*.vue"]` | ||
*/ | ||
export default [...pluginVue.configs["flat/essential"], { | ||
name: "kaciras/vue", | ||
rules: { | ||
// 没有 emits 或是 onXXX props 的话事件会绑到元素上,应当避免。 | ||
"vue/require-explicit-emits": [2, { allowProps: true }], | ||
|
||
// I use double quote in JS, so single for template. | ||
// I used double quote in JS, so single for template. | ||
"vue/html-quotes": [2, "single", { avoidEscape: true }], | ||
|
||
// 驼峰更好,跟 JSX 一致,同时也和 Custom Element 区分开。 | ||
// Consistent with JSX, and different from custom elements. | ||
"vue/component-name-in-template-casing": [2, "PascalCase"], | ||
}, | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.