-
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
6 changed files
with
79 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
module.exports = { | ||
extends: ["next/core-web-vitals", "next/typescript", "./react.js"], | ||
extends: ["next/core-web-vitals", "next/typescript", "./ts.js"], | ||
rules: { | ||
...require("./shared-react.js"), | ||
}, | ||
} |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module.exports = { | ||
"react/prop-types": "off", | ||
"react/display-name": "off", | ||
/** | ||
* Enable deps autofix. I've only had infinite loops once, and the autofix was off, | ||
* I just accept the suggestions and don't spend time analysing it. Rare to happen, easy to notice. | ||
* | ||
* https://github.com/facebook/react/issues/18235#issuecomment-898636301 | ||
*/ | ||
"react-hooks/exhaustive-deps": [ | ||
"warn", | ||
{ | ||
enableDangerousAutofixThisMayCauseInfiniteLoops: true, | ||
}, | ||
], | ||
/** https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-useless-fragment.md */ | ||
// Dropped it as it won't allow <></> to fit JSX.Element return. | ||
// "react/jsx-no-useless-fragment": ["warn", {"allowExpressions": true}], | ||
|
||
/** | ||
* From <A b={'c'}>d</A> to <A b="c">{'d'}<A/> | ||
* | ||
* Note that it always converts to double-quotes when changing, | ||
* so we use `jsx-quotes` rule for props and `quotes` rule for children. | ||
* | ||
* https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md | ||
*/ | ||
"react/jsx-curly-brace-presence": [ | ||
"warn", | ||
{ props: "never", children: "always" }, | ||
], | ||
|
||
/** | ||
* Prefer <> over <React.Fragment> if not using key=''. | ||
* | ||
* https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md | ||
*/ | ||
"react/jsx-fragments": "warn", | ||
|
||
/** https://www.npmjs.com/package/eslint-plugin-react-refresh */ | ||
"react-refresh/only-export-components": [ | ||
"warn", | ||
// Only Vite supports this. | ||
{ allowConstantExport: true }, | ||
], | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { test } from "bun:test" | ||
import path from "node:path" | ||
import { $ } from "bun" | ||
|
||
const flavors = ["index", "ts", "js", "react", "react-native"] | ||
|
||
$.cwd(path.resolve(__dirname)) | ||
|
||
test("can run eslint", async () => { | ||
const execs = flavors.map((flavor) => | ||
$`bunx eslint --config ../${flavor}.js test.test.ts`.catch( | ||
(err: unknown) => { | ||
throw new Error(`error on flavor ${flavor}: ${err}`) | ||
}, | ||
), | ||
) | ||
|
||
await Promise.all(execs) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@sindresorhus/tsconfig" | ||
} |